From 1c73af88d21e2826135b147d077cd219ed26090a Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Tue, 23 Jun 2020 13:15:56 +0200 Subject: [PATCH] fix fluctuating bitvalues, fix "send telegram", add solarpump softstart, add DHW temp for 9000i --- src/devices/boiler.cpp | 5 +++-- src/devices/solar.cpp | 4 ++++ src/telegram.cpp | 13 ++++++++++++- src/telegram.h | 5 +++-- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/devices/boiler.cpp b/src/devices/boiler.cpp index a9c6b44bf..1b5dadc92 100644 --- a/src/devices/boiler.cpp +++ b/src/devices/boiler.cpp @@ -675,6 +675,8 @@ void Boiler::process_UBAErrorMessage(std::shared_ptr telegram) { void Boiler::set_warmwater_temp(const uint8_t temperature) { LOG_INFO(F("Setting boiler warm water temperature to %d C"), temperature); write_command(EMS_TYPE_UBAParameterWW, 2, temperature); + // for i9000, see #397 + write_command(EMS_TYPE_UBAFlags, 3, temperature); } // flow temp @@ -846,8 +848,7 @@ void Boiler::console_commands(Shell & shell, unsigned int context) { set_warmwater_mode(1); } else if (arguments[0] == read_flash_string(F_(eco))) { set_warmwater_mode(2); - } - if (arguments[0] == read_flash_string(F_(intelligent))) { + } else if (arguments[0] == read_flash_string(F_(intelligent))) { set_warmwater_mode(3); } else { shell.println(F("Invalid value. Must be hot, eco or intelligent")); diff --git a/src/devices/solar.cpp b/src/devices/solar.cpp index 07e32b89e..fbda29547 100644 --- a/src/devices/solar.cpp +++ b/src/devices/solar.cpp @@ -181,7 +181,11 @@ void Solar::process_SM100Config(std::shared_ptr telegram) { * 30 00 FF 09 02 64 1E = 30% */ void Solar::process_SM100Status(std::shared_ptr telegram) { + uint8_t pumpmod = pumpModulation_; telegram->read_value(pumpModulation_, 9); + if (pumpmod == 0 && pumpModulation_ == 100) { // mask out boosts + pumpModulation_ = 15; // set to minimum, + } } /* diff --git a/src/telegram.cpp b/src/telegram.cpp index 4f310d978..7d1a6a05e 100644 --- a/src/telegram.cpp +++ b/src/telegram.cpp @@ -427,7 +427,7 @@ void TxService::add(uint8_t operation, uint8_t * data, const uint8_t length) { // EMS 1.0 type_id = data[2]; message_data = data + 4; - message_length = length - 5; + message_length = length - 4; } else { // EMS 2.0 / EMS+ uint8_t shift = 0; // default when data[2] is 0xFF @@ -442,9 +442,20 @@ void TxService::add(uint8_t operation, uint8_t * data, const uint8_t length) { // if we don't have a type_id or empty data block, exit if ((type_id == 0) || (message_length == 0)) { +#ifdef EMSESP_DEBUG + LOG_DEBUG(F("[DEBUG] Tx telegram type %d failed, length %d"), type_id, message_length); +#endif return; } + if (operation == Telegram::Operation::TX_RAW) { + if (dest & 0x80) { + operation = Telegram::Operation::TX_READ; + } else { + operation = Telegram::Operation::TX_WRITE; + } + } + auto telegram = std::make_shared(operation, src, dest, type_id, offset, message_data, message_length); // operation is TX_WRITE or TX_READ // if the queue is full, make room but removing the last one diff --git a/src/telegram.h b/src/telegram.h index 550c73c67..f4b5e7891 100644 --- a/src/telegram.h +++ b/src/telegram.h @@ -81,11 +81,12 @@ class Telegram { // reads a bit value from a given telegram position void read_bitvalue(uint8_t & value, const uint8_t index, const uint8_t bit) const { - if ((index - offset) >= message_length) { + uint8_t abs_index = (index - offset); + if(abs_index >= message_length) { return; // out of bounds } - value = (uint8_t)(((message_data[index - offset]) >> (bit)) & 0x01); + value = (uint8_t)(((message_data[abs_index]) >> (bit)) & 0x01); } // read values from a telegram. We always store the value, regardless if its garbage