mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2025-03-14 18:13:09 +01:00
Remember connection type determined at first connect
This commit is contained in:
parent
3681f0e445
commit
68f0c6681d
@ -54,15 +54,30 @@
|
|||||||
// Parse is called by Withrottle or Ethernet interface to determine which
|
// Parse is called by Withrottle or Ethernet interface to determine which
|
||||||
// protocol the client is using and call the appropriate part of dcc++Ex
|
// protocol the client is using and call the appropriate part of dcc++Ex
|
||||||
void CommandDistributor::parse(byte clientId,byte * buffer, RingStream * stream) {
|
void CommandDistributor::parse(byte clientId,byte * buffer, RingStream * stream) {
|
||||||
|
if (Diag::WIFI && Diag::CMD)
|
||||||
|
DIAG(F("Parse C=%d T=%d B=%s"),clientId, clients[clientId], buffer);
|
||||||
ring=stream;
|
ring=stream;
|
||||||
ringClient=stream->peekTargetMark();
|
ringClient=stream->peekTargetMark();
|
||||||
if (buffer[0] == '<') {
|
|
||||||
clients[clientId]=COMMAND_TYPE;
|
// First check if the client is not known
|
||||||
DCCEXParser::parse(stream, buffer, ring);
|
// yet and in that case determinine type
|
||||||
} else {
|
// NOTE: First character of transmission determines if this
|
||||||
clients[clientId]=WITHROTTLE_TYPE;
|
// client is using the DCC++ protocol where all commands start
|
||||||
WiThrottle::getThrottle(clientId)->parse(ring, buffer);
|
// with '<'
|
||||||
|
if (clients[clientId] == NONE_TYPE) {
|
||||||
|
if (buffer[0] == '<')
|
||||||
|
clients[clientId]=COMMAND_TYPE;
|
||||||
|
else
|
||||||
|
clients[clientId]=WITHROTTLE_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When type is known, send the string
|
||||||
|
// to the right parser
|
||||||
|
if (clients[clientId] == COMMAND_TYPE)
|
||||||
|
DCCEXParser::parse(stream, buffer, ring);
|
||||||
|
else if (clients[clientId] == WITHROTTLE_TYPE)
|
||||||
|
WiThrottle::getThrottle(clientId)->parse(ring, buffer);
|
||||||
|
|
||||||
ringClient=NO_CLIENT;
|
ringClient=NO_CLIENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user