From add405e284799d249025e869349f28d942fbae6a Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Wed, 9 Sep 2020 19:06:11 +0200 Subject: [PATCH 1/3] verify large offsets, readback setpoint roomtemp on `cmd:temp` --- src/devices/thermostat.cpp | 4 +++- src/telegram.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index aa2845c9d..4c4eeef37 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -1630,7 +1630,8 @@ void Thermostat::set_temperature(const float temperature, const uint8_t mode, co break; default: case HeatingCircuit::Mode::AUTO: - offset = 0x08; // auto offset + offset = 0x08; // auto offset + validate_typeid = monitor_typeids[hc->hc_num() - 1]; // get setpoint roomtemp back break; } @@ -1678,6 +1679,7 @@ void Thermostat::set_temperature(const float temperature, const uint8_t mode, co break; default: case HeatingCircuit::Mode::AUTO: // automatic selection, if no type is defined, we use the standard code + validate_typeid = monitor_typeids[hc->hc_num() - 1]; //get setpoint roomtemp back if (model == EMS_DEVICE_FLAG_RC35) { uint8_t mode_ = hc->get_mode(this->flags()); if (mode_ == HeatingCircuit::Mode::NIGHT) { diff --git a/src/telegram.cpp b/src/telegram.cpp index 19eb66243..82ac361d9 100644 --- a/src/telegram.cpp +++ b/src/telegram.cpp @@ -584,8 +584,10 @@ uint16_t TxService::post_send_query() { if (post_typeid) { uint8_t dest = (this->telegram_last_->dest & 0x7F); + // when set a value with large offset before and validate on same type, we have to add offset 0, 26, 52, ... + uint8_t offset = (this->telegram_last_->type_id == post_typeid) ? ((this->telegram_last_->offset / 26) * 26) : 0; uint8_t message_data[1] = {EMS_MAX_TELEGRAM_LENGTH}; // request all data, 32 bytes - this->add(Telegram::Operation::TX_READ, dest, post_typeid, 0, message_data, 1, true); + this->add(Telegram::Operation::TX_READ, dest, post_typeid, offset, message_data, 1, true); // read_request(telegram_last_post_send_query_, dest, 0); // no offset LOG_DEBUG(F("Sending post validate read, type ID 0x%02X to dest 0x%02X"), post_typeid, dest); set_post_send_query(0); // reset From e99a1f0cd4a3a9e1aa4e6bbce6a85b7ba498e005 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Thu, 10 Sep 2020 11:27:08 +0200 Subject: [PATCH 2/3] exclude crc from ems+ telegram, telegram length check to 27 --- src/telegram.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/telegram.cpp b/src/telegram.cpp index 82ac361d9..84abe5dca 100644 --- a/src/telegram.cpp +++ b/src/telegram.cpp @@ -73,7 +73,7 @@ Telegram::Telegram(const uint8_t operation, , offset(offset) , message_length(message_length) { // copy complete telegram data over, preventing buffer overflow - for (uint8_t i = 0; ((i < message_length) && (i != EMS_MAX_TELEGRAM_MESSAGE_LENGTH - 1)); i++) { + for (uint8_t i = 0; ((i < message_length) && (i < EMS_MAX_TELEGRAM_MESSAGE_LENGTH)); i++) { message_data[i] = data[i]; } } @@ -189,7 +189,7 @@ void RxService::add(uint8_t * data, uint8_t length) { } type_id = (data[4 + shift] << 8) + data[5 + shift] + 256; message_data = data + 6 + shift; - message_length = length - 6 - shift; + message_length = length - 7 - shift; } // if we're watching and "raw" print out actual telegram as bytes to the console From c10a619fbd2d94a1a7dc98126a06ec98c0956cea Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Thu, 10 Sep 2020 17:13:16 +0200 Subject: [PATCH 3/3] watch_id on type can also be 7F..FF --- src/emsesp.cpp | 10 +++------- src/telegram.cpp | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/emsesp.cpp b/src/emsesp.cpp index ceaed6dd0..e6b4423db 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -131,12 +131,7 @@ uint8_t EMSESP::actual_master_thermostat() { // to watch both type IDs and device IDs void EMSESP::watch_id(uint16_t watch_id) { - // if it's a device ID, which is a single byte, remove the MSB so to support both Buderus and HT3 protocols - if (watch_id <= 0xFF) { - watch_id_ = (watch_id & 0x7F); - } else { - watch_id_ = watch_id; - } + watch_id_ = watch_id; } // change the tx_mode @@ -491,7 +486,8 @@ bool EMSESP::process_telegram(std::shared_ptr telegram) { LOG_NOTICE(pretty_telegram(telegram).c_str()); read_id_ = WATCH_ID_NONE; } else if (watch() == WATCH_ON) { - if ((watch_id_ == WATCH_ID_NONE) || (telegram->src == watch_id_) || (telegram->dest == watch_id_) || (telegram->type_id == watch_id_)) { + if ((watch_id_ == WATCH_ID_NONE) || (telegram->type_id == watch_id_) || + ((watch_id_ < 0x80) && ((telegram->src == watch_id_) || (telegram->dest == watch_id_)))) { LOG_NOTICE(pretty_telegram(telegram).c_str()); } } diff --git a/src/telegram.cpp b/src/telegram.cpp index 84abe5dca..1ef80c54f 100644 --- a/src/telegram.cpp +++ b/src/telegram.cpp @@ -195,7 +195,7 @@ void RxService::add(uint8_t * data, uint8_t length) { // if we're watching and "raw" print out actual telegram as bytes to the console if (EMSESP::watch() == EMSESP::Watch::WATCH_RAW) { uint16_t trace_watch_id = EMSESP::watch_id(); - if ((trace_watch_id == WATCH_ID_NONE) || (src == trace_watch_id) || (dest == trace_watch_id) || (type_id == trace_watch_id)) { + if ((trace_watch_id == WATCH_ID_NONE) || (type_id == trace_watch_id) || ((trace_watch_id < 0x80) && ((src == trace_watch_id) || (dest == trace_watch_id)))) { LOG_NOTICE(F("Rx: %s"), Helpers::data_to_hex(data, length).c_str()); } }