BIG FIXES: External thermostat start denied if internal thermostat too high
Pump priming from web page only worked once - was because prime command was never released from heater.
This commit is contained in:
parent
3129a88cb9
commit
97f3433158
|
@ -202,7 +202,7 @@ CSecuritySetup SecurityMenu;
|
|||
|
||||
TaskHandle_t handleWatchdogTask;
|
||||
TaskHandle_t handleBlueWireTask;
|
||||
extern TaskHandle_t handleSSLTask;
|
||||
extern TaskHandle_t handleWebServerTask;
|
||||
|
||||
// these variables will persist over a soft reboot.
|
||||
__NOINIT_ATTR float persistentRunTime;
|
||||
|
@ -647,7 +647,7 @@ bool checkTemperatureSensors()
|
|||
DebugPort.printf(" Arduino: %d\r\n", uxTaskGetStackHighWaterMark(NULL));
|
||||
DebugPort.printf(" BlueWire: %d\r\n", uxTaskGetStackHighWaterMark(handleBlueWireTask));
|
||||
DebugPort.printf(" Watchdog: %d\r\n", uxTaskGetStackHighWaterMark(handleWatchdogTask));
|
||||
DebugPort.printf(" SSL loop: %d\r\n", uxTaskGetStackHighWaterMark(handleSSLTask));
|
||||
DebugPort.printf(" SSL loop: %d\r\n", uxTaskGetStackHighWaterMark(handleWebServerTask));
|
||||
}
|
||||
|
||||
TempSensor.readSensors();
|
||||
|
|
|
@ -53,6 +53,7 @@ CProtocol HeaterFrame2; // data packet received from heater in resp
|
|||
// CSmartError SmartError;
|
||||
CProtocolPackage reportHeaterData;
|
||||
CProtocolPackage primaryHeaterData;
|
||||
char dbgMsg[BLUEWIRE_MSGQUEUESIZE];
|
||||
|
||||
static bool bHasOEMController = false;
|
||||
static bool bHasOEMLCDController = false;
|
||||
|
@ -142,9 +143,8 @@ void BlueWireTask(void*) {
|
|||
if(RxTimeElapsed >= moderator) {
|
||||
moderator += 10;
|
||||
if(bReportRecyleEvents) {
|
||||
char msg[32];
|
||||
sprintf(msg, "%ldms - ", RxTimeElapsed);
|
||||
pushDebugMsg(msg);
|
||||
sprintf(dbgMsg, "%ldms - ", RxTimeElapsed);
|
||||
pushDebugMsg(dbgMsg);
|
||||
}
|
||||
if(CommState.is(CommStates::OEMCtrlRx)) {
|
||||
bHasOEMController = false;
|
||||
|
@ -208,9 +208,8 @@ void BlueWireTask(void*) {
|
|||
if(BlueWireRxData.available() && (RxTimeElapsed > (RX_DATA_TIMOUT+10))) {
|
||||
|
||||
if(bReportOEMresync) {
|
||||
char msg[64];
|
||||
sprintf(msg, "Re-sync'd with OEM Controller. %ldms Idle time.\r\n", RxTimeElapsed);
|
||||
pushDebugMsg(msg);
|
||||
sprintf(dbgMsg, "Re-sync'd with OEM Controller. %ldms Idle time.\r\n", RxTimeElapsed);
|
||||
pushDebugMsg(dbgMsg);
|
||||
}
|
||||
|
||||
bHasHtrData = false;
|
||||
|
@ -395,12 +394,11 @@ bool validateFrame(const CProtocol& frame, const char* name)
|
|||
{
|
||||
if(!frame.verifyCRC(pushDebugMsg)) {
|
||||
// Bad CRC - restart blue wire Serial port
|
||||
char msg[128];
|
||||
sprintf(msg, "\007Bad CRC detected for %s frame - restarting blue wire's serial port\r\n", name);
|
||||
pushDebugMsg(msg);
|
||||
msg[0] = 0; // empty string
|
||||
DebugReportFrame("BAD CRC:", frame, "\r\n", msg);
|
||||
pushDebugMsg(msg);
|
||||
sprintf(dbgMsg, "\007Bad CRC detected for %s frame - restarting blue wire's serial port\r\n", name);
|
||||
pushDebugMsg(dbgMsg);
|
||||
dbgMsg[0] = 0; // empty string
|
||||
DebugReportFrame("BAD CRC:", frame, "\r\n", dbgMsg);
|
||||
pushDebugMsg(dbgMsg);
|
||||
#ifdef REBOOT_BLUEWIRE
|
||||
initBlueWireSerial();
|
||||
#endif
|
||||
|
@ -415,7 +413,7 @@ void DebugReportFrame(const char* hdr, const CProtocol& Frame, const char* ftr,
|
|||
{
|
||||
strcat(msg, hdr); // header
|
||||
for(int i=0; i<24; i++) {
|
||||
char str[16];
|
||||
char str[8];
|
||||
sprintf(str, " %02X", Frame.Data[i]); // build 2 dig hex values
|
||||
strcat(msg, str); // and print
|
||||
}
|
||||
|
@ -478,7 +476,7 @@ const char* getBlueWireStatStr()
|
|||
|
||||
void reqPumpPrime(bool on)
|
||||
{
|
||||
DefaultBTCParams.setPump_Prime(on);
|
||||
TxManage.reqPrime(on);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -431,20 +431,21 @@ CProtocolPackage::setRefTime()
|
|||
_timeStamp.setRefTime();
|
||||
}*/
|
||||
|
||||
char dbgFrameMsg[192];
|
||||
|
||||
void
|
||||
CProtocolPackage::reportFrames(bool isOEM, std::function<void(const char*)> pushMsg)
|
||||
{
|
||||
char msg[192];
|
||||
msg[0] = 0;
|
||||
_timeStamp.report(msg); // absolute time
|
||||
dbgFrameMsg[0] = 0;
|
||||
_timeStamp.report(dbgFrameMsg); // absolute time
|
||||
if(isOEM) {
|
||||
DebugReportFrame("OEM:", Controller, TERMINATE_OEM_LINE ? "\r\n" : " ", msg);
|
||||
DebugReportFrame("OEM:", Controller, TERMINATE_OEM_LINE ? "\r\n" : " ", dbgFrameMsg);
|
||||
}
|
||||
else {
|
||||
DebugReportFrame("BTC:", Controller, TERMINATE_BTC_LINE ? "\r\n" : " ", msg);
|
||||
DebugReportFrame("BTC:", Controller, TERMINATE_BTC_LINE ? "\r\n" : " ", dbgFrameMsg);
|
||||
}
|
||||
DebugReportFrame("HTR:", Heater, "\r\n", msg);
|
||||
pushMsg(msg);
|
||||
DebugReportFrame("HTR:", Heater, "\r\n", dbgFrameMsg);
|
||||
pushMsg(dbgFrameMsg);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -36,6 +36,7 @@ void
|
|||
CSmartError::reset()
|
||||
{
|
||||
_prevRunState = 0;
|
||||
_prevPumpHz = 0;
|
||||
_Error = 0;
|
||||
_bInhibit = false;
|
||||
}
|
||||
|
@ -61,14 +62,15 @@ CSmartError::monitor(const CProtocol& heaterFrame)
|
|||
{
|
||||
if(heaterFrame.verifyCRC(NULL)) { // check but don't report dodgy frames to debug
|
||||
// only accept valid heater frames!
|
||||
monitor(heaterFrame.getRunState());
|
||||
_monitor(heaterFrame.getRunState());
|
||||
_monitorPriming(heaterFrame.getRunState(), heaterFrame.getPump_Actual());
|
||||
}
|
||||
}
|
||||
|
||||
// test the new run state value, comparing to previous
|
||||
// detect abnormal transitions
|
||||
void
|
||||
CSmartError::monitor(uint8_t newRunState)
|
||||
CSmartError::_monitor(uint8_t newRunState)
|
||||
{
|
||||
// check if moving away from heater Idle state (S0)
|
||||
// especially useful if an OEM controller exists
|
||||
|
@ -209,3 +211,15 @@ CSmartError::checkfuelUsage(bool throwfault)
|
|||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
void
|
||||
CSmartError::_monitorPriming(uint8_t runState, uint8_t pumpHz)
|
||||
{
|
||||
if(runState == 0 && pumpHz == 0 && _prevPumpHz != 0) {
|
||||
TxManage.reqPrime(false); // cancel pump priming request upon heater auto stopping priming
|
||||
}
|
||||
if(runState != 0) {
|
||||
TxManage.reqPrime(false); // ALWAYS cancel pump priming request upon heater running
|
||||
}
|
||||
_prevPumpHz = pumpHz;
|
||||
}
|
||||
|
|
|
@ -23,14 +23,16 @@
|
|||
|
||||
class CSmartError {
|
||||
uint8_t _prevRunState;
|
||||
uint8_t _prevPumpHz;
|
||||
uint8_t _Error;
|
||||
bool _bInhibit;
|
||||
void _monitorPriming(uint8_t runState, uint8_t pumpHz);
|
||||
void _monitor(uint8_t runstate);
|
||||
public:
|
||||
CSmartError();
|
||||
void reset();
|
||||
void inhibit(bool reseterror=false);
|
||||
void monitor(const CProtocol& heaterFrame);
|
||||
void monitor(uint8_t runstate);
|
||||
int checkVolts(float volts, float plugI, bool throwfault=true); // 0 = OK, 1 = within 0.5V of LVC, 2 = under LVC
|
||||
int checkfuelUsage(bool throwfault=true);
|
||||
uint8_t getError();
|
||||
|
|
|
@ -70,6 +70,7 @@ CTxManage::CTxManage(int TxGatePin, HardwareSerial& serial) :
|
|||
_rawCommand = 0;
|
||||
m_HWTimer = NULL;
|
||||
_callback = NULL;
|
||||
_prime = false;
|
||||
}
|
||||
|
||||
// static function used for the tx gate termination
|
||||
|
@ -178,6 +179,8 @@ CTxManage::PrepareFrame(const CProtocol& basisFrame, bool isBTCmaster)
|
|||
m_TxFrame.setAltitude(3500); // default height - yes it is weird, but that's what the simple controllers send!
|
||||
}
|
||||
|
||||
m_TxFrame.setPump_Prime(_prime);
|
||||
|
||||
float tActual = getTemperatureSensor();
|
||||
int8_t s8Temp = (int8_t)(tActual + 0.5);
|
||||
m_TxFrame.setTemperature_Actual(s8Temp); // use current temp, for now
|
||||
|
@ -338,3 +341,8 @@ CTxManage::CheckTx(unsigned long timenow)
|
|||
return m_nStartTime == 0; // returns true when done
|
||||
}
|
||||
|
||||
void
|
||||
CTxManage::reqPrime(bool on)
|
||||
{
|
||||
_prime = on;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ class CTxManage
|
|||
const int m_nFrontPorch = 0;
|
||||
int m_sysUpdate;
|
||||
std::function<void(const char*)> _callback;
|
||||
bool _prime;
|
||||
|
||||
public:
|
||||
CTxManage(int TxGatePin, HardwareSerial& serial);
|
||||
|
@ -42,6 +43,7 @@ public:
|
|||
static void IRAM_ATTR callbackGateTerminate();
|
||||
void queueSysUpdate(); // use to implant NV settings into heater
|
||||
void setCallback(std::function<void(const char*)> fn) { _callback = fn; };
|
||||
void reqPrime(bool on);
|
||||
|
||||
private:
|
||||
HardwareSerial& m_BlueWireSerial;
|
||||
|
|
|
@ -123,28 +123,30 @@ CDemandManager::checkStart()
|
|||
// create a deny start temperature margin
|
||||
int stopDeltaT = 0;
|
||||
|
||||
int cyclicstop = NVstore.getUserSettings().cyclic.Stop;
|
||||
if(cyclicstop) { // cyclic mode enabled
|
||||
// if cylic mode, raise the margin by the cyclic stop range
|
||||
stopDeltaT = cyclicstop + 1; // bump up by 1 degree - no point invoking cyclic at 1 deg over!
|
||||
}
|
||||
|
||||
// determine temperature error vs desired thermostat value
|
||||
float deltaT = getTemperatureSensor() - getDegC();
|
||||
|
||||
if(deltaT > stopDeltaT) {
|
||||
// temperature exceeded the allowed margin
|
||||
if(cyclicstop) {
|
||||
// using cyclic mode - suggest immediate cyclic suspend
|
||||
int cyclicstop = NVstore.getUserSettings().cyclic.Stop;
|
||||
if(cyclicstop) { // cyclic mode enabled
|
||||
// if cyclic mode, raise the margin by the cyclic stop range
|
||||
stopDeltaT = cyclicstop + 1; // bump up by 1 degree - no point invoking cyclic at 1 deg over!
|
||||
|
||||
// alows honour cyclic stop threshold - immediate suspend transition
|
||||
if(deltaT > stopDeltaT) {
|
||||
return eStartSuspend;
|
||||
}
|
||||
else {
|
||||
// only deny start if actually using thermostat mode
|
||||
}
|
||||
|
||||
if(!isExtThermostatMode()) {
|
||||
if(deltaT > stopDeltaT) {
|
||||
// temperature exceeded the allowed margin
|
||||
// only deny start if actually using inbuilt thermostat mode
|
||||
if(isThermostat()) {
|
||||
return eStartTooWarm; // too warm - deny start
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return eStartOK; // allow start
|
||||
}
|
||||
|
||||
|
|
|
@ -77,9 +77,9 @@ void streamFileCoreSSL(const size_t fileSize, const String & fileName, const Str
|
|||
void processWebsocketQueue();
|
||||
|
||||
QueueHandle_t webSocketQueue = NULL;
|
||||
TaskHandle_t handleWebServerTask;
|
||||
#if USE_HTTPS == 1
|
||||
SSLCert* pCert;
|
||||
TaskHandle_t handleSSLTask;
|
||||
HTTPSServer * secureServer;
|
||||
#endif
|
||||
HTTPServer * insecureServer;
|
||||
|
@ -403,7 +403,7 @@ void initWebServer(void) {
|
|||
16384,
|
||||
NULL,
|
||||
TASK_PRIORITY_SSL_CERT, // low priority as this blocks BIG time
|
||||
&handleSSLTask);
|
||||
&handleWebServerTask);
|
||||
|
||||
while(!xSemaphoreTake(SSLSemaphore, 250)) {
|
||||
ScreenManager.showBootWait(1);
|
||||
|
@ -476,12 +476,12 @@ void initWebServer(void) {
|
|||
// setup task to handle webserver
|
||||
webSocketQueue = xQueueCreate(50, sizeof(char*) );
|
||||
xTaskCreate(SSLloopTask,
|
||||
"SSLloopTask",
|
||||
"Web server task",
|
||||
8192,
|
||||
// 16384,
|
||||
NULL,
|
||||
TASK_PRIORITY_SSL_LOOP, // low priority as this potentially blocks BIG time
|
||||
&handleSSLTask);
|
||||
&handleWebServerTask);
|
||||
|
||||
DebugPort.println("HTTP task started");
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue