Fix protocol parse and validity check back
This commit is contained in:
@@ -43,18 +43,18 @@ bool gatewayTransportInit() {
|
|||||||
|
|
||||||
|
|
||||||
bool gatewayTransportAvailable() {
|
bool gatewayTransportAvailable() {
|
||||||
bool available = false;
|
|
||||||
|
|
||||||
while (MY_SERIALDEVICE.available()) {
|
while (MY_SERIALDEVICE.available()) {
|
||||||
// get the new byte:
|
// get the new byte:
|
||||||
char inChar = (char) MY_SERIALDEVICE.read();
|
char inChar = (char) MY_SERIALDEVICE.read();
|
||||||
// if the incoming character is a newline, set a flag
|
// if the incoming character is a newline, set a flag
|
||||||
// so the main loop can do something about it:
|
// so the main loop can do something about it:
|
||||||
if (_serialInputPos < MY_GATEWAY_MAX_RECEIVE_LENGTH - 1 && !available) {
|
if (_serialInputPos < MY_GATEWAY_MAX_RECEIVE_LENGTH - 1) {
|
||||||
if (inChar == '\n') {
|
if (inChar == '\n') {
|
||||||
_serialInputString[_serialInputPos] = 0;
|
_serialInputString[_serialInputPos] = 0;
|
||||||
available = true;
|
bool ok = protocolParse(_serialMsg, _serialInputString);
|
||||||
return true;
|
if (ok)
|
||||||
|
_serialInputPos = 0;
|
||||||
|
return ok;
|
||||||
} else {
|
} else {
|
||||||
// add it to the inputString:
|
// add it to the inputString:
|
||||||
_serialInputString[_serialInputPos] = inChar;
|
_serialInputString[_serialInputPos] = inChar;
|
||||||
@@ -65,12 +65,7 @@ bool gatewayTransportAvailable() {
|
|||||||
_serialInputPos = 0;
|
_serialInputPos = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (available) {
|
return false;
|
||||||
// Parse message and return parse result
|
|
||||||
available = protocolParse(_serialMsg, _serialInputString);
|
|
||||||
_serialInputPos = 0;
|
|
||||||
}
|
|
||||||
return available;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MyMessage & gatewayTransportReceive() {
|
MyMessage & gatewayTransportReceive() {
|
||||||
|
|||||||
Reference in New Issue
Block a user