diff --git a/CHANGELOG.md b/CHANGELOG.md index 023cb75dc..bf8fd774f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -# Changelog +# [3.3.1] January 20 2022 + +- lastcode broke MQTT JSON structure [#228](https://github.com/emsesp/EMS-ESP32/issues/228) +- overlapping while reading sequence of EMS1.0 telegrams +- redundant telegram readings (because of offset overflow) +- added missing RC30/Moduline400 [#243](https://github.com/emsesp/EMS-ESP32/issues/243) +- check received status before toggling fetch on empty telegram [#268][#282] # [3.3.0] November 28 2021 diff --git a/src/devices/boiler.cpp b/src/devices/boiler.cpp index 35a1fdbef..c942f5009 100644 --- a/src/devices/boiler.cpp +++ b/src/devices/boiler.cpp @@ -815,10 +815,11 @@ void Boiler::process_UBAErrorMessage(std::shared_ptr telegram) { // 0xC2 void Boiler::process_UBAErrorMessage2(std::shared_ptr telegram) { - // not sure why this test is in , so removing - // if (telegram->offset > 0 || telegram->message_length < 14) { - // return; - // } + // for decoding "last error code" we need telegram starting with offset 0 + if (telegram->offset != 0 || telegram->message_length < 20) { + return; + } + char code[4]; uint16_t codeNo; char start_time[17]; diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index 741256cb8..f2e900c15 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -2691,6 +2691,17 @@ void Thermostat::register_device_values() { case EMS_DEVICE_FLAG_RC20: register_device_value(TAG_THERMOSTAT_DATA, &dateTime_, DeviceValueType::STRING, nullptr, FL_(dateTime), DeviceValueUOM::NONE); // can't set datetime break; + case EMS_DEVICE_FLAG_RC30: + register_device_value(TAG_THERMOSTAT_DATA, &dateTime_, DeviceValueType::STRING, nullptr, FL_(dateTime), DeviceValueUOM::NONE); // can't set datetime + register_device_value(TAG_THERMOSTAT_DATA, &ibaMainDisplay_, DeviceValueType::ENUM, FL_(enum_ibaMainDisplay), FL_(ibaMainDisplay), DeviceValueUOM::NONE); + register_device_value(TAG_THERMOSTAT_DATA, &ibaLanguage_, DeviceValueType::ENUM, FL_(enum_ibaLanguage), FL_(ibaLanguage), DeviceValueUOM::NONE); + register_device_value(TAG_THERMOSTAT_DATA, + &ibaClockOffset_, + DeviceValueType::INT, + nullptr, + FL_(ibaClockOffset), + DeviceValueUOM::SECONDS); // offset (in sec) to clock, 0xff=-1s, 0x02=2s + break; case EMS_DEVICE_FLAG_RC30_N: register_device_value(TAG_THERMOSTAT_DATA, &dateTime_, DeviceValueType::STRING, nullptr, FL_(dateTime), DeviceValueUOM::NONE); // can't set datetime register_device_value(TAG_THERMOSTAT_DATA, &ibaMainDisplay_, DeviceValueType::ENUM, FL_(enum_ibaMainDisplay), FL_(ibaMainDisplay), DeviceValueUOM::NONE); @@ -2940,6 +2951,9 @@ void Thermostat::register_device_values_hc(std::shared_ptrsummertemp, DeviceValueType::UINT, nullptr, FL_(summertemp), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_summertemp)); register_device_value(tag, &hc->summermode, DeviceValueType::BOOL, nullptr, FL_(summermode), DeviceValueUOM::NONE); break; + case EMS_DEVICE_FLAG_RC30: + register_device_value(tag, &hc->mode, DeviceValueType::ENUM, FL_(enum_mode3), FL_(mode), DeviceValueUOM::NONE, MAKE_CF_CB(set_mode)); + break; case EMS_DEVICE_FLAG_RC30_N: case EMS_DEVICE_FLAG_RC35: register_device_value(tag, &hc->mode, DeviceValueType::ENUM, FL_(enum_mode3), FL_(mode), DeviceValueUOM::NONE, MAKE_CF_CB(set_mode)); diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index d2c3e0d47..60a3a2d87 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -461,7 +461,7 @@ void EMSdevice::show_mqtt_handlers(uuid::console::Shell & shell) { // register a callback function for a specific telegram type void EMSdevice::register_telegram_type(const uint16_t telegram_type_id, const __FlashStringHelper * telegram_type_name, bool fetch, const process_function_p f) { - telegram_functions_.emplace_back(telegram_type_id, telegram_type_name, fetch, f); + telegram_functions_.emplace_back(telegram_type_id, telegram_type_name, fetch, false, f); } // add to device value library, also know now as a "device entity" @@ -1156,17 +1156,18 @@ const std::string EMSdevice::telegram_type_name(std::shared_ptr // take a telegram_type_id and call the matching handler // return true if match found bool EMSdevice::handle_telegram(std::shared_ptr telegram) { - for (const auto & tf : telegram_functions_) { + for (auto & tf : telegram_functions_) { if (tf.telegram_type_id_ == telegram->type_id) { - // if the data block is empty, assume that this telegram is not recognized by the bus master - // so remove it from the automatic fetch list - if (telegram->message_length == 0 && telegram->offset == 0) { + // if the data block is empty and we have not received data before, assume that this telegram + // is not recognized by the bus master. So remove it from the automatic fetch list + if (telegram->message_length == 0 && telegram->offset == 0 && !tf.received_) { EMSESP::logger().debug(F("This telegram (%s) is not recognized by the EMS bus"), read_flash_string(tf.telegram_type_name_).c_str()); - toggle_fetch(tf.telegram_type_id_, false); + tf.fetch_ = false; return false; } if (telegram->message_length > 0) { + tf.received_ = true; tf.process_function_(telegram); } diff --git a/src/emsdevice.h b/src/emsdevice.h index cea919fb3..dd936ccb1 100644 --- a/src/emsdevice.h +++ b/src/emsdevice.h @@ -407,12 +407,14 @@ class EMSdevice { uint16_t telegram_type_id_; // it's type_id const __FlashStringHelper * telegram_type_name_; // e.g. RC20Message bool fetch_; // if this type_id be queried automatically + bool received_; process_function_p process_function_; - TelegramFunction(uint16_t telegram_type_id, const __FlashStringHelper * telegram_type_name, bool fetch, const process_function_p process_function) + TelegramFunction(uint16_t telegram_type_id, const __FlashStringHelper * telegram_type_name, bool fetch, bool received, const process_function_p process_function) : telegram_type_id_(telegram_type_id) , telegram_type_name_(telegram_type_name) , fetch_(fetch) + , received_(received) , process_function_(process_function) { } }; diff --git a/src/emsesp.cpp b/src/emsesp.cpp index bd7ce5cca..d31849933 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -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; diff --git a/src/telegram.cpp b/src/telegram.cpp index f56ac0148..186430b91 100644 --- a/src/telegram.cpp +++ b/src/telegram.cpp @@ -607,13 +607,24 @@ void TxService::retry_tx(const uint8_t operation, const uint8_t * data, const ui tx_telegrams_.emplace_front(tx_telegram_id_++, std::move(telegram_last_), true, get_post_send_query()); } +// send a request to read the next block of data from longer telegrams uint16_t TxService::read_next_tx(uint8_t offset) { // add to the top/front of the queue uint8_t message_data[1] = {EMS_MAX_TELEGRAM_LENGTH}; // request all data, 32 bytes 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; } diff --git a/src/version.h b/src/version.h index 322394716..d69acecf4 100644 --- a/src/version.h +++ b/src/version.h @@ -1 +1 @@ -#define EMSESP_APP_VERSION "3.3.0" +#define EMSESP_APP_VERSION "3.3.1"