mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 00:39:50 +03:00
Merge pull request #235 from pswid:dev
fix overlapping 0xC2 and overflow of offset
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
|
||||
## Fixed
|
||||
- lastcode broke MQTT JSON structure [#228]
|
||||
- overlapping while reading sequence of EMS1.0 telegrams
|
||||
- redundant telegram readings (because of offset overflow)
|
||||
|
||||
## Changed
|
||||
|
||||
|
||||
@@ -1191,7 +1191,7 @@ void EMSESP::incoming_telegram(uint8_t * data, const uint8_t length) {
|
||||
txservice_.send_poll(); // close the bus
|
||||
txservice_.reset_retry_count();
|
||||
tx_successful = true;
|
||||
// if telegram is longer read next part with offset + 25 for ems+
|
||||
// if telegram is longer read next part with offset +25 for ems+ or +27 for ems1.0
|
||||
if (length == 32) {
|
||||
if (txservice_.read_next_tx(data[3]) == read_id_) {
|
||||
read_next_ = true;
|
||||
|
||||
@@ -613,7 +613,17 @@ 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 = 25; //for EMS+ telegram increase offset by 25
|
||||
if (telegram_last_->type_id < 0x100) { //but for EMS1.0 by 27
|
||||
add_offset = 27;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user