From a8f997670c18994c61c7b8daf882f800b7d0b8cf Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Mon, 14 Dec 2020 09:37:05 +0100 Subject: [PATCH] add v2.1.1b7 changes, json sizes --- .../src/project/EMSESPSettingsController.tsx | 22 +++++++++++++++ interface/src/project/EMSESPtypes.ts | 2 ++ src/WebAPIService.cpp | 17 ++++++------ src/WebDevicesService.cpp | 2 +- src/WebSettingsService.cpp | 11 +++++--- src/WebSettingsService.h | 4 +++ src/command.cpp | 2 ++ src/device_library.h | 1 + src/devices/boiler.cpp | 14 ++++++---- src/devices/switch.cpp | 14 ++++++++-- src/devices/switch.h | 1 + src/devices/thermostat.cpp | 21 +++++++-------- src/emsesp.cpp | 27 ++++++++++++++----- src/emsesp.h | 11 ++++++++ src/mqtt.cpp | 4 +-- src/system.cpp | 4 ++- src/telegram.cpp | 7 ++++- src/telegram.h | 2 +- 18 files changed, 122 insertions(+), 44 deletions(-) diff --git a/interface/src/project/EMSESPSettingsController.tsx b/interface/src/project/EMSESPSettingsController.tsx index ca97a8af8..393cfd9ac 100644 --- a/interface/src/project/EMSESPSettingsController.tsx +++ b/interface/src/project/EMSESPSettingsController.tsx @@ -104,6 +104,18 @@ function EMSESPSettingsControllerForm(props: EMSESPSettingsControllerFormProps) onChange={handleValueChange('tx_gpio')} margin="normal" /> +

Dallas Sensor @@ -245,6 +257,16 @@ function EMSESPSettingsControllerForm(props: EMSESPSettingsControllerFormProps) onChange={handleValueChange('syslog_mark_interval')} margin="normal" /> + + } + label="Trace ems-telegrams in raw format" + />

Analog Input diff --git a/interface/src/project/EMSESPtypes.ts b/interface/src/project/EMSESPtypes.ts index 0142f3feb..f9f5c54f2 100644 --- a/interface/src/project/EMSESPtypes.ts +++ b/interface/src/project/EMSESPtypes.ts @@ -1,5 +1,6 @@ export interface EMSESPSettings { tx_mode: number; + tx_delay: number; ems_bus_id: number; syslog_enabled: boolean; syslog_level: number; @@ -17,6 +18,7 @@ export interface EMSESPSettings { api_enabled: boolean; bool_format: number; analog_enabled: boolean; + trace_raw: boolean; } export enum busConnectionStatus { diff --git a/src/WebAPIService.cpp b/src/WebAPIService.cpp index f0e93932d..8e96efcee 100644 --- a/src/WebAPIService.cpp +++ b/src/WebAPIService.cpp @@ -71,7 +71,7 @@ void WebAPIService::webAPIService(AsyncWebServerRequest * request) { id = "-1"; } - DynamicJsonDocument doc(EMSESP_JSON_SIZE_LARGE_DYN); + DynamicJsonDocument doc(EMSESP_JSON_SIZE_XLARGE_DYN); JsonObject json = doc.to(); bool ok = false; @@ -82,19 +82,18 @@ void WebAPIService::webAPIService(AsyncWebServerRequest * request) { if (api_enabled) { // we only allow commands with parameters if the API is enabled ok = Command::call(device_type, cmd.c_str(), data.c_str(), id.toInt(), json); // has cmd, data and id - if (ok && json.size()) { - // send json output back to web - std::string buffer; - serializeJsonPretty(doc, buffer); - request->send(200, "text/plain", buffer.c_str()); - return; - } } else { request->send(401, "text/plain", F("Unauthorized")); return; } } - + if (ok && json.size()) { + // send json output back to web + std::string buffer; + serializeJsonPretty(doc, buffer); + request->send(200, "text/plain", buffer.c_str()); + return; + } request->send(200, "text/plain", ok ? F("OK") : F("Invalid")); } diff --git a/src/WebDevicesService.cpp b/src/WebDevicesService.cpp index 9b5c03368..7e2a289d9 100644 --- a/src/WebDevicesService.cpp +++ b/src/WebDevicesService.cpp @@ -81,7 +81,7 @@ void WebDevicesService::all_devices(AsyncWebServerRequest * request) { // The unique_id is the unique record ID from the Web table to identify which device to load void WebDevicesService::device_data(AsyncWebServerRequest * request, JsonVariant & json) { if (json.is()) { - AsyncJsonResponse * response = new AsyncJsonResponse(false, EMSESP_JSON_SIZE_XLARGE_DYN); + AsyncJsonResponse * response = new AsyncJsonResponse(false, EMSESP_JSON_SIZE_XXLARGE_DYN); for (const auto & emsdevice : EMSESP::emsdevices) { if (emsdevice) { if (emsdevice->unique_id() == json["id"]) { diff --git a/src/WebSettingsService.cpp b/src/WebSettingsService.cpp index 84739786f..bf5c56cff 100644 --- a/src/WebSettingsService.cpp +++ b/src/WebSettingsService.cpp @@ -31,9 +31,11 @@ WebSettingsService::WebSettingsService(AsyncWebServer * server, FS * fs, Securit void WebSettings::read(WebSettings & settings, JsonObject & root) { root["tx_mode"] = settings.tx_mode; + root["tx_delay"] = settings.tx_delay; root["ems_bus_id"] = settings.ems_bus_id; root["syslog_enabled"] = settings.syslog_enabled; root["syslog_level"] = settings.syslog_level; + root["trace_raw"] = settings.trace_raw; root["syslog_mark_interval"] = settings.syslog_mark_interval; root["syslog_host"] = settings.syslog_host; root["master_thermostat"] = settings.master_thermostat; @@ -57,9 +59,10 @@ StateUpdateResult WebSettings::update(JsonObject & root, WebSettings & settings) // tx_mode, rx and tx pins snprintf_P(&crc_before[0], crc_before.capacity() + 1, PSTR("%d%d%d"), settings.tx_mode, settings.rx_gpio, settings.tx_gpio); - settings.tx_mode = root["tx_mode"] | EMSESP_DEFAULT_TX_MODE; - settings.rx_gpio = root["rx_gpio"] | EMSESP_DEFAULT_RX_GPIO; - settings.tx_gpio = root["tx_gpio"] | EMSESP_DEFAULT_TX_GPIO; + settings.tx_mode = root["tx_mode"] | EMSESP_DEFAULT_TX_MODE; + settings.tx_delay = root["tx_delay"] | EMSESP_DEFAULT_TX_DELAY; + settings.rx_gpio = root["rx_gpio"] | EMSESP_DEFAULT_RX_GPIO; + settings.tx_gpio = root["tx_gpio"] | EMSESP_DEFAULT_TX_GPIO; snprintf_P(&crc_after[0], crc_after.capacity() + 1, PSTR("%d%d%d"), settings.tx_mode, settings.rx_gpio, settings.tx_gpio); if (crc_before != crc_after) { add_flags(ChangeFlags::UART); @@ -77,6 +80,8 @@ StateUpdateResult WebSettings::update(JsonObject & root, WebSettings & settings) settings.syslog_level = root["syslog_level"] | EMSESP_DEFAULT_SYSLOG_LEVEL; settings.syslog_mark_interval = root["syslog_mark_interval"] | EMSESP_DEFAULT_SYSLOG_MARK_INTERVAL; settings.syslog_host = root["syslog_host"] | EMSESP_DEFAULT_SYSLOG_HOST; + settings.trace_raw = root["trace_raw"] | EMSESP_DEFAULT_TRACELOG_RAW ; + EMSESP::trace_raw(settings.trace_raw); snprintf_P(&crc_after[0], crc_after.capacity() + 1, PSTR("%d%d%d%s"), diff --git a/src/WebSettingsService.h b/src/WebSettingsService.h index 7345394b6..92f865a00 100644 --- a/src/WebSettingsService.h +++ b/src/WebSettingsService.h @@ -26,11 +26,13 @@ #define EMSESP_SETTINGS_SERVICE_PATH "/rest/emsespSettings" #define EMSESP_DEFAULT_TX_MODE 1 // EMS1.0 +#define EMSESP_DEFAULT_TX_DELAY 0 // no delay #define EMSESP_DEFAULT_EMS_BUS_ID 0x0B // service key #define EMSESP_DEFAULT_SYSLOG_ENABLED false #define EMSESP_DEFAULT_SYSLOG_LEVEL 3 // ERR #define EMSESP_DEFAULT_SYSLOG_MARK_INTERVAL 0 #define EMSESP_DEFAULT_SYSLOG_HOST "" +#define EMSESP_DEFAULT_TRACELOG_RAW false #define EMSESP_DEFAULT_MASTER_THERMOSTAT 0 // not set #define EMSESP_DEFAULT_SHOWER_TIMER false #define EMSESP_DEFAULT_SHOWER_ALERT false @@ -64,6 +66,7 @@ namespace emsesp { class WebSettings { public: uint8_t tx_mode; + uint8_t tx_delay; uint8_t ems_bus_id; uint8_t master_thermostat; bool shower_timer; @@ -72,6 +75,7 @@ class WebSettings { int8_t syslog_level; // uuid::log::Level uint32_t syslog_mark_interval; String syslog_host; + bool trace_raw; uint8_t rx_gpio; uint8_t tx_gpio; uint8_t dallas_gpio; diff --git a/src/command.cpp b/src/command.cpp index 44eb58875..077116865 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -32,6 +32,7 @@ std::vector Command::cmdfunctions_; bool Command::call(const uint8_t device_type, const char * cmd, const char * value, const int8_t id) { auto cf = find_command(device_type, cmd); if ((cf == nullptr) || (cf->cmdfunction_json_)) { + LOG_WARNING(F("Command %s not found"), cmd); return false; // command not found, or requires a json } @@ -55,6 +56,7 @@ bool Command::call(const uint8_t device_type, const char * cmd, const char * val bool Command::call(const uint8_t device_type, const char * cmd, const char * value, const int8_t id, JsonObject & json) { auto cf = find_command(device_type, cmd); if (cf == nullptr) { + LOG_WARNING(F("Command %s not found"), cmd); return false; // command not found or not json } diff --git a/src/device_library.h b/src/device_library.h index 8d8050b27..31bbac757 100644 --- a/src/device_library.h +++ b/src/device_library.h @@ -78,6 +78,7 @@ {165, DeviceType::THERMOSTAT, F("RC100/Moduline 1000/1010"), DeviceFlags::EMS_DEVICE_FLAG_RC100}, // 0x18, 0x38 // Thermostat - Sieger - 0x10 / 0x17 +{ 66, DeviceType::THERMOSTAT, F("ES72"), DeviceFlags::EMS_DEVICE_FLAG_RC20}, // first seen as remote 0x19, could also be RC20_2? { 76, DeviceType::THERMOSTAT, F("ES73"), DeviceFlags::EMS_DEVICE_FLAG_RC35}, // 0x10 {113, DeviceType::THERMOSTAT, F("ES72/RC20"), DeviceFlags::EMS_DEVICE_FLAG_RC20_2}, // 0x17 diff --git a/src/devices/boiler.cpp b/src/devices/boiler.cpp index f87ea4964..2a5d683e5 100644 --- a/src/devices/boiler.cpp +++ b/src/devices/boiler.cpp @@ -121,7 +121,7 @@ Boiler::Boiler(uint8_t device_type, int8_t device_id, uint8_t product_id, const register_device_value(boiler_data_ww, &wWCircPumpMode_, DeviceValueType::ENUM, - flash_string_vector{F("1x3min"), F("2x3min"), F("3x3min"), F("4x3min"), F("5x3min"), F("6x3min"), F("continuos")}, + flash_string_vector{F("off"), F("1x3min"), F("2x3min"), F("3x3min"), F("4x3min"), F("5x3min"), F("6x3min"), F("continuos")}, F("wWCircPumpMode"), F("Warm water circulation pump freq"), DeviceValueUOM::NONE); @@ -484,10 +484,11 @@ void Boiler::process_UBAMonitorWW(std::shared_ptr telegram) { /* * UBAMonitorFastPlus - type 0xE4 - central heating monitor EMS+ - * Still to figure out are: retTemp, sysPress * temperatures at 7 and 23 always identical - * 88 00 E4 00 00 2D 2D 00 00 C9 34 02 21 64 3D 05 02 01 DE 00 00 00 00 03 62 14 00 02 21 00 00 33 - * 88 00 E4 23 00 00 00 00 00 2B 2B 83 ++ * Bosch Logamax Plus GB122: issue #620 ++ * 88 00 E4 00 00 2D 2D 00 00 C9 34 02 21 64 3D 05 02 01 DE 00 00 00 00 03 62 14 00 02 21 00 00 00 00 00 00 00 2B 2B 83 ++ * GB125/Logamatic MC110: issue #650: add retTemp & sysPress ++ * 08 00 E4 00 10 20 2D 48 00 C8 38 02 37 3C 27 03 00 00 00 00 00 01 7B 01 8F 11 00 02 37 80 00 02 1B 80 00 7F FF 80 00 */ void Boiler::process_UBAMonitorFastPlus(std::shared_ptr telegram) { has_update(telegram->read_value(selFlowTemp_, 6)); @@ -498,8 +499,11 @@ void Boiler::process_UBAMonitorFastPlus(std::shared_ptr telegram has_update(telegram->read_value(selBurnPow_, 9)); has_update(telegram->read_value(curFlowTemp_, 7)); has_update(telegram->read_value(flameCurr_, 19)); + has_update(telegram->read_value(retTemp_, 17)); // can be 0 if no sensor, handled in export_values + has_update(telegram->read_value(sysPress_, 21)); - //has_update(telegram->read_value(temperatur_, 13)); unknown temperature + //has_update(telegram->read_value(temperatur_, 13)); // unknown temperature + //has_update(telegram->read_value(temperatur_, 27)); // unknown temperature // read 3 char service code / installation status as appears on the display if ((telegram->message_length > 3) && (telegram->offset == 0)) { diff --git a/src/devices/switch.cpp b/src/devices/switch.cpp index ddc03a525..4d00796be 100644 --- a/src/devices/switch.cpp +++ b/src/devices/switch.cpp @@ -31,7 +31,8 @@ Switch::Switch(uint8_t device_type, uint8_t device_id, uint8_t product_id, const LOG_DEBUG(F("Adding new Switch with device ID 0x%02X"), device_id); register_telegram_type(0x9C, F("WM10MonitorMessage"), false, [&](std::shared_ptr t) { process_WM10MonitorMessage(t); }); - register_telegram_type(0x9B, F("WM10SetMessage"), false, [&](std::shared_ptr t) { process_WM10SetMessage(t); }); + register_telegram_type(0x9D, F("WM10SetMessage"), false, [&](std::shared_ptr t) { process_WM10SetMessage(t); }); + register_telegram_type(0x1E, F("WM10TempMessage"), false, [&](std::shared_ptr t) { process_WM10TempMessage(t); }); std::string empty(""); register_device_value(empty, &activated_, DeviceValueType::BOOL, {}, F("activated"), F("Activated"), DeviceValueUOM::NONE); @@ -71,15 +72,24 @@ bool Switch::publish_ha_config() { return true; } -// message 0x9B switch on/off +// message 0x9D switch on/off +// Thermostat(0x10) -> Switch(0x11), ?(0x9D), data: 00 void Switch::process_WM10SetMessage(std::shared_ptr telegram) { has_update(telegram->read_value(activated_, 0)); } // message 0x9C holds flowtemp and unknown status value +// Switch(0x11) -> All(0x00), ?(0x9C), data: 01 BA 00 01 00 void Switch::process_WM10MonitorMessage(std::shared_ptr telegram) { has_update(telegram->read_value(flowTemp_, 0)); // is * 10 has_update(telegram->read_value(status_, 2)); + // has_update(telegram->read_value(status2_, 3)); // unknown +} + +// message 0x1E flow temperature, same as in 9C, published often, republished also by boiler UBAFast 0x18 +// Switch(0x11) -> Boiler(0x08), ?(0x1E), data: 01 BA +void Switch::process_WM10TempMessage(std::shared_ptr telegram) { + has_update(telegram->read_value(flowTemp_, 0)); // is * 10 } } // namespace emsesp \ No newline at end of file diff --git a/src/devices/switch.h b/src/devices/switch.h index bc3b1e207..2f5759143 100644 --- a/src/devices/switch.h +++ b/src/devices/switch.h @@ -43,6 +43,7 @@ class Switch : public EMSdevice { void process_WM10SetMessage(std::shared_ptr telegram); void process_WM10MonitorMessage(std::shared_ptr telegram); + void process_WM10TempMessage(std::shared_ptr telegram); uint16_t flowTemp_; uint8_t status_; diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index d32c38036..607c2f2e4 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -1557,20 +1557,17 @@ bool Thermostat::set_program(const char * value, const int8_t id) { return false; } - if (set < 0 || set > 11) { + if (model() == EMS_DEVICE_FLAG_RC20_2 && set > 0 && set < 10) { + write_command(set_typeids[hc->hc_num() - 1], 11, set, set_typeids[hc->hc_num() - 1]); + } else if ((model() == EMS_DEVICE_FLAG_RC35 || model() == EMS_DEVICE_FLAG_RC30_1) && set < 11) { + write_command(timer_typeids[hc->hc_num() - 1], 84, set, timer_typeids[hc->hc_num() - 1]); + } else if ((model() == EMS_DEVICE_FLAG_RC300 || model() == EMS_DEVICE_FLAG_RC100) && (set == 1 || set == 2)) { + write_command(set_typeids[hc->hc_num() - 1], 11, set, set_typeids[hc->hc_num() - 1]); + } else { LOG_WARNING(F("Setting program: Invalid number")); return false; } - LOG_INFO(F("Setting program to %d for heating circuit %d"), set, hc->hc_num()); - if (model() == EMS_DEVICE_FLAG_RC20_2 && set > 0 && set < 10) { - write_command(set_typeids[hc->hc_num() - 1], 11, set, set_typeids[hc->hc_num() - 1]); - } else if ((model() == EMS_DEVICE_FLAG_RC35) || (model() == EMS_DEVICE_FLAG_RC30_1)) { - write_command(timer_typeids[hc->hc_num() - 1], 84, set, timer_typeids[hc->hc_num() - 1]); - } else if ((model() == EMS_DEVICE_FLAG_RC300 || model() == EMS_DEVICE_FLAG_RC100) && (set == 0 || set == 1)) { - write_command(set_typeids[hc->hc_num() - 1], 11, set, set_typeids[hc->hc_num() - 1]); - } - return true; } @@ -2217,7 +2214,7 @@ void Thermostat::register_device_values_hc(std::shared_ptrroominfluence, DeviceValueType::UINT, {}, F("roominfluence"), F("Room influence"), DeviceValueUOM::NONE); register_device_value(hc_name, &hc->nofrosttemp, DeviceValueType::INT, {}, F("nofrosttemp"), F("Nofrost temperature"), DeviceValueUOM::DEGREES); register_device_value(hc_name, &hc->targetflowtemp, DeviceValueType::UINT, {}, F("targetflowtemp"), F("Target flow temperature"), DeviceValueUOM::DEGREES); - register_device_value(hc_name, &hc->heatingtype, DeviceValueType::UINT, {}, F("heatingtype"), F("Heating type"), DeviceValueUOM::NONE); + register_device_value(hc_name, &hc->heatingtype, DeviceValueType::ENUM, {F("off"), F("radiator"), F("convector"), F("floor")}, F("heatingtype"), F("Heating type"), DeviceValueUOM::NONE); register_device_value(hc_name, &hc->summer_setmode, DeviceValueType::ENUM, @@ -2265,7 +2262,7 @@ void Thermostat::register_device_values_hc(std::shared_ptrminflowtemp, DeviceValueType::UINT, {}, F("minflowtemp"), F("Min flow temperature"), DeviceValueUOM::DEGREES); register_device_value(hc_name, &hc->maxflowtemp, DeviceValueType::UINT, {}, F("maxflowtemp"), F("Max flow temperature"), DeviceValueUOM::DEGREES); register_device_value(hc_name, &hc->flowtempoffset, DeviceValueType::UINT, {}, F("flowtempoffset"), F("Flow temperature offset"), DeviceValueUOM::DEGREES); - register_device_value(hc_name, &hc->heatingtype, DeviceValueType::UINT, {}, F("heatingtype"), F("Heating type"), DeviceValueUOM::NONE); + register_device_value(hc_name, &hc->heatingtype, DeviceValueType::ENUM, {F("off"), F("radiator"), F("convector"), F("floor")}, F("heatingtype"), F("Heating type"), DeviceValueUOM::NONE); register_device_value(hc_name, &hc->reducemode, DeviceValueType::ENUM, diff --git a/src/emsesp.cpp b/src/emsesp.cpp index e8fe9d4ea..eb224133d 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -65,6 +65,8 @@ bool EMSESP::tap_water_active_ = false; // for when Boiler states we uint32_t EMSESP::last_fetch_ = 0; uint8_t EMSESP::publish_all_idx_ = 0; uint8_t EMSESP::unique_id_count_ = 0; +bool EMSESP::trace_raw_ = false; +uint64_t EMSESP::tx_delay_ = 0; // for a specific EMS device go and request data values // or if device_id is 0 it will fetch from all our known and active devices @@ -145,7 +147,8 @@ void EMSESP::watch_id(uint16_t watch_id) { void EMSESP::init_tx() { uint8_t tx_mode; EMSESP::webSettingsService.read([&](WebSettings & settings) { - tx_mode = settings.tx_mode; + tx_mode = settings.tx_mode; + tx_delay_ = settings.tx_delay * 1000; #ifndef EMSESP_FORCE_SERIAL EMSuart::stop(); @@ -665,10 +668,10 @@ bool EMSESP::process_telegram(std::shared_ptr telegram) { 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()); - } else { + } else if (!trace_raw_) { LOG_TRACE(pretty_telegram(telegram).c_str()); } - } else { + } else if (!trace_raw_) { LOG_TRACE(pretty_telegram(telegram).c_str()); } @@ -941,8 +944,9 @@ void EMSESP::incoming_telegram(uint8_t * data, const uint8_t length) { tx_successful = true; // if telegram is longer read next part with offset + 25 for ems+ if (length == 32) { - txservice_.read_next_tx(); - read_next_ = true; + if (txservice_.read_next_tx() == read_id_) { + read_next_ = true; + } } } } @@ -956,7 +960,18 @@ void EMSESP::incoming_telegram(uint8_t * data, const uint8_t length) { // check for poll if (length == 1) { - EMSbus::last_bus_activity(uuid::get_uptime()); // set the flag indication the EMS bus is active + static uint64_t delayed_tx_start_ = 0; + if (!rxservice_.bus_connected() && (tx_delay_ > 0)) { + delayed_tx_start_ = uuid::get_uptime_ms(); + LOG_DEBUG(F("Tx delay started")); + } + if ((first_value ^ 0x80 ^ rxservice_.ems_mask()) == txservice_.ems_bus_id()) { + EMSbus::last_bus_activity(uuid::get_uptime()); // set the flag indication the EMS bus is active + } + // first send delayed after connect + if ((uuid::get_uptime_ms() - delayed_tx_start_) < tx_delay_) { + return; + } #ifdef EMSESP_UART_DEBUG char s[4]; diff --git a/src/emsesp.h b/src/emsesp.h index ba2bc05e8..a5ecd3dde 100644 --- a/src/emsesp.h +++ b/src/emsesp.h @@ -66,6 +66,7 @@ #else #define EMSESP_JSON_SIZE_XLARGE_DYN 4096 // for very very large json docs, using DynamicJsonDocument #endif +#define EMSESP_JSON_SIZE_XXLARGE_DYN 5120 // for very very large json docs, using DynamicJsonDocument namespace emsesp { @@ -159,6 +160,14 @@ class EMSESP { tap_water_active_ = tap_water_active; } + static bool trace_raw() { + return trace_raw_; + } + + static void trace_raw(bool set) { + trace_raw_ = set; + } + static void fetch_device_values(const uint8_t device_id = 0); static bool add_device(const uint8_t device_id, const uint8_t product_id, std::string & version, const uint8_t brand); @@ -220,6 +229,8 @@ class EMSESP { static bool tap_water_active_; static uint8_t publish_all_idx_; static uint8_t unique_id_count_; + static bool trace_raw_; + static uint64_t tx_delay_; }; } // namespace emsesp diff --git a/src/mqtt.cpp b/src/mqtt.cpp index 7c692b016..84d039e57 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -231,9 +231,7 @@ void Mqtt::on_message(const char * topic, const char * payload, size_t len) { char message[len + 2]; strlcpy(message, payload, len + 1); -#ifdef EMSESP_DEBUG - LOG_DEBUG(F("[DEBUG] Received %s => %s (length %d)"), topic, message, len); -#endif + LOG_DEBUG(F("Received %s => %s (length %d)"), topic, message, len); // see if we have this topic in our subscription list, then call its callback handler for (const auto & mf : mqtt_subfunctions_) { diff --git a/src/system.cpp b/src/system.cpp index 529fdb965..34316f2bd 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -398,9 +398,11 @@ void System::system_check() { // not healthy if bus not connected if (!EMSbus::bus_connected()) { + if (system_healthy_) { + LOG_ERROR(F("Error: No connection to the EMS bus")); + } system_healthy_ = false; set_led_speed(LED_WARNING_BLINK); // flash every 1/2 second from now on - // LOG_ERROR(F("Error: No connection to the EMS bus")); } else { // if it was unhealthy but now we're better, make sure the LED is solid again cos we've been healed if (!system_healthy_) { diff --git a/src/telegram.cpp b/src/telegram.cpp index 333165510..c25388d67 100644 --- a/src/telegram.cpp +++ b/src/telegram.cpp @@ -197,7 +197,11 @@ void RxService::add(uint8_t * data, uint8_t length) { 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()); + } else if (EMSESP::trace_raw()) { + LOG_TRACE(F("Rx: %s"), Helpers::data_to_hex(data, length).c_str()); } + } else if (EMSESP::trace_raw()) { + LOG_TRACE(F("Rx: %s"), Helpers::data_to_hex(data, length).c_str()); } #ifdef EMSESP_DEBUG @@ -577,10 +581,11 @@ 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); } -void TxService::read_next_tx() { +uint16_t TxService::read_next_tx() { // add to the top of the queue uint8_t message_data[1] = {EMS_MAX_TELEGRAM_LENGTH}; // request all data, 32 bytes add(Telegram::Operation::TX_READ, telegram_last_->dest, telegram_last_->type_id, telegram_last_->offset + 25, message_data, 1, true); + return telegram_last_->type_id; } // checks if a telegram is sent to us matches the last Tx request diff --git a/src/telegram.h b/src/telegram.h index ac2b4d9c2..0d8185180 100644 --- a/src/telegram.h +++ b/src/telegram.h @@ -281,7 +281,7 @@ class TxService : public EMSbus { void retry_tx(const uint8_t operation, const uint8_t * data, const uint8_t length); bool is_last_tx(const uint8_t src, const uint8_t dest) const; uint16_t post_send_query(); - void read_next_tx(); + uint16_t read_next_tx(); uint8_t retry_count() const { return retry_count_;