From 59e541de72b9859d1044ad226a84cee6d62296f7 Mon Sep 17 00:00:00 2001 From: Asbelos Date: Mon, 29 Jun 2020 13:45:16 +0100 Subject: [PATCH] Quit/Reconnect improvements --- WiThrottle.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/WiThrottle.cpp b/WiThrottle.cpp index b7edfac..8d3a607 100644 --- a/WiThrottle.cpp +++ b/WiThrottle.cpp @@ -53,6 +53,7 @@ WiThrottle::WiThrottle(Print & stream, int wificlientid) { StringFormatter::send(stream,F("]\\[LT&d}|{%d}|{%d"), tt->data.id, tt->data.id, (bool)(tt->data.tStatus & STATUS_ACTIVE)); } StringFormatter::send(stream,F("\n*10")); + heartBeatEnable=false; // until client turns it on } WiThrottle::~WiThrottle() { @@ -89,11 +90,17 @@ void WiThrottle::parse(Print & stream, byte * cmd) { } break; case 'N': // Heartbeat (2) - StringFormatter::send(stream, F("*10")); // 10 second timeout + StringFormatter::send(stream, F("*10\n")); // 10 second timeout break; case 'M': // multithrottle multithrottle(stream, cmd); break; + case 'H': // hardware introduction.... + break; + case 'Q': // hardware introduction.... + DIAG(F("\nWiThrottle Quit")); + delete this; + break; } } int WiThrottle::getInt(byte * cmd) { @@ -210,13 +217,15 @@ void WiThrottle::loop() { } void WiThrottle::checkHeartbeat() { - if(millis()-heartBeat > HEARTBEAT_TIMEOUT*1000) { + if(heartBeatEnable && (millis()-heartBeat > HEARTBEAT_TIMEOUT*1000)) { + DIAG(F("WiThrottle hearbeat missed client=%d"),clientid); // Haertbeat missed... STOP all locos for this client for (int loco=0;loco