diff --git a/makefile b/makefile index af6c3082b..c7e1da373 100644 --- a/makefile +++ b/makefile @@ -26,7 +26,7 @@ CXX_STANDARD := -std=c++11 #---------------------------------------------------------------------- # Defined Symbols #---------------------------------------------------------------------- -DEFINES += -DARDUINOJSON_ENABLE_STD_STRING=1 -DARDUINOJSON_ENABLE_ARDUINO_STRING -DEMSESP_DEBUG -DEMSESP_STANDALONE +DEFINES += -DARDUINOJSON_ENABLE_STD_STRING=1 -DARDUINOJSON_ENABLE_ARDUINO_STRING -DEMSESP_DEBUG -DEMSESP_STANDALONE -DEMSESP_TEST #---------------------------------------------------------------------- # Sources & Files diff --git a/platformio.ini b/platformio.ini index a5d8af090..051069d01 100644 --- a/platformio.ini +++ b/platformio.ini @@ -13,6 +13,7 @@ extra_configs = debug_flags = ; -D EMSESP_DEBUG ; -D EMSESP_UART_DEBUG + ; -D EMSESP_TEST ; -D EMSESP_FORCE_SERIAL ; -D ENABLE_CORS diff --git a/src/console.cpp b/src/console.cpp index 4e39942dd..ef81ffc88 100644 --- a/src/console.cpp +++ b/src/console.cpp @@ -20,7 +20,9 @@ #include "emsesp.h" #include "version.h" +#if defined(EMSESP_TEST) #include "test/test.h" +#endif namespace emsesp { @@ -426,11 +428,7 @@ void EMSESPShell::add_console_commands() { return {}; }); - /* - * add all the submenu contexts... - */ - - // System + // System context menu commands->add_command(ShellContext::MAIN, CommandFlags::USER, flash_string_vector{F_(system)}, @@ -471,26 +469,22 @@ void Console::enter_custom_context(Shell & shell, unsigned int context) { // each custom context has the common commands like log, help, exit, su etc void Console::load_standard_commands(unsigned int context) { -#if defined(EMSESP_DEBUG) +#if defined(EMSESP_TEST) EMSESPShell::commands->add_command(context, CommandFlags::USER, - flash_string_vector{F("test")}, + flash_string_vector{F_(test)}, flash_string_vector{F_(name_optional)}, [](Shell & shell, const std::vector & arguments) { if (arguments.size() == 0) { - Test::run_test(shell, "default"); + Test::run_test_shell(shell, "default"); } else { - Test::run_test(shell, arguments.front()); + Test::run_test_shell(shell, arguments.front()); } }); - EMSESPShell::commands->add_command(context, - CommandFlags::USER, - flash_string_vector{F("t")}, - [](Shell & shell, const std::vector & arguments __attribute__((unused))) { - Test::run_test(shell, "default"); - }); #endif + + EMSESPShell::commands->add_command( context, CommandFlags::USER, diff --git a/src/locale_EN.h b/src/locale_EN.h index b7abe921e..128809a94 100644 --- a/src/locale_EN.h +++ b/src/locale_EN.h @@ -78,6 +78,7 @@ MAKE_PSTR_WORD(command) MAKE_PSTR_WORD(commands) MAKE_PSTR_WORD(info) MAKE_PSTR_WORD(report) +MAKE_PSTR_WORD(test) // devices MAKE_PSTR_WORD(boiler) diff --git a/src/system.cpp b/src/system.cpp index c89b4ca88..072426316 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -21,6 +21,10 @@ #include "version.h" // firmware version of EMS-ESP +#if defined(EMSESP_TEST) +#include "test/test.h" +#endif + namespace emsesp { uuid::log::Logger System::logger_{F_(system), uuid::log::Facility::KERN}; @@ -47,7 +51,12 @@ String System::syslog_host_; // send on/off to a gpio pin // value: true = HIGH, false = LOW +// http://ems-esp/api?device=system&cmd=pin&data=1&id=2 bool System::command_pin(const char * value, const int8_t id) { + if (id < 0) { + return false; + } + bool v = false; if (Helpers::value2bool(value, v)) { pinMode(id, OUTPUT); @@ -191,6 +200,10 @@ void System::start() { Command::add(EMSdevice::DeviceType::SYSTEM, settings.ems_bus_id, F_(fetch), System::command_fetch); Command::add_with_json(EMSdevice::DeviceType::SYSTEM, F_(info), System::command_info); Command::add_with_json(EMSdevice::DeviceType::SYSTEM, F_(report), System::command_report); + +#if defined(EMSESP_TEST) + Command::add(EMSdevice::DeviceType::SYSTEM, settings.ems_bus_id, F_(test), System::command_test); +#endif }); @@ -274,7 +287,6 @@ void System::loop() { #endif #endif - } void System::show_mem(const char * note) { @@ -1073,4 +1085,13 @@ bool System::command_report(const char * value, const int8_t id, JsonObject & js return true; } +#if defined(EMSESP_TEST) +// run a test +// e.g. http://ems-esp/api?device=system&cmd=test&data=boiler +bool System::command_test(const char * value, const int8_t id) { + Test::run_test(value, id); + return true; +} +#endif + } // namespace emsesp diff --git a/src/system.h b/src/system.h index 0af8a8aae..7a5caad02 100644 --- a/src/system.h +++ b/src/system.h @@ -55,6 +55,10 @@ class System { static bool command_info(const char * value, const int8_t id, JsonObject & json); static bool command_report(const char * value, const int8_t id, JsonObject & json); +#if defined(EMSESP_TEST) + static bool command_test(const char * value, const int8_t id); +#endif + static uint8_t free_mem(); static void upload_status(bool in_progress); static bool upload_status(); diff --git a/src/test/test.cpp b/src/test/test.cpp index f0801dbb9..c1bce5695 100644 --- a/src/test/test.cpp +++ b/src/test/test.cpp @@ -17,24 +17,140 @@ * along with this program. If not, see . */ -#if defined(EMSESP_DEBUG) +#if defined(EMSESP_TEST) #include "test.h" +// create some fake test data + namespace emsesp { -// create some fake test data +// no shell +void Test::run_test(const char * command, int8_t id) { + if ((command == nullptr) || (strlen(command) == 0)) { + return; + } + + if (strcmp(command, "general") == 0) { + EMSESP::logger().info(F("Testing general...")); + + add_device(0x08, 123); // Nefit Trendline + add_device(0x18, 157); // Bosch CR100 + + // add some data + // Boiler -> Me, UBAMonitorFast(0x18), telegram: 08 00 18 00 00 02 5A 73 3D 0A 10 65 40 02 1A 80 00 01 E1 01 76 0E 3D 48 00 C9 44 02 00 (#data=25) + uart_telegram({0x08, 0x00, 0x18, 0x00, 0x00, 0x02, 0x5A, 0x73, 0x3D, 0x0A, 0x10, 0x65, 0x40, 0x02, 0x1A, + 0x80, 0x00, 0x01, 0xE1, 0x01, 0x76, 0x0E, 0x3D, 0x48, 0x00, 0xC9, 0x44, 0x02, 0x00}); + + // Boiler -> Thermostat, UBAParameterWW(0x33), telegram: 08 97 33 00 23 24 (#data=2) + uart_telegram({0x08, 0x98, 0x33, 0x00, 0x23, 0x24}); + + // Boiler -> Me, UBAParameterWW(0x33), telegram: 08 0B 33 00 08 FF 34 FB 00 28 00 00 46 00 FF FF 00 (#data=13) + uart_telegram({0x08, 0x0B, 0x33, 0x00, 0x08, 0xFF, 0x34, 0xFB, 0x00, 0x28, 0x00, 0x00, 0x46, 0x00, 0xFF, 0xFF, 0x00}); + + // Thermostat RCPLUSStatusMessage_HC1(0x01A5) + uart_telegram({0x98, 0x00, 0xFF, 0x00, 0x01, 0xA5, 0x00, 0xCF, 0x21, 0x2E, 0x00, 0x00, 0x2E, 0x24, + 0x03, 0x25, 0x03, 0x03, 0x01, 0x03, 0x25, 0x00, 0xC8, 0x00, 0x00, 0x11, 0x01, 0x03}); + + return; + } + + if (strcmp(command, "gateway") == 0) { + EMSESP::logger().info(F("Testing gateway...")); + + // add 0x48 KM200, via a version command + rx_telegram({0x48, 0x0B, 0x02, 0x00, 0xBD, 0x04, 0x06, 00, 00, 00, 00, 00, 00, 00}); + + // Boiler(0x08) -> All(0x00), UBADevices(0x07), data: 09 01 00 00 00 00 00 00 01 00 00 00 00 + // check: make sure 0x48 is not detected again ! + rx_telegram({0x08, 0x00, 0x07, 0x00, 0x09, 01, 00, 00, 00, 00, 00, 00, 01, 00, 00, 00, 00}); + + // add thermostat - Thermostat: RC300/RC310/Moduline 3000/CW400/Sense II (DeviceID:0x10, ProductID:158, Version:03.03) ** master device ** + add_device(0x10, 158); // Nefit Trendline + + // simulate incoming telegram + // Thermostat(0x10) -> 48(0x48), ?(0x26B), data: 6B 08 4F 00 00 00 02 00 00 00 02 00 03 00 03 00 03 + rx_telegram({0x10, 0x48, 0xFF, 00, 01, 0x6B, 00, 0x6B, 0x08, 0x4F, 00, 00, 00, 02, 00, 00, 00, 02, 00, 03, 00, 03, 00, 03}); + + return; + } + + if (strcmp(command, "boiler") == 0) { + // EMSESP::logger().info(F("Testing boiler...")); + add_device(0x08, 123); // Nefit Trendline + + // UBAuptime + uart_telegram({0x08, 0x0B, 0x14, 00, 0x3C, 0x1F, 0xAC, 0x70}); + + return; + } + + if (strcmp(command, "thermostat") == 0) { + EMSESP::logger().info(F("Testing thermostat...")); + add_device(0x10, 192); // FW120 + + // HC1 + uart_telegram({0x90, 0x00, 0xFF, 0x00, 0x00, 0x6F, 0x00, 0xCF, 0x21, 0x2E, 0x20, 0x00, 0x2E, 0x24, + 0x03, 0x25, 0x03, 0x03, 0x01, 0x03, 0x25, 0x00, 0xC8, 0x00, 0x00, 0x11, 0x01, 0x03}); + + // HC2 + uart_telegram({0x90, 0x00, 0xFF, 0x00, 0x00, 0x70, 0x00, 0xCF, 0x22, 0x2F, 0x10, 0x00, 0x2E, 0x24, + 0x03, 0x25, 0x03, 0x03, 0x01, 0x03, 0x25, 0x00, 0xC8, 0x00, 0x00, 0x11, 0x01, 0x03}); + + // HC3 + uart_telegram({0x90, 0x00, 0xFF, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}); + + return; + } + + if (strcmp(command, "solar") == 0) { + EMSESP::logger().info(F("Testing solar...")); + EMSESP::rxservice_.ems_mask(EMSbus::EMS_MASK_BUDERUS); + + add_device(0x30, 163); // SM100 + + // SM100Monitor - type 0x0362 EMS+ - for SM100 and SM200 + // B0 0B FF 00 02 62 00 44 02 7A 80 00 80 00 80 00 80 00 80 00 80 00 00 7C 80 00 80 00 80 00 80 + rx_telegram({0xB0, 0x0B, 0xFF, 00, 0x02, 0x62, 00, 0x44, 0x02, 0x7A, 0x80, 00, 0x80, 0x00, 0x80, 00, + 0x80, 00, 0x80, 00, 0x80, 00, 00, 0x7C, 0x80, 00, 0x80, 00, 0x80, 00, 0x80}); + + rx_telegram({0xB0, 0x0B, 0xFF, 0x00, 0x02, 0x62, 0x01, 0x44, 0x03, 0x30, 0x80, 00, 0x80, 00, 0x80, 00, + 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 0x33}); + + rx_telegram({0xB0, 00, 0xFF, 0x18, 02, 0x62, 0x80, 00, 0xB8}); + + EMSESP::send_raw_telegram("B0 00 FF 18 02 62 80 00 B8"); + + return; + } + + if (strcmp(command, "heatpump") == 0) { + EMSESP::logger().info(F("Testing heatpump...")); + EMSESP::rxservice_.ems_mask(EMSbus::EMS_MASK_BUDERUS); + add_device(0x38, 200); // Enviline module + add_device(0x10, 192); // FW120 thermostat + + uart_telegram({0x90, 0x00, 0xFF, 0x00, 0x00, 0x6F, 0x00, 0xCF, 0x21, 0x2E, 0x20, 0x00, 0x2E, 0x24, + 0x03, 0x25, 0x03, 0x03, 0x01, 0x03, 0x25, 0x00, 0xC8, 0x00, 0x00, 0x11, 0x01, 0x03}); // HC1 + + uart_telegram("38 0B FF 00 03 7B 0C 34 00 74"); + + return; + } +} + // used with the 'test' command, under su/admin -void Test::run_test(uuid::console::Shell & shell, const std::string & command) { +void Test::run_test_shell(uuid::console::Shell & shell, const std::string & command) { // switch to su shell.add_flags(CommandFlags::ADMIN); - if (command == "default") { - run_test(shell, "general"); // add the default test case here - } - - if (command.empty()) { - run_test(shell, "default"); + if ((command == "default") || (command == "general") || (command.empty())) { + shell.printfln(F("Testing adding a general boiler & thermostat...")); + run_test("general"); + shell.invoke_command("show devices"); + shell.invoke_command("show"); + shell.invoke_command("call system publish"); + shell.invoke_command("show mqtt"); } if (command == "render") { @@ -139,8 +255,6 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { EMSESP::rxservice_.ems_mask(EMSbus::EMS_MASK_BUDERUS); // this is important otherwise nothing will be picked up! - //emsdevices.push_back(EMSFactory::add(EMSdevice::DeviceType::BOILER, EMSdevice::EMS_DEVICE_ID_BOILER, 0, "", "My Boiler", 0, 0)); - // A fake response - UBADevices(0x07) rx_telegram({0x08, 0x00, 0x07, 0x00, 0x0B, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}); } @@ -160,9 +274,6 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { if (command == "unknown") { shell.printfln(F("Testing unknown...")); - // question: do we need to set the mask? - std::string version("1.2.3"); - // add boiler add_device(0x08, 84); @@ -186,20 +297,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { if (command == "gateway") { shell.printfln(F("Testing Gateway...")); - - // add 0x48 KM200, via a version command - rx_telegram({0x48, 0x0B, 0x02, 0x00, 0xBD, 0x04, 0x06, 00, 00, 00, 00, 00, 00, 00}); - - // Boiler(0x08) -> All(0x00), UBADevices(0x07), data: 09 01 00 00 00 00 00 00 01 00 00 00 00 - // check: make sure 0x48 is not detected again ! - rx_telegram({0x08, 0x00, 0x07, 0x00, 0x09, 01, 00, 00, 00, 00, 00, 00, 01, 00, 00, 00, 00}); - - // add thermostat - Thermostat: RC300/RC310/Moduline 3000/CW400/Sense II (DeviceID:0x10, ProductID:158, Version:03.03) ** master device ** - add_device(0x10, 158); // Nefit Trendline - - // simulate incoming telegram - // Thermostat(0x10) -> 48(0x48), ?(0x26B), data: 6B 08 4F 00 00 00 02 00 00 00 02 00 03 00 03 00 03 - rx_telegram({0x10, 0x48, 0xFF, 00, 01, 0x6B, 00, 0x6B, 0x08, 0x4F, 00, 00, 00, 02, 00, 00, 00, 02, 00, 03, 00, 03, 00, 03}); + run_test("gateway"); } if (command == "web") { @@ -227,8 +325,9 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { uart_telegram({0x98, 0x00, 0x06, 0x00, 0x00, 0x03, 0x04, 0x0C, 0x02, 0x33, 0x06, 00, 00, 00, 00, 00, 00}); shell.invoke_command("show"); - StaticJsonDocument<2000> doc; - JsonObject root = doc.to(); + + StaticJsonDocument<500> doc; + JsonObject root = doc.to(); EMSESP::device_info_web(2, root); // show thermostat. use 1 for boiler serializeJsonPretty(doc, shell); shell.println(); @@ -236,48 +335,15 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { if (command == "boiler") { shell.printfln(F("Testing boiler...")); - - add_device(0x08, 123); // Nefit Trendline - - // UBAuptime - uart_telegram({0x08, 0x0B, 0x14, 00, 0x3C, 0x1F, 0xAC, 0x70}); - + run_test("boiler"); shell.invoke_command("show"); shell.invoke_command("call boiler info"); } - if (command == "general") { - shell.printfln(F("Testing adding a general boiler & thermostat...")); - - add_device(0x08, 123); // Nefit Trendline - add_device(0x18, 157); // Bosch CR100 - - // add some data - // Boiler -> Me, UBAMonitorFast(0x18), telegram: 08 00 18 00 00 02 5A 73 3D 0A 10 65 40 02 1A 80 00 01 E1 01 76 0E 3D 48 00 C9 44 02 00 (#data=25) - uart_telegram({0x08, 0x00, 0x18, 0x00, 0x00, 0x02, 0x5A, 0x73, 0x3D, 0x0A, 0x10, 0x65, 0x40, 0x02, 0x1A, - 0x80, 0x00, 0x01, 0xE1, 0x01, 0x76, 0x0E, 0x3D, 0x48, 0x00, 0xC9, 0x44, 0x02, 0x00}); - - // Boiler -> Thermostat, UBAParameterWW(0x33), telegram: 08 97 33 00 23 24 (#data=2) - uart_telegram({0x08, 0x98, 0x33, 0x00, 0x23, 0x24}); - - // Boiler -> Me, UBAParameterWW(0x33), telegram: 08 0B 33 00 08 FF 34 FB 00 28 00 00 46 00 FF FF 00 (#data=13) - uart_telegram({0x08, 0x0B, 0x33, 0x00, 0x08, 0xFF, 0x34, 0xFB, 0x00, 0x28, 0x00, 0x00, 0x46, 0x00, 0xFF, 0xFF, 0x00}); - - // Thermostat RCPLUSStatusMessage_HC1(0x01A5) - uart_telegram({0x98, 0x00, 0xFF, 0x00, 0x01, 0xA5, 0x00, 0xCF, 0x21, 0x2E, 0x00, 0x00, 0x2E, 0x24, - 0x03, 0x25, 0x03, 0x03, 0x01, 0x03, 0x25, 0x00, 0xC8, 0x00, 0x00, 0x11, 0x01, 0x03}); - - shell.invoke_command("show devices"); - shell.invoke_command("show"); - shell.invoke_command("call system publish"); - shell.invoke_command("show mqtt"); - } - if (command == "fr120") { shell.printfln(F("Testing adding a thermostat FR120...")); - // add a thermostat - add_device(0x10, 191); // FR120 + add_device(0x10, 191); // FR120 thermostat // HC1 uart_telegram({0x90, 0x00, 0xFF, 0x00, 0x00, 0x6F, 0x00, 0xCF, 0x21, 0x2E, 0x20, 0x00, 0x2E, 0x24, @@ -289,23 +355,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { if (command == "thermostat") { shell.printfln(F("Testing adding a thermostat FW120...")); - - // add a thermostat - add_device(0x10, 192); // FW120 - - // HC1 - uart_telegram({0x90, 0x00, 0xFF, 0x00, 0x00, 0x6F, 0x00, 0xCF, 0x21, 0x2E, 0x20, 0x00, 0x2E, 0x24, - 0x03, 0x25, 0x03, 0x03, 0x01, 0x03, 0x25, 0x00, 0xC8, 0x00, 0x00, 0x11, 0x01, 0x03}); - - // HC2 - uart_telegram({0x90, 0x00, 0xFF, 0x00, 0x00, 0x70, 0x00, 0xCF, 0x22, 0x2F, 0x10, 0x00, 0x2E, 0x24, - 0x03, 0x25, 0x03, 0x03, 0x01, 0x03, 0x25, 0x00, 0xC8, 0x00, 0x00, 0x11, 0x01, 0x03}); - - // HC3 - uart_telegram({0x90, 0x00, 0xFF, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}); - + run_test("thermostat"); shell.invoke_command("show"); - EMSESP::mqtt_.incoming("ems-esp/thermostat_hc1", "heat"); EMSESP::mqtt_.incoming("ems-esp/thermostat_hc2", "28.8"); EMSESP::mqtt_.incoming("ems-esp/thermostat", "{\"cmd\":\"temp\",\"id\":2,\"data\":22}"); @@ -324,50 +375,19 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { if (command == "solar") { shell.printfln(F("Testing Solar")); - - EMSESP::rxservice_.ems_mask(EMSbus::EMS_MASK_BUDERUS); - - add_device(0x30, 163); // SM100 - - // SM100Monitor - type 0x0362 EMS+ - for SM100 and SM200 - // B0 0B FF 00 02 62 00 44 02 7A 80 00 80 00 80 00 80 00 80 00 80 00 00 7C 80 00 80 00 80 00 80 - rx_telegram({0xB0, 0x0B, 0xFF, 00, 0x02, 0x62, 00, 0x44, 0x02, 0x7A, 0x80, 00, 0x80, 0x00, 0x80, 00, - 0x80, 00, 0x80, 00, 0x80, 00, 00, 0x7C, 0x80, 00, 0x80, 00, 0x80, 00, 0x80}); - - rx_telegram({0xB0, 0x0B, 0xFF, 0x00, 0x02, 0x62, 0x01, 0x44, 0x03, 0x30, 0x80, 00, 0x80, 00, 0x80, 00, - 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 0x33}); - - rx_telegram({0xB0, 00, 0xFF, 0x18, 02, 0x62, 0x80, 00, 0xB8}); - - EMSESP::send_raw_telegram("B0 00 FF 18 02 62 80 00 B8"); - + run_test("solar"); uart_telegram("30 00 FF 0A 02 6A 04"); // SM100 pump on 1 uart_telegram("30 00 FF 00 02 64 00 00 00 04 00 00 FF 00 00 1E 0B 09 64 00 00 00 00"); // SM100 modulation EMSESP::show_device_values(shell); - uart_telegram("30 00 FF 0A 02 6A 03"); // SM100 pump off 0 EMSESP::show_device_values(shell); } if (command == "heatpump") { shell.printfln(F("Testing Heat Pump")); - - EMSESP::rxservice_.ems_mask(EMSbus::EMS_MASK_BUDERUS); - - // add heatpump - add_device(0x38, 200); // Enviline module - - // add a thermostat - add_device(0x10, 192); // FW120 - - uart_telegram({0x90, 0x00, 0xFF, 0x00, 0x00, 0x6F, 0x00, 0xCF, 0x21, 0x2E, 0x20, 0x00, 0x2E, 0x24, - 0x03, 0x25, 0x03, 0x03, 0x01, 0x03, 0x25, 0x00, 0xC8, 0x00, 0x00, 0x11, 0x01, 0x03}); // HC1 - - uart_telegram("38 0B FF 00 03 7B 0C 34 00 74"); + run_test("heatpump"); shell.invoke_command("call"); shell.invoke_command("call heatpump info"); - - EMSESP::show_device_values(shell); } if (command == "solar200") { @@ -381,25 +401,20 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { // B0 0B FF 00 02 62 00 44 02 7A 80 00 80 00 80 00 80 00 80 00 80 00 00 7C 80 00 80 00 80 00 80 rx_telegram({0xB0, 0x0B, 0xFF, 00, 0x02, 0x62, 00, 0x44, 0x02, 0x7A, 0x80, 00, 0x80, 0x00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 00, 0x7C, 0x80, 00, 0x80, 00, 0x80, 00, 0x80}); - EMSESP::show_device_values(shell); rx_telegram({0xB0, 0x0B, 0xFF, 0x00, 0x02, 0x62, 0x01, 0x44, 0x03, 0x30, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 00, 0x80, 0x33}); - EMSESP::show_device_values(shell); rx_telegram({0xB0, 00, 0xFF, 0x18, 02, 0x62, 0x80, 00, 0xB8}); - EMSESP::show_device_values(shell); EMSESP::send_raw_telegram("B0 00 FF 18 02 62 80 00 B8"); uart_telegram("30 00 FF 0A 02 6A 04"); // SM100 pump on 1 uart_telegram("30 00 FF 00 02 64 00 00 00 04 00 00 FF 00 00 1E 0B 09 64 00 00 00 00"); // SM100 modulation - EMSESP::show_device_values(shell); - uart_telegram("30 00 FF 0A 02 6A 03"); // SM100 pump off 0 - EMSESP::show_device_values(shell); + shell.invoke_command("show"); } if (command == "km") { @@ -558,12 +573,6 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { uart_telegram({0x88, 00, 0x2A, 00, 00, 00, 00, 00, 00, 00, 00, 00, 0xD2, 00, 00, 0x80, 00, 00, 01, 0x9D, 0x80, 0x00, 0x02, 0x79, 00}); } - if (command == "send") { - shell.printfln(F("Sending to Tx...")); - EMSESP::show_ems(shell); - EMSESP::txservice_.send(); // send it to UART - } - if (command == "tx") { shell.printfln(F("Testing Tx...")); @@ -602,8 +611,6 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { EMSESP::txservice_.send(); // send it to UART } - shell.loop_all(); - EMSESP::txservice_.flush_tx_queue(); } @@ -654,9 +661,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { shell.invoke_command("call"); shell.invoke_command("call system info"); - char system_topic[Mqtt::MQTT_TOPIC_MAX_SIZE]; - strcpy(system_topic, "ems-esp/system"); - EMSESP::mqtt_.incoming(system_topic, "{\"cmd\":\"info\"}"); // this should fail + EMSESP::mqtt_.incoming("ems-esp/system", "{\"cmd\":\"info\"}"); // this should fail shell.invoke_command("call thermostat wwmode"); // should do nothing shell.invoke_command("call thermostat mode auto 2"); // should error, no hc2 @@ -665,8 +670,6 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { if (command == "pin") { shell.printfln(F("Testing pin...")); - - shell.invoke_command("su"); shell.invoke_command("call system pin"); shell.invoke_command("call system pin 1 true"); } @@ -819,10 +822,10 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & command) { // check for error "No telegram type handler found for ID 0x255 (src 0x20)" uart_telegram({0xA0, 0x00, 0xFF, 0x00, 0x01, 0x55, 0x00, 0x1A}); - shell.invoke_command("show"); - shell.invoke_command("call mixer info"); - shell.invoke_command("call system publish"); - shell.invoke_command("show mqtt"); + // shell.invoke_command("show"); + // shell.invoke_command("call mixer info"); + // shell.invoke_command("call system publish"); + // shell.invoke_command("show mqtt"); } } diff --git a/src/test/test.h b/src/test/test.h index 4dcb75e41..90529ba38 100644 --- a/src/test/test.h +++ b/src/test/test.h @@ -16,7 +16,7 @@ * along with this program. If not, see . */ -#if defined(EMSESP_DEBUG) +#if defined(EMSESP_TEST) #ifndef EMSESP_TEST_H #define EMSESP_TEST_H @@ -40,7 +40,8 @@ namespace emsesp { class Test { public: - static void run_test(uuid::console::Shell & shell, const std::string & command); + static void run_test_shell(uuid::console::Shell & shell, const std::string & command); + static void run_test(const char * command, int8_t id = 0); static void dummy_mqtt_commands(const char * message); static void rx_telegram(const std::vector & data); static void uart_telegram(const std::vector & rx_data);