Skip to content

Commit

Permalink
fix overlapping 0xC2 and overflow of offset
Browse files Browse the repository at this point in the history
  • Loading branch information
pswid committed Dec 3, 2021
1 parent 92da613 commit 1343bbf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG_LATEST.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

## Fixed
- lastcode broke MQTT JSON structure [#228]
- overlapping while reading 0xC2 from Boiler
- redundant telegram readings (because of offset overflow)

## Changed

Expand Down
14 changes: 13 additions & 1 deletion src/telegram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,19 @@ uint16_t TxService::read_next_tx(uint8_t offset) {
if (telegram_last_->offset != offset) {
return 0;
}
add(Telegram::Operation::TX_READ, telegram_last_->dest, telegram_last_->type_id, telegram_last_->offset + 25, message_data, 1, 0, true);

uint8_t add_offset;
if (telegram_last_->dest == 0x08 && telegram_last_->type_id == 0xC2) { //fix for overlapping 0xC2 telegrams from Boiler. Are other telegrams also affected?
add_offset = 27;
} else {
add_offset = 25;
}

if (UINT8_MAX - telegram_last_->offset < add_offset) { //stop if new offset would overflow
return 0;
}

add(Telegram::Operation::TX_READ, telegram_last_->dest, telegram_last_->type_id, telegram_last_->offset + add_offset, message_data, 1, 0, true);
return telegram_last_->type_id;
}

Expand Down

0 comments on commit 1343bbf

Please sign in to comment.