On/Off requests now repeat.
Using Minimal SPIFFS, can now fit internal Bluetooth code BUT internal Bluetooth and WiFi bang radio heads - refusing to co-operate :-(
This commit is contained in:
parent
dc8e1940f2
commit
a7b6399c30
7 changed files with 35 additions and 10 deletions
2
Arduino/BTCDieselHeater/.vscode/arduino.json
vendored
2
Arduino/BTCDieselHeater/.vscode/arduino.json
vendored
|
@ -3,5 +3,5 @@
|
|||
"port": "192.168.0.108",
|
||||
"sketch": "BTCDieselHeater.ino",
|
||||
"output": "..\\build",
|
||||
"configuration": "PSRAM=disabled,PartitionScheme=default,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=none"
|
||||
"configuration": "PSRAM=disabled,PartitionScheme=min_spiffs,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=none"
|
||||
}
|
|
@ -11,6 +11,8 @@
|
|||
#define USE_BLE_BLUETOOTH 0
|
||||
#define USE_CLASSIC_BLUETOOTH 0
|
||||
|
||||
#define USE_WIFI 1
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// limit rate of Bluetooth delivery from enthusiastic OEM controllers
|
||||
|
|
|
@ -170,10 +170,12 @@ void setup() {
|
|||
// this is the usual USB connection to a PC
|
||||
// DO THIS BEFORE WE TRY AND SEND DEBUG INFO!
|
||||
DebugPort.begin(115200);
|
||||
|
||||
|
||||
#if USE_WIFI == 1
|
||||
initWifi(WiFi_TriggerPin, FAILEDSSID, FAILEDPASSWORD);
|
||||
initOTA();
|
||||
initWebServer();
|
||||
#endif
|
||||
|
||||
pinMode(ListenOnlyPin, INPUT_PULLUP); // pin to enable passive mode
|
||||
pinMode(LED_Pin, OUTPUT); // On board LED indicator
|
||||
|
@ -225,9 +227,12 @@ void setup() {
|
|||
void loop()
|
||||
{
|
||||
unsigned long timenow = millis();
|
||||
|
||||
#if USE_WIFI == 1
|
||||
doWiFiManager();
|
||||
DoOTA();
|
||||
doWebServer();
|
||||
#endif
|
||||
|
||||
// check for test commands received from PC Over USB
|
||||
if(DebugPort.available()) {
|
||||
|
@ -430,6 +435,7 @@ void loop()
|
|||
|
||||
// do some monitoring of the heater state variable
|
||||
// if abnormal transitions, introduce a smart error!
|
||||
// This will also cancel ON/OFF requests if runstate in startup/shutdown
|
||||
SmartError.monitor(HeaterFrame1);
|
||||
|
||||
// echo heater reponse data to Bluetooth client
|
||||
|
|
|
@ -56,6 +56,7 @@ void
|
|||
CBluetoothESP32Classic::init()
|
||||
{
|
||||
_rxLine.clear();
|
||||
DebugPort.println("Initialising ESP32 Classic Bluetooth");
|
||||
|
||||
if(!SerialBT.begin("ESPHEATER")) {
|
||||
DebugPort.println("An error occurred initialising Bluetooth");
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "SmartError.h"
|
||||
#include "TxManage.h"
|
||||
|
||||
CSmartError::CSmartError()
|
||||
{
|
||||
|
@ -80,6 +81,19 @@ CSmartError::monitor(unsigned char newRunState)
|
|||
}
|
||||
}
|
||||
|
||||
if(m_prevRunState != newRunState) {
|
||||
// check for transition to startup
|
||||
// - force cancellation of an on request if we generated it
|
||||
if(newRunState == 2) {
|
||||
TxManage.queueOnRequest(false); // ensure ON request is cancelled
|
||||
}
|
||||
// check for transition to shutdown
|
||||
// - force cancellation of an off request if we generated it
|
||||
if(newRunState == 7) {
|
||||
TxManage.queueOffRequest(false); // ensure OFF request is cancelled
|
||||
}
|
||||
}
|
||||
|
||||
m_prevRunState = newRunState;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,15 +42,17 @@ void CTxManage::begin()
|
|||
}
|
||||
|
||||
void
|
||||
CTxManage::queueOnRequest()
|
||||
CTxManage::queueOnRequest(bool set)
|
||||
{
|
||||
m_bOnReq = true;
|
||||
m_bOnReq = set; // allow cancel via heater frame decode
|
||||
m_bOffReq = false;
|
||||
}
|
||||
|
||||
void
|
||||
CTxManage::queueOffRequest()
|
||||
CTxManage::queueOffRequest(bool set)
|
||||
{
|
||||
m_bOffReq = true;
|
||||
m_bOffReq = set; // allow cancel via heater frame decode
|
||||
m_bOnReq = false;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -77,11 +79,11 @@ CTxManage::PrepareFrame(const CProtocol& basisFrame, bool isBTCmaster)
|
|||
}
|
||||
else {
|
||||
if(m_bOnReq) {
|
||||
m_bOnReq = false;
|
||||
// m_bOnReq = false; // requires cancel via queueOnRequest(false)
|
||||
m_TxFrame.onCommand();
|
||||
}
|
||||
if(m_bOffReq) {
|
||||
m_bOffReq = false;
|
||||
// m_bOffReq = false; // requires cancel via queueOffRequest(false)
|
||||
m_TxFrame.offCommand();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@ class CTxManage
|
|||
|
||||
public:
|
||||
CTxManage(int TxGatePin, HardwareSerial& serial);
|
||||
void queueOnRequest();
|
||||
void queueOffRequest();
|
||||
void queueOnRequest(bool set = true); // use false to remove repeating command
|
||||
void queueOffRequest(bool set = true); // use false to remove repeating command
|
||||
void queueRawCommand(unsigned char val);
|
||||
void PrepareFrame(const CProtocol& Frame, bool isBTCmaster);
|
||||
void Start(unsigned long timenow);
|
||||
|
|
Loading…
Reference in a new issue