Skip to content

Commit

Permalink
Make sure we consume the double 5c (#59)
Browse files Browse the repository at this point in the history
We must consume the 5c to make sure the next character does not trigger
detection.
  • Loading branch information
elupus authored Dec 1, 2023
1 parent 42f339d commit 29d8cd0
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions components/nibegw/NibeGw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,20 @@ void NibeGw::loop()
buffer[0] = buffer[1];
buffer[1] = b;

if (buffer[0] == 0x5C && buffer[1] != 0x5C)
if (buffer[0] == 0x5C)
{
index = 2;
state = STATE_WAIT_DATA;
ESP_LOGVV(TAG, "Frame start found");
if (buffer[1] == 0x5C)
{
buffer[1] = 0x00;
state = STATE_WAIT_START;
ESP_LOGVV(TAG, "Ignore double start");
}
else
{
index = 2;
state = STATE_WAIT_DATA;
ESP_LOGVV(TAG, "Frame start found");
}
}
}
break;
Expand Down

0 comments on commit 29d8cd0

Please sign in to comment.