From 52b0502776b0baeb546c653544b23ae2f0c3b288 Mon Sep 17 00:00:00 2001 From: SteveT Date: Wed, 12 Aug 2020 15:10:51 -0400 Subject: [PATCH] set initial direction forward, forget locos on 2nd missed heartbeat --- WiThrottle.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/WiThrottle.cpp b/WiThrottle.cpp index 61c5492..48a95fa 100644 --- a/WiThrottle.cpp +++ b/WiThrottle.cpp @@ -149,7 +149,7 @@ void WiThrottle::parse(Print & stream, byte * cmdx) { } break; case 'N': // Heartbeat (2) - StringFormatter::send(stream, F("*%d\n"),HEARTBEAT_TIMEOUT); // 10 second timeout + StringFormatter::send(stream, F("*%d\n"),HEARTBEAT_TIMEOUT); // return timeout value break; case 'M': // multithrottle multithrottle(stream, cmd); @@ -217,7 +217,7 @@ void WiThrottle::multithrottle(Print & stream, byte * cmd){ if (myLocos[loco].throttle=='\0') { myLocos[loco].throttle=throttleChar; myLocos[loco].cab=locoid; - DCC::setThrottle(locoid,0,0); //register this loco address + DCC::setThrottle(locoid,0,1); //register this loco address, speed zero, direction forward StringFormatter::send(stream, F("M%c+%c%d<;>\n"), throttleChar, cmd[3] ,locoid); // TODO... get known Fn states from DCC (need memoryStream improvements to handle data length) // for(fKey=0; fKey<29; fKey++)StringFormatter::send(stream,F("M%cA%c<;>F0&s\n"),throttleChar,cmd[3],fkey); @@ -231,7 +231,7 @@ void WiThrottle::multithrottle(Print & stream, byte * cmd){ case '-': // remove loco LOOPLOCOS(throttleChar, locoid) { myLocos[loco].throttle='\0'; - DCC::setThrottle(myLocos[loco].cab,0,0); + DCC::setThrottle(myLocos[loco].cab,0,1); DCC::forgetLoco(myLocos[loco].cab); //unregister this loco address StringFormatter::send(stream, F("M%c-%c%d<;>\n"), throttleChar, LorS(myLocos[loco].cab), myLocos[loco].cab); } @@ -309,17 +309,17 @@ void WiThrottle::loop() { } void WiThrottle::checkHeartbeat() { - if(heartBeatEnable && (millis()-heartBeat > HEARTBEAT_TIMEOUT*1000)) { + // if 2 heartbeats missed... STOP and forget all locos for this client + if(heartBeatEnable && (millis()-heartBeat > HEARTBEAT_TIMEOUT*2000)) { DIAG(F("WiThrottle hearbeat missed client=%d"),clientid); - // Haertbeat missed... STOP all locos for this client for (int loco=0;loco