Skip to content

Commit c7efee3

Browse files
committed
Fix protocol parse and validity check back
1 parent 47f8df8 commit c7efee3

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

libraries/MySensors/core/MyGatewayTransportSerial.cpp

+6-11
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,18 @@ bool gatewayTransportInit() {
4343

4444

4545
bool gatewayTransportAvailable() {
46-
bool available = false;
47-
4846
while (MY_SERIALDEVICE.available()) {
4947
// get the new byte:
5048
char inChar = (char) MY_SERIALDEVICE.read();
5149
// if the incoming character is a newline, set a flag
5250
// so the main loop can do something about it:
53-
if (_serialInputPos < MY_GATEWAY_MAX_RECEIVE_LENGTH - 1 && !available) {
51+
if (_serialInputPos < MY_GATEWAY_MAX_RECEIVE_LENGTH - 1) {
5452
if (inChar == '\n') {
5553
_serialInputString[_serialInputPos] = 0;
56-
available = true;
57-
return true;
54+
bool ok = protocolParse(_serialMsg, _serialInputString);
55+
if (ok)
56+
_serialInputPos = 0;
57+
return ok;
5858
} else {
5959
// add it to the inputString:
6060
_serialInputString[_serialInputPos] = inChar;
@@ -65,12 +65,7 @@ bool gatewayTransportAvailable() {
6565
_serialInputPos = 0;
6666
}
6767
}
68-
if (available) {
69-
// Parse message and return parse result
70-
available = protocolParse(_serialMsg, _serialInputString);
71-
_serialInputPos = 0;
72-
}
73-
return available;
68+
return false;
7469
}
7570

7671
MyMessage & gatewayTransportReceive() {

0 commit comments

Comments
 (0)