From 59db38f2619f2aa8f91a03722c0d04164026703d Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Thu, 13 Aug 2020 18:35:54 +0200 Subject: [PATCH] feedback for read-command and set tx_mode, move show mqtt, --- src/console.cpp | 9 ++++++++- src/devices/boiler.cpp | 1 + src/devices/thermostat.cpp | 1 + src/emsesp.cpp | 6 +++++- src/emsesp.h | 4 ++++ src/locale_EN.h | 5 +++-- src/system.cpp | 4 ++-- 7 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/console.cpp b/src/console.cpp index 2776dea91..1f9a95ab5 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -146,6 +146,11 @@ void EMSESPShell::add_console_commands() { flash_string_vector{F_(show), F_(values)}, [](Shell & shell, const std::vector & arguments __attribute__((unused))) { EMSESP::show_device_values(shell); }); + commands->add_command(ShellContext::MAIN, + CommandFlags::USER, + flash_string_vector{F_(show), F_(mqtt)}, + [](Shell & shell, const std::vector & arguments __attribute__((unused))) { Mqtt::show_mqtt(shell); }); + commands->add_command( ShellContext::MAIN, CommandFlags::ADMIN, @@ -186,10 +191,10 @@ void EMSESPShell::add_console_commands() { EMSESP::emsespSettingsService.update( [&](EMSESPSettings & settings) { settings.tx_mode = tx_mode; + shell.printfln(F_(tx_mode_fmt), settings.tx_mode); return StateUpdateResult::CHANGED; }, "local"); - EMSESP::reset_tx(); // reset counters and set tx_mode }); commands->add_command(ShellContext::MAIN, @@ -318,6 +323,8 @@ void Console::load_standard_commands(unsigned int context) { shell.printfln(F_(invalid_log_level)); return; } + } else { + shell.printfln(F_(log_level_list)); } shell.printfln(F_(log_level_fmt), uuid::log::format_level_uppercase(shell.log_level())); }, diff --git a/src/devices/boiler.cpp b/src/devices/boiler.cpp index d5540c261..d36ce20b8 100644 --- a/src/devices/boiler.cpp +++ b/src/devices/boiler.cpp @@ -863,6 +863,7 @@ void Boiler::console_commands(Shell & shell, unsigned int context) { flash_string_vector{F_(typeid_mandatory)}, [=](Shell & shell __attribute__((unused)), const std::vector & arguments) { uint16_t type_id = Helpers::hextoint(arguments.front().c_str()); + EMSESP::set_read_id(type_id); EMSESP::send_read_request(type_id, get_device_id()); }); diff --git a/src/devices/thermostat.cpp b/src/devices/thermostat.cpp index edd7a2ffd..f2faaa09b 100644 --- a/src/devices/thermostat.cpp +++ b/src/devices/thermostat.cpp @@ -1130,6 +1130,7 @@ void Thermostat::console_commands(Shell & shell, unsigned int context) { flash_string_vector{F_(typeid_mandatory)}, [=](Shell & shell __attribute__((unused)), const std::vector & arguments) { uint16_t type_id = Helpers::hextoint(arguments.front().c_str()); + EMSESP::set_read_id(type_id); EMSESP::send_read_request(type_id, this->get_device_id()); }); diff --git a/src/emsesp.cpp b/src/emsesp.cpp index 4d8396970..eba2da9c8 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -57,6 +57,7 @@ Shower EMSESP::shower_; // Shower logic uint8_t EMSESP::actual_master_thermostat_ = EMSESP_DEFAULT_MASTER_THERMOSTAT; // which thermostat leads when multiple found uint16_t EMSESP::watch_id_ = WATCH_ID_NONE; // for when log is TRACE. 0 means no trace set uint8_t EMSESP::watch_ = 0; // trace off +uint16_t EMSESP::read_id_ = WATCH_ID_NONE; bool EMSESP::tap_water_active_ = false; // for when Boiler states we having running warm water. used in Shower() uint32_t EMSESP::last_fetch_ = 0; uint8_t EMSESP::unique_id_count_ = 0; @@ -467,7 +468,10 @@ void EMSESP::process_version(std::shared_ptr telegram) { // returns false if there are none found bool EMSESP::process_telegram(std::shared_ptr telegram) { // if watching... - if (watch() == WATCH_ON) { + if (telegram->type_id == read_id_) { + 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_)) { LOG_NOTICE(pretty_telegram(telegram).c_str()); } diff --git a/src/emsesp.h b/src/emsesp.h index 96c04f335..18bda872f 100644 --- a/src/emsesp.h +++ b/src/emsesp.h @@ -123,6 +123,9 @@ class EMSESP { static uint8_t watch() { return watch_; } + static void set_read_id(uint16_t id) { + read_id_ = id; + } enum Bus_status : uint8_t { BUS_STATUS_CONNECTED = 0, BUS_STATUS_TX_ERRORS, BUS_STATUS_OFFLINE }; static uint8_t bus_status(); @@ -187,6 +190,7 @@ class EMSESP { static uint8_t actual_master_thermostat_; static uint16_t watch_id_; static uint8_t watch_; + static uint16_t read_id_; static bool tap_water_active_; static uint8_t unique_id_count_; diff --git a/src/locale_EN.h b/src/locale_EN.h index 37ebc810a..d3cf2e1d0 100644 --- a/src/locale_EN.h +++ b/src/locale_EN.h @@ -87,8 +87,8 @@ MAKE_PSTR(hc_optional, "[heating circuit]") MAKE_PSTR(master_thermostat_fmt, "Master Thermostat Device ID = %s") MAKE_PSTR(host_fmt, "Host = %s") MAKE_PSTR(hostname_fmt, "WiFi Hostname = %s") -MAKE_PSTR(mark_interval_fmt, "Mark interval = %lus"); -MAKE_PSTR(wifi_ssid_fmt, "WiFi SSID = %s"); +MAKE_PSTR(mark_interval_fmt, "Mark interval = %lus") +MAKE_PSTR(wifi_ssid_fmt, "WiFi SSID = %s") MAKE_PSTR(wifi_password_fmt, "WiFi Password = %S") MAKE_PSTR(system_heartbeat_fmt, "MQTT Heartbeat is %s") MAKE_PSTR(cmd_optional, "[cmd]") @@ -110,6 +110,7 @@ MAKE_PSTR(typeid_mandatory, "") MAKE_PSTR(deviceid_mandatory, "") MAKE_PSTR(deviceid_optional, "[device ID]") MAKE_PSTR(invalid_log_level, "Invalid log level") +MAKE_PSTR(log_level_list,"OFF EMERG ALERT CRIT ERR WARNING NOTICE INFO DEBUG TRACE ALL") MAKE_PSTR(log_level_fmt, "Log level = %s") MAKE_PSTR(log_level_optional, "[level]") MAKE_PSTR(name_mandatory, "") diff --git a/src/system.cpp b/src/system.cpp index 85c5db7c6..5a439a196 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -554,12 +554,12 @@ void System::console_commands(Shell & shell, unsigned int context) { shell.printfln(F_(wifi_password_fmt), wifiSettings.ssid.isEmpty() ? F_(unset) : F_(asterisks)); }); }); - +/* EMSESPShell::commands->add_command(ShellContext::SYSTEM, CommandFlags::USER, flash_string_vector{F_(show), F_(mqtt)}, [](Shell & shell, const std::vector & arguments __attribute__((unused))) { Mqtt::show_mqtt(shell); }); - +*/ EMSESPShell::commands->add_command(ShellContext::SYSTEM, CommandFlags::ADMIN, flash_string_vector{F_(show), F_(users)},