1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-24 21:21:24 +01:00

Quit/Reconnect improvements

This commit is contained in:
Asbelos 2020-06-29 13:45:16 +01:00
parent 20e8715fc6
commit 59e541de72

View File

@ -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("]\\[LT&d}|{%d}|{%d"), tt->data.id, tt->data.id, (bool)(tt->data.tStatus & STATUS_ACTIVE));
} }
StringFormatter::send(stream,F("\n*10")); StringFormatter::send(stream,F("\n*10"));
heartBeatEnable=false; // until client turns it on
} }
WiThrottle::~WiThrottle() { WiThrottle::~WiThrottle() {
@ -89,11 +90,17 @@ void WiThrottle::parse(Print & stream, byte * cmd) {
} }
break; break;
case 'N': // Heartbeat (2) case 'N': // Heartbeat (2)
StringFormatter::send(stream, F("*10")); // 10 second timeout StringFormatter::send(stream, F("*10\n")); // 10 second timeout
break; break;
case 'M': // multithrottle case 'M': // multithrottle
multithrottle(stream, cmd); multithrottle(stream, cmd);
break; break;
case 'H': // hardware introduction....
break;
case 'Q': // hardware introduction....
DIAG(F("\nWiThrottle Quit"));
delete this;
break;
} }
} }
int WiThrottle::getInt(byte * cmd) { int WiThrottle::getInt(byte * cmd) {
@ -210,13 +217,15 @@ void WiThrottle::loop() {
} }
void WiThrottle::checkHeartbeat() { 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 // Haertbeat missed... STOP all locos for this client
for (int loco=0;loco<MAX_MY_LOCO;loco++) { for (int loco=0;loco<MAX_MY_LOCO;loco++) {
if (myLocos[loco].throttle!='\0') { if (myLocos[loco].throttle!='\0') {
DCC::setThrottle(myLocos[loco].cab, 1, DCC::getThrottleDirection(myLocos[loco].cab)); DCC::setThrottle(myLocos[loco].cab, 1, DCC::getThrottleDirection(myLocos[loco].cab));
} }
} }
delete this;
} }
else { else {
// TODO Check if anything has changed on my locos since last notified! // TODO Check if anything has changed on my locos since last notified!