diff --git a/src/devices/boiler.cpp b/src/devices/boiler.cpp index 522c9743c..82ff00998 100644 --- a/src/devices/boiler.cpp +++ b/src/devices/boiler.cpp @@ -736,6 +736,8 @@ void Boiler::show_values(uuid::console::Shell & shell) { shell.println(); return; } + + // ww print_value_json(shell, F("wWSelTemp"), nullptr, F_(wWSelTemp), F_(degrees), json); print_value_json(shell, F("wWSetTemp"), nullptr, F_(wWSetTemp), F_(degrees), json); print_value_json(shell, F("wWDisinfectionTemp"), nullptr, F_(wWDisinfectionTemp), F_(degrees), json); diff --git a/src/devices/connect.cpp b/src/devices/connect.cpp index 99f8510f9..25937441c 100644 --- a/src/devices/connect.cpp +++ b/src/devices/connect.cpp @@ -33,7 +33,7 @@ void Connect::device_info_web(JsonArray & root) { // display all values into the shell console void Connect::show_values(uuid::console::Shell & shell) { - // EMSdevice::show_values(shell); // always call this to show header + EMSdevice::show_values(shell); // always call this to show header } // publish values via MQTT diff --git a/src/devices/controller.cpp b/src/devices/controller.cpp index 6adb7c050..4899d5cb3 100644 --- a/src/devices/controller.cpp +++ b/src/devices/controller.cpp @@ -33,7 +33,7 @@ void Controller::device_info_web(JsonArray & root) { // display all values into the shell console void Controller::show_values(uuid::console::Shell & shell) { - // EMSdevice::show_values(shell); // always call this to show header + EMSdevice::show_values(shell); // always call this to show header } // publish values via MQTT diff --git a/src/devices/generic.cpp b/src/devices/generic.cpp index 7f29d3e78..a212677d9 100644 --- a/src/devices/generic.cpp +++ b/src/devices/generic.cpp @@ -33,7 +33,7 @@ void Generic::device_info_web(JsonArray & root) { // display all values into the shell console void Generic::show_values(uuid::console::Shell & shell) { - // EMSdevice::show_values(shell); // always call this to show header + EMSdevice::show_values(shell); // always call this to show header } // publish values via MQTT diff --git a/src/devices/switch.cpp b/src/devices/switch.cpp index 60ca552a2..8c40e8ddc 100644 --- a/src/devices/switch.cpp +++ b/src/devices/switch.cpp @@ -34,8 +34,8 @@ Switch::Switch(uint8_t device_type, uint8_t device_id, uint8_t product_id, const register_telegram_type(0x9B, F("WM10SetMessage"), false, [&](std::shared_ptr t) { process_WM10SetMessage(t); }); } +// fetch the values into a JSON document for display in the web void Switch::device_info_web(JsonArray & root) { - // fetch the values into a JSON document StaticJsonDocument doc; JsonObject json = doc.to(); if (export_values(json)) { @@ -47,8 +47,6 @@ void Switch::device_info_web(JsonArray & root) { // display all values into the shell console void Switch::show_values(uuid::console::Shell & shell) { - // EMSdevice::show_values(shell); // always call this to show header - // fetch the values into a JSON document StaticJsonDocument doc; JsonObject json = doc.to(); if (export_values(json)) { @@ -66,6 +64,7 @@ void Switch::publish_values(JsonObject & json, bool force) { return; } } + StaticJsonDocument doc; JsonObject json_data = doc.to(); if (export_values(json_data)) { diff --git a/src/emsdevice.cpp b/src/emsdevice.cpp index a356057c4..5466aaa54 100644 --- a/src/emsdevice.cpp +++ b/src/emsdevice.cpp @@ -413,7 +413,7 @@ void EMSdevice::print_value_json(uuid::console::Shell & shell, shell.println(); } -// print value to shell from the json doc into a name/value pair +// create json key/value pair void EMSdevice::print_value_json(JsonArray & root, const __FlashStringHelper * key, const __FlashStringHelper * prefix, diff --git a/src/emsesp.cpp b/src/emsesp.cpp index 64070b4be..3279baf38 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -108,9 +108,9 @@ void EMSESP::scan_devices() { * we send to right device and match all reads to 0x18 */ uint8_t EMSESP::check_master_device(const uint8_t device_id, const uint16_t type_id, const bool read) { - uint16_t mon_id[4] = {0x02A5, 0x02A6, 0x02A7, 0x02A8}; - uint16_t set_id[4] = {0x02B9, 0x02BA, 0x02BB, 0x02BC}; if (actual_master_thermostat_ == 0x18) { + uint16_t mon_id[4] = {0x02A5, 0x02A6, 0x02A7, 0x02A8}; + uint16_t set_id[4] = {0x02B9, 0x02BA, 0x02BB, 0x02BC}; for (uint8_t i = 0; i < 4; i++) { if (type_id == mon_id[i] || type_id == set_id[i]) { if (read) { @@ -121,6 +121,7 @@ uint8_t EMSESP::check_master_device(const uint8_t device_id, const uint16_t type } } } + return device_id; } diff --git a/src/helpers.cpp b/src/helpers.cpp index c63831402..2507fcbf6 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -82,7 +82,7 @@ char * Helpers::itoa(char * result, int32_t value, const uint8_t base) { return result; } - char * ptr = result, *ptr1 = result, tmp_char; + char * ptr = result, *ptr1 = result; int16_t tmp_value; do { @@ -97,6 +97,7 @@ char * Helpers::itoa(char * result, int32_t value, const uint8_t base) { } *ptr-- = '\0'; + char tmp_char; while (ptr1 < ptr) { tmp_char = *ptr; *ptr-- = *ptr1; @@ -136,7 +137,7 @@ char * Helpers::render_boolean(char * result, bool value) { } // depending on format render a number or a string -char * Helpers::render_enum(char * result, const std::vector value, const uint8_t no) { +char * Helpers::render_enum(char * result, const std::vector &value, const uint8_t no) { if (no >= value.size()) { return nullptr; // out of bounds } @@ -459,7 +460,7 @@ bool Helpers::value2bool(const char * v, bool & value) { } // checks to see if a string is member of a vector and return the index, also allow true/false for on/off -bool Helpers::value2enum(const char * v, uint8_t & value, const std::vector strs) { +bool Helpers::value2enum(const char * v, uint8_t & value, const std::vector &strs) { if ((v == nullptr) || (strlen(v) == 0)) { return false; } diff --git a/src/helpers.h b/src/helpers.h index 8573d5797..b20c3771c 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -40,7 +40,7 @@ class Helpers { static char * render_value(char * result, const int16_t value, const uint8_t format); static char * render_value(char * result, const char * value, uint8_t format); static char * render_boolean(char * result, bool value); - static char * render_enum(char * result, const std::vector value, const uint8_t no); + static char * render_enum(char * result, const std::vector & value, const uint8_t no); static char * hextoa(char * result, const uint8_t value); static std::string data_to_hex(const uint8_t * data, const uint8_t length); @@ -63,7 +63,7 @@ class Helpers { static bool value2float(const char * v, float & value); static bool value2bool(const char * v, bool & value); static bool value2string(const char * v, std::string & value); - static bool value2enum(const char * v, uint8_t & value, const std::vector strs); + static bool value2enum(const char * v, uint8_t & value, const std::vector & strs); static void bool_format(uint8_t bool_format) { bool_format_ = bool_format; diff --git a/src/system.cpp b/src/system.cpp index 508f06cd6..f6a35a64e 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -434,14 +434,13 @@ void System::led_monitor() { // Low quality: 30% ~= -85dBm // Unusable quality: 8% ~= -96dBm int8_t System::wifi_quality() { -#ifndef EMSESP_STANDALONE +#ifdef EMSESP_STANDALONE + return 100; +#else if (WiFi.status() != WL_CONNECTED) { return -1; } int32_t dBm = WiFi.RSSI(); -#else - int32_t dBm = -70; -#endif if (dBm <= -100) { return 0; } @@ -450,6 +449,7 @@ int8_t System::wifi_quality() { return 100; } return 2 * (dBm + 100); +#endif } // print users to console @@ -750,9 +750,9 @@ bool System::check_upgrade() { Serial.begin(115200); - bool failed = false; - File file; - JsonObject network, general, mqtt, custom_settings; + bool failed = false; + File file; + JsonObject network, general, mqtt, custom_settings; StaticJsonDocument doc; // open the system settings: diff --git a/src/uart/emsuart_esp8266.cpp b/src/uart/emsuart_esp8266.cpp index 67a40b872..d73cb1b4d 100644 --- a/src/uart/emsuart_esp8266.cpp +++ b/src/uart/emsuart_esp8266.cpp @@ -41,7 +41,6 @@ bool EMSuart::sending_ = false; // Important: must not use ICACHE_FLASH_ATTR // void ICACHE_RAM_ATTR EMSuart::emsuart_rx_intr_handler(void * para) { - static uint8_t length = 0; static uint8_t uart_buffer[EMS_MAXBUFFERSIZE + 2]; if (USIS(EMSUART_UART) & ((1 << UIBD))) { // BREAK detection = End of EMS data block @@ -49,8 +48,10 @@ void ICACHE_RAM_ATTR EMSuart::emsuart_rx_intr_handler(void * para) { if (sending_) { // irq tx_mode is interrupted by , should never happen drop_next_rx = true; // we have trash in buffer } - USIC(EMSUART_UART) = (1 << UIBD); // INT clear the BREAK detect interrupt - length = 0; + + USIC(EMSUART_UART) = (1 << UIBD); // INT clear the BREAK detect interrupt + static uint8_t length = 0; + while ((USS(EMSUART_UART) >> USRXC) & 0x0FF) { // read fifo into buffer uint8_t rx = USF(EMSUART_UART); if (length < EMS_MAXBUFFERSIZE) { @@ -61,14 +62,17 @@ void ICACHE_RAM_ATTR EMSuart::emsuart_rx_intr_handler(void * para) { drop_next_rx = true; } } + if (!drop_next_rx) { if (uart_buffer[length - 1]) { // check if last byte is break length++; } + pEMSRxBuf->length = length; os_memcpy((void *)pEMSRxBuf->buffer, (void *)&uart_buffer, pEMSRxBuf->length); // copy data into transfer buffer, including the BRK 0x00 at the end system_os_post(EMSUART_recvTaskPrio, 0, 0); // call emsuart_recvTask() at next opportunity } + drop_next_rx = false; sending_ = false; }