mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-02 12:25:03 +01:00
Reject unknown turnouts
This commit is contained in:
parent
32b507248d
commit
3aff6230a2
|
@ -110,7 +110,7 @@ void WiThrottle::parse(Print & stream, byte * cmdx) {
|
||||||
if (Turnout::firstTurnout) {
|
if (Turnout::firstTurnout) {
|
||||||
StringFormatter::send(stream,F("PTL"));
|
StringFormatter::send(stream,F("PTL"));
|
||||||
for(Turnout *tt=Turnout::firstTurnout;tt!=NULL;tt=tt->nextTurnout){
|
for(Turnout *tt=Turnout::firstTurnout;tt!=NULL;tt=tt->nextTurnout){
|
||||||
StringFormatter::send(stream,F("]\\[DT%d}|{T%d}|{%d"), tt->data.id, tt->data.id, (bool)(tt->data.tStatus & STATUS_ACTIVE));
|
StringFormatter::send(stream,F("]\\[%d}|{T%d}|{%d"), tt->data.id, tt->data.id, (bool)(tt->data.tStatus & STATUS_ACTIVE));
|
||||||
}
|
}
|
||||||
StringFormatter::send(stream,F("\n"));
|
StringFormatter::send(stream,F("\n"));
|
||||||
}
|
}
|
||||||
|
@ -131,17 +131,20 @@ void WiThrottle::parse(Print & stream, byte * cmdx) {
|
||||||
StringFormatter::send(stream, F("PPA%c\n"),cmd[3]);
|
StringFormatter::send(stream, F("PPA%c\n"),cmd[3]);
|
||||||
}
|
}
|
||||||
else if (cmd[1]=='T' && cmd[2]=='A') { // PTA accessory toggle
|
else if (cmd[1]=='T' && cmd[2]=='A') { // PTA accessory toggle
|
||||||
// TODO... if we are given an address that is not a known Turnout...
|
int id=getInt(cmd+4);
|
||||||
// should we create one or just send the DCC message.
|
|
||||||
int id=getInt(cmd+6);
|
|
||||||
bool newstate=false;
|
bool newstate=false;
|
||||||
|
Turnout * tt=Turnout::get(id);
|
||||||
|
if (!tt) {
|
||||||
|
StringFormatter::send(stream, F("HMTurnout %d Unknown\n"),id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
switch (cmd[3]) {
|
switch (cmd[3]) {
|
||||||
case 'T': newstate=true; break;
|
case 'T': newstate=true; break;
|
||||||
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);
|
tt->activate(newstate);
|
||||||
StringFormatter::send(stream, F("PTA%cDT%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)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user