diff --git a/CHANGELOG_LATEST.md b/CHANGELOG_LATEST.md index 4f8736371..91bc9e8cf 100644 --- a/CHANGELOG_LATEST.md +++ b/CHANGELOG_LATEST.md @@ -40,6 +40,7 @@ For more details go to [docs.emsesp.org](https://docs.emsesp.org/). - added RTL8201 to eth phy list [#2800](https://github.com/emsesp/EMS-ESP32/issues/2800) - added partitions to Web UI Version page, so previous firmware versions can be installed [#2837](https://github.com/emsesp/EMS-ESP32/issues/2837) - button pressures show LED. On a long press (10 seconds) the LED flashes for 5 seconds to indicate a factory reset is about to happen. [#2848](https://github.com/emsesp/EMS-ESP32/issues/2848) +- added `txpause` command to pause the TX, by setting Txmode to 0 (disabled) [#2850](https://github.com/emsesp/EMS-ESP32/issues/2850) ## Fixed diff --git a/src/core/system.cpp b/src/core/system.cpp index 736351b46..b2ab4de79 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -1047,7 +1047,7 @@ void System::commands_init() { Command::add(EMSdevice::DeviceType::SYSTEM, F_(fetch), System::command_fetch, FL_(fetch_cmd), CommandFlag::ADMIN_ONLY); Command::add(EMSdevice::DeviceType::SYSTEM, F_(restart), System::command_restart, FL_(restart_cmd), CommandFlag::ADMIN_ONLY); Command::add(EMSdevice::DeviceType::SYSTEM, F_(format), System::command_format, FL_(format_cmd), CommandFlag::ADMIN_ONLY); - Command::add(EMSdevice::DeviceType::SYSTEM, F_(txenabled), System::command_txenabled, FL_(txenabled_cmd), CommandFlag::ADMIN_ONLY); + Command::add(EMSdevice::DeviceType::SYSTEM, F_(txpause), System::command_txpause, FL_(txpause_cmd), CommandFlag::ADMIN_ONLY); Command::add(EMSdevice::DeviceType::SYSTEM, F_(watch), System::command_watch, FL_(watch_cmd)); Command::add(EMSdevice::DeviceType::SYSTEM, F_(message), System::command_message, FL_(message_cmd)); #if defined(EMSESP_TEST) @@ -1107,9 +1107,8 @@ void System::led_monitor() { } else if (led_flash_step_ % 2) { // handle the step events (on odd numbers 3,5,7,etc). see if we need to turn on a LED // 1 flash (blue) is the EMS bus is not connected - // 2 flashes (red) if the network (wifi or ethernet) is not connected + // 2 flashes (red, red) if the network (wifi or ethernet) is not connected // 3 flashes (red, red, blue) is both the bus and the network are not connected - bool no_network = (healthcheck_ & HEALTHCHECK_NO_NETWORK) == HEALTHCHECK_NO_NETWORK; bool no_bus = (healthcheck_ & HEALTHCHECK_NO_BUS) == HEALTHCHECK_NO_BUS; @@ -2435,27 +2434,34 @@ bool System::load_board_profile(std::vector & data, const std::string & return true; } -// txenabled command - temporarily pause the TX, setting Txmode to 0 -bool System::command_txenabled(const char * value, const int8_t id) { +// txpause command - temporarily pause the TX, by setting Txmode to 0 (disabled) +bool System::command_txpause(const char * value, const int8_t id) { bool arg; if (!Helpers::value2bool(value, arg)) { return false; // argument not recognized } - if (arg) { - // Tx mode on - // if the TX mode was off, revert back to the saved setting + if (!arg) { + // arg = false: Tx mode to 0 (disabled) to pause if (EMSbus::tx_mode() == EMS_TXMODE_OFF) { EMSESP::webSettingsService.read([&](WebSettings & settings) { EMSbus::tx_mode(settings.tx_mode); +#ifdef EMSESP_DEBUG LOG_INFO("TX mode restored (value %d)", settings.tx_mode); +#else + LOG_INFO("TX active"); +#endif }); } } else { - // Tx mode off + // pause = true: Tx mode to 0 (disabled) to pause if (EMSbus::tx_mode() != EMS_TXMODE_OFF) { EMSbus::tx_mode(EMS_TXMODE_OFF); +#ifdef EMSESP_DEBUG LOG_INFO("TX mode set to OFF (value %d)", EMS_TXMODE_OFF); +#else + LOG_INFO("TX paused"); +#endif } } return true; diff --git a/src/core/system.h b/src/core/system.h index aa5995978..91ee58722 100644 --- a/src/core/system.h +++ b/src/core/system.h @@ -103,7 +103,7 @@ class System { static bool command_info(const char * value, const int8_t id, JsonObject output); static bool command_response(const char * value, const int8_t id, JsonObject output); static bool command_service(const char * cmd, const char * value); - static bool command_txenabled(const char * value, const int8_t id); + static bool command_txpause(const char * value, const int8_t id); static bool get_value_info(JsonObject root, const char * cmd); static void get_value_json(JsonObject output, const std::string & circuit, const std::string & name, JsonVariant val); diff --git a/test/test_api/api_test.http b/test/test_api/api_test.http index 3192cb5ae..1a37372bc 100755 --- a/test/test_api/api_test.http +++ b/test/test_api/api_test.http @@ -145,7 +145,7 @@ Authorization: Bearer {{token}} ### -POST {{host_dev}}/api/system/txenabled +POST {{host_dev}}/api/system/txpause Content-Type: application/json Authorization: Bearer {{token}} @@ -155,7 +155,7 @@ Authorization: Bearer {{token}} ### -POST {{host_dev}}/api/system/txenabled +POST {{host_dev}}/api/system/txpause Content-Type: application/json Authorization: Bearer {{token}}