Merge remote-tracking branch 'origin/dev'

This commit is contained in:
proddy
2022-01-20 10:51:40 +01:00
8 changed files with 50 additions and 15 deletions

View File

@@ -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/), 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). 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 # [3.3.0] November 28 2021

View File

@@ -815,10 +815,11 @@ void Boiler::process_UBAErrorMessage(std::shared_ptr<const Telegram> telegram) {
// 0xC2 // 0xC2
void Boiler::process_UBAErrorMessage2(std::shared_ptr<const Telegram> telegram) { void Boiler::process_UBAErrorMessage2(std::shared_ptr<const Telegram> telegram) {
// not sure why this test is in , so removing // for decoding "last error code" we need telegram starting with offset 0
// if (telegram->offset > 0 || telegram->message_length < 14) { if (telegram->offset != 0 || telegram->message_length < 20) {
// return; return;
// } }
char code[4]; char code[4];
uint16_t codeNo; uint16_t codeNo;
char start_time[17]; char start_time[17];

View File

@@ -2691,6 +2691,17 @@ void Thermostat::register_device_values() {
case EMS_DEVICE_FLAG_RC20: case EMS_DEVICE_FLAG_RC20:
register_device_value(TAG_THERMOSTAT_DATA, &dateTime_, DeviceValueType::STRING, nullptr, FL_(dateTime), DeviceValueUOM::NONE); // can't set datetime register_device_value(TAG_THERMOSTAT_DATA, &dateTime_, DeviceValueType::STRING, nullptr, FL_(dateTime), DeviceValueUOM::NONE); // can't set datetime
break; 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: 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, &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, &ibaMainDisplay_, DeviceValueType::ENUM, FL_(enum_ibaMainDisplay), FL_(ibaMainDisplay), DeviceValueUOM::NONE);
@@ -2940,6 +2951,9 @@ void Thermostat::register_device_values_hc(std::shared_ptr<Thermostat::HeatingCi
register_device_value(tag, &hc->summertemp, DeviceValueType::UINT, nullptr, FL_(summertemp), DeviceValueUOM::DEGREES, MAKE_CF_CB(set_summertemp)); register_device_value(tag, &hc->summertemp, 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); register_device_value(tag, &hc->summermode, DeviceValueType::BOOL, nullptr, FL_(summermode), DeviceValueUOM::NONE);
break; 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_RC30_N:
case EMS_DEVICE_FLAG_RC35: 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)); register_device_value(tag, &hc->mode, DeviceValueType::ENUM, FL_(enum_mode3), FL_(mode), DeviceValueUOM::NONE, MAKE_CF_CB(set_mode));

View File

@@ -461,7 +461,7 @@ void EMSdevice::show_mqtt_handlers(uuid::console::Shell & shell) {
// register a callback function for a specific telegram type // 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) { 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" // 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<const Telegram>
// take a telegram_type_id and call the matching handler // take a telegram_type_id and call the matching handler
// return true if match found // return true if match found
bool EMSdevice::handle_telegram(std::shared_ptr<const Telegram> telegram) { bool EMSdevice::handle_telegram(std::shared_ptr<const Telegram> telegram) {
for (const auto & tf : telegram_functions_) { for (auto & tf : telegram_functions_) {
if (tf.telegram_type_id_ == telegram->type_id) { 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 // if the data block is empty and we have not received data before, assume that this telegram
// so remove it from the automatic fetch list // is not recognized by the bus master. So remove it from the automatic fetch list
if (telegram->message_length == 0 && telegram->offset == 0) { 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()); 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; return false;
} }
if (telegram->message_length > 0) { if (telegram->message_length > 0) {
tf.received_ = true;
tf.process_function_(telegram); tf.process_function_(telegram);
} }

View File

@@ -407,12 +407,14 @@ class EMSdevice {
uint16_t telegram_type_id_; // it's type_id uint16_t telegram_type_id_; // it's type_id
const __FlashStringHelper * telegram_type_name_; // e.g. RC20Message const __FlashStringHelper * telegram_type_name_; // e.g. RC20Message
bool fetch_; // if this type_id be queried automatically bool fetch_; // if this type_id be queried automatically
bool received_;
process_function_p process_function_; 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_id_(telegram_type_id)
, telegram_type_name_(telegram_type_name) , telegram_type_name_(telegram_type_name)
, fetch_(fetch) , fetch_(fetch)
, received_(received)
, process_function_(process_function) { , process_function_(process_function) {
} }
}; };

View File

@@ -1191,7 +1191,7 @@ void EMSESP::incoming_telegram(uint8_t * data, const uint8_t length) {
txservice_.send_poll(); // close the bus txservice_.send_poll(); // close the bus
txservice_.reset_retry_count(); txservice_.reset_retry_count();
tx_successful = true; 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 (length == 32) {
if (txservice_.read_next_tx(data[3]) == read_id_) { if (txservice_.read_next_tx(data[3]) == read_id_) {
read_next_ = true; read_next_ = true;

View File

@@ -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()); 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) { uint16_t TxService::read_next_tx(uint8_t offset) {
// add to the top/front of the queue // add to the top/front of the queue
uint8_t message_data[1] = {EMS_MAX_TELEGRAM_LENGTH}; // request all data, 32 bytes uint8_t message_data[1] = {EMS_MAX_TELEGRAM_LENGTH}; // request all data, 32 bytes
if (telegram_last_->offset != offset) { if (telegram_last_->offset != offset) {
return 0; 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; return telegram_last_->type_id;
} }

View File

@@ -1 +1 @@
#define EMSESP_APP_VERSION "3.3.0" #define EMSESP_APP_VERSION "3.3.1"