From 3ab7134ca0eb19b3d376105b9c302aedda4aacf8 Mon Sep 17 00:00:00 2001 From: proddy Date: Tue, 28 Jul 2020 11:52:23 +0200 Subject: [PATCH] reset_tx() takes tx_mode from settings file --- src/console.cpp | 5 +---- src/emsesp.cpp | 11 +++++++---- src/emsesp.h | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/console.cpp b/src/console.cpp index 830af193d..a4ede0465 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -110,8 +110,6 @@ void EMSESPShell::add_console_commands() { flash_string_vector{F_(fetch)}, [&](Shell & shell, const std::vector & arguments __attribute__((unused))) { shell.printfln(F("Requesting data from EMS devices")); - console_commands_loaded_ = false; - add_console_commands(); EMSESP::fetch_device_values(); }); @@ -184,7 +182,7 @@ void EMSESPShell::add_console_commands() { return StateUpdateResult::CHANGED; }, "local"); - EMSESP::reset_tx(tx_mode); // reset counters and set tx_mode + EMSESP::reset_tx(); // reset counters and set tx_mode }); commands->add_command(ShellContext::MAIN, @@ -515,7 +513,6 @@ void Console::start() { shell = std::make_shared(serial_console_, true); shell->maximum_log_messages(100); // default is 50 shell->start(); - // shell->log_level(uuid::log::Level::DEBUG); // order is: err, warning, notice, info, debug, trace, all #endif #if defined(EMSESP_DEBUG) diff --git a/src/emsesp.cpp b/src/emsesp.cpp index a0f55df89..e779cbcf4 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -110,13 +110,16 @@ void EMSESP::watch_id(uint16_t watch_id) { // change the tx_mode // resets all counters and bumps the UART -void EMSESP::reset_tx(uint8_t const tx_mode) { - EMSuart::stop(); +void EMSESP::reset_tx() { + // get the tx_mode + uint8_t tx_mode; + EMSESP::emsespSettingsService.read([&](EMSESPSettings & settings) { tx_mode = settings.tx_mode; }); + EMSuart::stop(); + EMSuart::start(tx_mode); txservice_.start(); - EMSuart::start(tx_mode); - + // force a fetch for all new values, unless Tx is set to off if (tx_mode != 0) { EMSESP::fetch_device_values(); } diff --git a/src/emsesp.h b/src/emsesp.h index 28d62c860..e22633f88 100644 --- a/src/emsesp.h +++ b/src/emsesp.h @@ -96,7 +96,7 @@ class EMSESP { static void add_context_menus(); - static void reset_tx(uint8_t const tx_mode); + static void reset_tx(); static void incoming_telegram(uint8_t * data, const uint8_t length);