mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-26 17:46:14 +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);
|
||||
|
||||
// On first few commands, send turnout, roster and routes
|
||||
|
||||
if (!turnoutsSent) sendTurnouts(stream);
|
||||
else if(!rosterSent) sendRoster(stream);
|
||||
else if (!routesSent) sendRoutes(stream);
|
||||
else if (!heartrateSent) {
|
||||
heartrateSent=true;
|
||||
// allow heartbeat to slow down once all metadata sent
|
||||
StringFormatter::send(stream,F("*%d\n"),HEARTBEAT_SECONDS);
|
||||
if (introSent) {
|
||||
if (!turnoutsSent) sendTurnouts(stream);
|
||||
else if(!rosterSent) sendRoster(stream);
|
||||
else if (!routesSent) sendRoutes(stream);
|
||||
else if (!heartrateSent) {
|
||||
heartrateSent=true;
|
||||
// allow heartbeat to slow down once all metadata sent
|
||||
StringFormatter::send(stream,F("*%d\n"),HEARTBEAT_SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
while (cmd[0]) {
|
||||
switch (cmd[0]) {
|
||||
case '*': // heartbeat control
|
||||
|
@ -194,13 +194,7 @@ void WiThrottle::parse(RingStream * stream, byte * cmdx) {
|
|||
break;
|
||||
case 'H': // send initial connection info after receiving "HU" message
|
||||
if (cmd[1] == 'U') {
|
||||
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);
|
||||
|
||||
sendIntro(stream);
|
||||
}
|
||||
break;
|
||||
case 'Q': //
|
||||
|
@ -500,6 +494,16 @@ void WiThrottle::getLocoCallback(int16_t locoid) {
|
|||
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) {
|
||||
turnoutsSent=true;
|
||||
StringFormatter::send(stream,F("PTL"));
|
||||
|
|
|
@ -61,6 +61,7 @@ class WiThrottle {
|
|||
MYLOCO myLocos[MAX_MY_LOCO];
|
||||
bool heartBeatEnable;
|
||||
unsigned long heartBeat;
|
||||
bool introSent=false;
|
||||
bool turnoutsSent=false;
|
||||
bool rosterSent=false;
|
||||
bool routesSent=false;
|
||||
|
@ -75,6 +76,7 @@ class WiThrottle {
|
|||
void accessory(RingStream *, byte* cmd);
|
||||
void checkHeartbeat(RingStream * stream);
|
||||
void markForBroadcast2(int cab);
|
||||
void sendIntro(Print * stream);
|
||||
void sendTurnouts(Print * stream);
|
||||
void sendRoster(Print * stream);
|
||||
void sendRoutes(Print * stream);
|
||||
|
|
Loading…
Reference in New Issue
Block a user