mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-25 05:31:24 +01:00
return new speed and dir to client, add timestamp to DIAG
This commit is contained in:
parent
52b0502776
commit
5256c1d021
@ -144,12 +144,12 @@ void WiThrottle::parse(Print & stream, byte * cmdx) {
|
|||||||
case 'C': newstate=false; break;
|
case 'C': newstate=false; break;
|
||||||
case '2': newstate=!Turnout::isActive(id);
|
case '2': newstate=!Turnout::isActive(id);
|
||||||
}
|
}
|
||||||
Turnout::activate(id,newstate);
|
Turnout::activate(id,newstate);
|
||||||
StringFormatter::send(stream, F("PTA%c%d\n"),newstate?'4':'2',id );
|
StringFormatter::send(stream, F("PTA%c%d\n"),newstate?'4':'2',id );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'N': // Heartbeat (2)
|
case 'N': // Heartbeat (2)
|
||||||
StringFormatter::send(stream, F("*%d\n"),HEARTBEAT_TIMEOUT); // return timeout value
|
StringFormatter::send(stream, F("*%d\n"),HEARTBEAT_TIMEOUT); // return timeout value
|
||||||
break;
|
break;
|
||||||
case 'M': // multithrottle
|
case 'M': // multithrottle
|
||||||
multithrottle(stream, cmd);
|
multithrottle(stream, cmd);
|
||||||
@ -251,6 +251,7 @@ void WiThrottle::locoAction(Print & stream, byte* aval, char throttleChar, int c
|
|||||||
byte locospeed=getInt(aval+1);
|
byte locospeed=getInt(aval+1);
|
||||||
LOOPLOCOS(throttleChar, cab) {
|
LOOPLOCOS(throttleChar, cab) {
|
||||||
DCC::setThrottle(myLocos[loco].cab,locospeed, DCC::getThrottleDirection(myLocos[loco].cab));
|
DCC::setThrottle(myLocos[loco].cab,locospeed, DCC::getThrottleDirection(myLocos[loco].cab));
|
||||||
|
StringFormatter::send(stream,F("M%cA%c%d<;>V%d\n"), throttleChar, LorS(myLocos[loco].cab), myLocos[loco].cab, DCC::getThrottleSpeed(myLocos[loco].cab));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -282,9 +283,10 @@ void WiThrottle::locoAction(Print & stream, byte* aval, char throttleChar, int c
|
|||||||
case 'R':
|
case 'R':
|
||||||
{
|
{
|
||||||
bool forward=aval[1]!='0';
|
bool forward=aval[1]!='0';
|
||||||
LOOPLOCOS(throttleChar, cab) {
|
LOOPLOCOS(throttleChar, cab) {
|
||||||
DCC::setThrottle(myLocos[loco].cab, DCC::getThrottleSpeed(myLocos[loco].cab), forward);
|
DCC::setThrottle(myLocos[loco].cab, DCC::getThrottleSpeed(myLocos[loco].cab), forward);
|
||||||
}
|
StringFormatter::send(stream,F("M%cA%c%d<;>R%d\n"), throttleChar, LorS(myLocos[loco].cab), myLocos[loco].cab, DCC::getThrottleDirection(myLocos[loco].cab));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'X':
|
case 'X':
|
||||||
|
@ -36,7 +36,7 @@ class WiThrottle {
|
|||||||
~WiThrottle();
|
~WiThrottle();
|
||||||
|
|
||||||
static const int MAX_MY_LOCO=10; //maximum number of locos assigned to a single client
|
static const int MAX_MY_LOCO=10; //maximum number of locos assigned to a single client
|
||||||
static const int HEARTBEAT_TIMEOUT=4;// heartbeat at 4secs to provide messaging transport
|
static const int HEARTBEAT_TIMEOUT=3;// heartbeat at 3secs to provide messaging transport
|
||||||
static WiThrottle* firstThrottle;
|
static WiThrottle* firstThrottle;
|
||||||
static int getInt(byte * cmd);
|
static int getInt(byte * cmd);
|
||||||
static int getLocoId(byte * cmd);
|
static int getLocoId(byte * cmd);
|
||||||
|
@ -232,7 +232,7 @@ void WifiInterface::loop() {
|
|||||||
// AT this point we have read an incoming message into the buffer
|
// AT this point we have read an incoming message into the buffer
|
||||||
streamer.print('\0'); // null the end of the buffer so we can treat it as a string
|
streamer.print('\0'); // null the end of the buffer so we can treat it as a string
|
||||||
|
|
||||||
DIAG(F("\nWifi(%d)<-[%e]\n"),connectionId,buffer);
|
DIAG(F("\n%d Wifi(%d)<-[%e]\n"),millis(),connectionId,buffer);
|
||||||
streamer.setBufferContentPosition(0,0); // reset write position to start of buffer
|
streamer.setBufferContentPosition(0,0); // reset write position to start of buffer
|
||||||
// SIDE EFFECT WARNING:::
|
// SIDE EFFECT WARNING:::
|
||||||
// We know that parser will read the entire buffer before starting to write to it.
|
// We know that parser will read the entire buffer before starting to write to it.
|
||||||
@ -256,7 +256,7 @@ void WifiInterface::loop() {
|
|||||||
}
|
}
|
||||||
// prepare to send reply
|
// prepare to send reply
|
||||||
streamer.print('\0'); // null the end of the buffer so we can treat it as a string
|
streamer.print('\0'); // null the end of the buffer so we can treat it as a string
|
||||||
DIAG(F("WiFi(%d)->[%e] l(%d)\n"),connectionId,buffer,streamer.available()-1);
|
DIAG(F("%d WiFi(%d)->[%e] l(%d)\n"),millis(),connectionId,buffer,streamer.available()-1);
|
||||||
StringFormatter::send(wifiStream,F("AT+CIPSEND=%d,%d\r\n"),connectionId,streamer.available()-1);
|
StringFormatter::send(wifiStream,F("AT+CIPSEND=%d,%d\r\n"),connectionId,streamer.available()-1);
|
||||||
loopTimeoutStart=millis();
|
loopTimeoutStart=millis();
|
||||||
loopstate=10; // non-blocking loop waits for > before sending
|
loopstate=10; // non-blocking loop waits for > before sending
|
||||||
|
Loading…
Reference in New Issue
Block a user