mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2025-02-18 15:06:03 +01:00
Roster send order
This commit is contained in:
parent
9cdabb0acf
commit
e8817d6b4b
@ -124,17 +124,17 @@ void WiThrottle::parse(RingStream * stream, byte * cmdx) {
|
|||||||
if (Diag::WITHROTTLE) DIAG(F("%l WiThrottle(%d)<-[%e]"),millis(),clientid,cmd);
|
if (Diag::WITHROTTLE) DIAG(F("%l WiThrottle(%d)<-[%e]"),millis(),clientid,cmd);
|
||||||
|
|
||||||
// On first few commands, send turnout, roster and routes
|
// On first few commands, send turnout, roster and routes
|
||||||
|
if (introSent) {
|
||||||
if (!turnoutsSent) sendTurnouts(stream);
|
if (!turnoutsSent) sendTurnouts(stream);
|
||||||
else if(!rosterSent) sendRoster(stream);
|
else if(!rosterSent) sendRoster(stream);
|
||||||
else if (!routesSent) sendRoutes(stream);
|
else if (!routesSent) sendRoutes(stream);
|
||||||
else if (!heartrateSent) {
|
else if (!heartrateSent) {
|
||||||
heartrateSent=true;
|
heartrateSent=true;
|
||||||
// allow heartbeat to slow down once all metadata sent
|
// allow heartbeat to slow down once all metadata sent
|
||||||
StringFormatter::send(stream,F("*%d\n"),HEARTBEAT_SECONDS);
|
StringFormatter::send(stream,F("*%d\n"),HEARTBEAT_SECONDS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
while (cmd[0]) {
|
while (cmd[0]) {
|
||||||
switch (cmd[0]) {
|
switch (cmd[0]) {
|
||||||
case '*': // heartbeat control
|
case '*': // heartbeat control
|
||||||
@ -194,13 +194,7 @@ void WiThrottle::parse(RingStream * stream, byte * cmdx) {
|
|||||||
break;
|
break;
|
||||||
case 'H': // send initial connection info after receiving "HU" message
|
case 'H': // send initial connection info after receiving "HU" message
|
||||||
if (cmd[1] == 'U') {
|
if (cmd[1] == 'U') {
|
||||||
StringFormatter::send(stream,F("VN2.0\nHTDCC-EX\nRL0\n"));
|
sendIntro(stream);
|
||||||
StringFormatter::send(stream,F("HtDCC-EX v%S, %S, %S, %S\n"), F(VERSION), F(ARDUINO_TYPE), DCC::getMotorShieldName(), F(GITHUB_SHA));
|
|
||||||
StringFormatter::send(stream,F("PTT]\\[Turnouts}|{Turnout]\\[THROW}|{2]\\[CLOSE}|{4\n"));
|
|
||||||
StringFormatter::send(stream,F("PPA%x\n"),TrackManager::getMainPower()==POWERMODE::ON);
|
|
||||||
// set heartbeat to 5 seconds because we need to sync the metadata (1 second is too short!)
|
|
||||||
StringFormatter::send(stream,F("*%d\n"), HEARTBEAT_SECONDS/2);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'Q': //
|
case 'Q': //
|
||||||
@ -500,6 +494,16 @@ void WiThrottle::getLocoCallback(int16_t locoid) {
|
|||||||
CommandDistributor::broadcastPower();
|
CommandDistributor::broadcastPower();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WiThrottle::sendIntro(Print* stream) {
|
||||||
|
introSent=true;
|
||||||
|
StringFormatter::send(stream,F("VN2.0\nHTDCC-EX\nRL0\n"));
|
||||||
|
StringFormatter::send(stream,F("HtDCC-EX v%S, %S, %S, %S\n"), F(VERSION), F(ARDUINO_TYPE), DCC::getMotorShieldName(), F(GITHUB_SHA));
|
||||||
|
StringFormatter::send(stream,F("PTT]\\[Turnouts}|{Turnout]\\[THROW}|{2]\\[CLOSE}|{4\n"));
|
||||||
|
StringFormatter::send(stream,F("PPA%x\n"),TrackManager::getMainPower()==POWERMODE::ON);
|
||||||
|
// set heartbeat to 5 seconds because we need to sync the metadata (1 second is too short!)
|
||||||
|
StringFormatter::send(stream,F("*%d\n"), HEARTBEAT_SECONDS/2);
|
||||||
|
}
|
||||||
|
|
||||||
void WiThrottle::sendTurnouts(Print* stream) {
|
void WiThrottle::sendTurnouts(Print* stream) {
|
||||||
turnoutsSent=true;
|
turnoutsSent=true;
|
||||||
StringFormatter::send(stream,F("PTL"));
|
StringFormatter::send(stream,F("PTL"));
|
||||||
|
@ -61,6 +61,7 @@ class WiThrottle {
|
|||||||
MYLOCO myLocos[MAX_MY_LOCO];
|
MYLOCO myLocos[MAX_MY_LOCO];
|
||||||
bool heartBeatEnable;
|
bool heartBeatEnable;
|
||||||
unsigned long heartBeat;
|
unsigned long heartBeat;
|
||||||
|
bool introSent=false;
|
||||||
bool turnoutsSent=false;
|
bool turnoutsSent=false;
|
||||||
bool rosterSent=false;
|
bool rosterSent=false;
|
||||||
bool routesSent=false;
|
bool routesSent=false;
|
||||||
@ -75,6 +76,7 @@ class WiThrottle {
|
|||||||
void accessory(RingStream *, byte* cmd);
|
void accessory(RingStream *, byte* cmd);
|
||||||
void checkHeartbeat(RingStream * stream);
|
void checkHeartbeat(RingStream * stream);
|
||||||
void markForBroadcast2(int cab);
|
void markForBroadcast2(int cab);
|
||||||
|
void sendIntro(Print * stream);
|
||||||
void sendTurnouts(Print * stream);
|
void sendTurnouts(Print * stream);
|
||||||
void sendRoster(Print * stream);
|
void sendRoster(Print * stream);
|
||||||
void sendRoutes(Print * stream);
|
void sendRoutes(Print * stream);
|
||||||
|
Loading…
Reference in New Issue
Block a user