replace STANDALONE_DUMP with a parameter set during tests call test_test_set_all_active

This commit is contained in:
proddy
2023-01-07 21:28:33 +01:00
parent 6ed378086b
commit 60b424705d
16 changed files with 151 additions and 68 deletions

View File

@@ -53,7 +53,11 @@ bool Test::run_test(const char * command, int8_t id) {
return true;
}
#ifndef EMSESP_DEBUG_LIMITED
//
// the tests take a lot of memory when built for the ESP32
// so only including the full set in standalone, otherwise a limited selection of basic tests
//
#ifndef EMSESP_STANDALONE
if (strcmp(command, "2thermostats") == 0) {
EMSESP::logger().info("Testing with multiple thermostats...");
@@ -223,7 +227,7 @@ bool Test::run_test(const char * command, int8_t id) {
return false;
}
// These next tests are run from the Console
// These next tests are run from the Console, so inherit the Shell
// using the test command
void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const std::string & data) {
// switch to su
@@ -236,28 +240,49 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
std::string command(20, '\0');
#ifndef EMSESP_DEBUG_LIMITED
if ((cmd.empty()) || (cmd == "default")) {
command = EMSESP_DEBUG_DEFAULT;
} else {
command = cmd;
}
#if defined(EMSESP_STANDALONE_DUMP)
if (command == "dump") {
shell.printfln("Adding all devices and entities...");
EMSESP::dump_all_values(shell);
if (command == "memory") {
shell.printfln("Testing memory by adding lots of devices and entities...");
System::test_set_all_active(true);
add_device(0x08, 123); // Nefit Trendline
add_device(0x18, 157); // Bosch CR100
shell.invoke_command("show values");
return;
}
//
// the tests take a lot of memory when built for the ESP32
// so only including the full set in standalone, otherwise a limited selection of basic tests
//
#ifdef EMSESP_STANDALONE
// all tests with EMSESP_STANDALONE
if (command == "entity_dump") {
shell.printfln("Adding all devices and entities...");
System::test_set_all_active(true);
EMSESP::dump_all_values(shell);
return;
}
#endif
if (command == "general") {
shell.printfln("Testing adding a general boiler & thermostat...");
run_test("general");
shell.invoke_command("show devices");
shell.invoke_command("show");
shell.invoke_command("show values");
shell.invoke_command("call system publish");
shell.invoke_command("show mqtt");
return;
}
if (command == "modes") {
@@ -266,6 +291,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
shell.invoke_command("call thermostat mode auto");
shell.invoke_command("call thermostat mode Manuell"); // DE
shell.invoke_command("call thermostat mode 1");
return;
}
if (command == "render") {
@@ -334,6 +361,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
temp = 0x63;
doub = Helpers::transformNumFloat(temp, 2); // divide by 2
shell.printfln("Round test div2 from x%02X to %d to %f", temp, temp, doub);
return;
}
if (command == "devices") {
@@ -341,6 +370,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
// A fake response - UBADevices(0x07)
rx_telegram({0x08, 0x00, 0x07, 0x00, 0x0B, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00});
return;
}
// check for boiler and controller on same product_id
@@ -352,6 +383,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
// UBAuptime
uart_telegram({0x08, 0x0B, 0x14, 00, 0x3C, 0x1F, 0xAC, 0x70});
return;
}
if (command == "620") {
@@ -362,6 +395,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
// Version Boiler
uart_telegram({0x08, 0x0B, 0x02, 0x00, 0x5F, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00});
return;
}
// unknown device
@@ -380,6 +415,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
shell.invoke_command("show devices");
shell.invoke_command("call system report");
return;
}
if (command == "unknown2") {
@@ -387,11 +424,15 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
// simulate getting version information back from an unknown device
rx_telegram({0x09, 0x0B, 0x02, 0x00, 0x5A, 0x01, 0x02}); // productID is 90 which doesn't exist
return;
}
if (command == "gateway") {
shell.printfln("Testing Gateway...");
run_test("gateway");
return;
}
if (command == "310") {
@@ -401,6 +442,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
shell.invoke_command("show");
shell.invoke_command("call system publish");
shell.invoke_command("show mqtt");
return;
}
if (command == "2thermostats") {
@@ -408,6 +451,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
run_test("2thermostats");
shell.invoke_command("show");
shell.invoke_command("show devices");
return;
}
if (command == "web") {
@@ -420,7 +465,6 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
run_test("thermostat");
#if defined(EMSESP_STANDALONE)
DynamicJsonDocument doc(8000); // some absurd high number
for (const auto & emsdevice : EMSESP::emsdevices) {
if (emsdevice) {
@@ -466,6 +510,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
shell.invoke_command("set board_profile wemos");
shell.invoke_command("exit");
shell.invoke_command("call system settings");
return;
}
if (command == "boiler") {
@@ -494,6 +540,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
EMSESP::mqtt_.incoming("ems-esp/boiler", "{\"cmd\":\"heatingactivated\",\"data\":1}");
shell.invoke_command("show mqtt");
return;
}
if (command == "shower_alert") {
@@ -503,6 +551,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
// device type, command, data
Command::call(EMSdevice::DeviceType::BOILER, "wwtapactivated", "false");
return;
}
if (command == "fr120") {
@@ -515,6 +565,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
shell.invoke_command("show");
shell.invoke_command("show devices");
return;
}
if (command == "ha") {
@@ -537,6 +589,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
// shell.invoke_command("call thermostat seltemp"); // sensor.thermostat_hc1_selected_room_temperature
// shell.invoke_command("call thermostat entities");
// shell.invoke_command("call boiler entities");
return;
}
if (command == "lastcode") {
@@ -555,6 +609,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
{0x08, 0x0B, 0xC2, 0, 0x08, 0xAC, 00, 0x10, 0x31, 0x48, 0x30, 0x31, 0x15, 0x80, 0x95, 0x0B, 0x0E, 0x10, 0x38, 00, 0x7F, 0xFF, 0xFF, 0xFF});
// shell.invoke_command("show");
return;
}
if (command == "dv") {
@@ -569,11 +624,13 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
shell.invoke_command("call boiler wwseltemp");
shell.invoke_command("call system publish");
return;
}
if (command == "dallas") {
shell.printfln("Testing adding Dallas sensor");
emsesp::EMSESP::dallassensor_.test();
return;
}
if (command == "dallas_full") {
@@ -590,6 +647,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
EMSESP::dallassensor_.update("01-0203-0405-0607", "testdallas", 2);
shell.invoke_command("show");
shell.invoke_command("call system publish");
return;
}
if (command == "analog") {
@@ -609,6 +667,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
EMSESP::analogsensor_.update(36, "analogtest", 2, 0.7, 17, 1);
shell.invoke_command("show");
// shell.invoke_command("call system publish");
return;
}
if (command == "healthcheck") {
@@ -621,6 +680,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
// n=2 = EMSESP::system_.HEALTHCHECK_NO_NETWORK
shell.printfln("Testing healthcheck with %d", n);
EMSESP::system_.healthcheck(n);
return;
}
if (command == "custom") {
@@ -650,9 +710,9 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
shell.invoke_command("call thermostat seltemp");
shell.invoke_command("call system publish");
return;
}
if (command == "masked") {
shell.printfln("Testing masked entities");
@@ -675,6 +735,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
shell.invoke_command("call boiler wwseltemp");
shell.invoke_command("call system publish");
return;
}
if (command == "dv2") {
@@ -695,6 +756,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
shell.invoke_command("call boiler wwseltemp");
shell.invoke_command("call system publish");
return;
}
if (command == "api_values") {
@@ -729,6 +791,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
request.url("/api/boiler/flamecurr/bad");
EMSESP::webAPIService.webAPIService_get(&request);
#endif
return;
}
if (command == "mqtt_post") {
@@ -743,6 +806,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
run_test("thermostat");
EMSESP::mqtt_.incoming("ems-esp/boiler/wwseltemp", "59");
return;
}
#if defined(EMSESP_STANDALONE)
@@ -763,6 +827,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
json = doc.as<JsonVariant>();
request.url("/api/thermostat/wwmode");
EMSESP::webAPIService.webAPIService_post(&request, json);
return;
}
#endif
@@ -779,7 +845,6 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
run_test("thermostat");
#if defined(EMSESP_STANDALONE)
AsyncWebServerRequest requestX;
DynamicJsonDocument docX(2000);
JsonVariant jsonX;
@@ -871,7 +936,6 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
return;
*/
/*
// char dataX[] = "{\"value\":\"0B 88 19 19 02\"}";
char dataX[] = "{\"name\":\"temp\",\"value\":11}";
@@ -916,7 +980,6 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
strlcpy(command_s, "hc3_seltemp", sizeof(command_s));
ncmd = Command::parse_command_string(command_s, id_n);
shell.printfln("test cmd parse cmd=%s id=%d", ncmd, id_n);
#endif
// Console tests
@@ -1037,8 +1100,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
json = doc.as<JsonVariant>();
request.url("/api/thermostat/mode/auto");
EMSESP::webAPIService.webAPIService_post(&request, json);
#endif
return;
}
if (command == "mqtt_nested") {
@@ -1059,6 +1122,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
Mqtt::nested_format(2);
shell.invoke_command("call system publish");
shell.invoke_command("show mqtt");
return;
}
if (command == "thermostat") {
@@ -1075,6 +1139,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
EMSESP::mqtt_.incoming("ems-esp/thermostat_hc3", "{\"cmd\":\"temp\",\"data\":-3}");
shell.invoke_command("show mqtt");
return;
}
if (command == "tc100") {
@@ -1086,6 +1151,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
// 0x0A
uart_telegram({0x98, 0x0B, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00});
return;
}
if (command == "solar") {
@@ -1099,6 +1165,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
shell.invoke_command("call system publish");
// EMSESP::txservice_.send_raw("B0 00 FF 18 02 62 80 00 B8");
return;
}
if (command == "heatpump") {
@@ -1106,6 +1173,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
run_test("heatpump");
shell.invoke_command("call");
shell.invoke_command("call heatpump info");
return;
}
if (command == "solar200") {
@@ -1131,6 +1199,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
uart_telegram("30 00 FF 0A 02 6A 03"); // SM100 pump off 0
shell.invoke_command("show");
return;
}
if (command == "km") {
@@ -1189,6 +1258,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
EMSESP::show_ems(shell);
EMSESP::show_device_values(shell);
return;
}
if (command == "cr100") {
@@ -1214,6 +1284,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
shell.loop_all();
EMSESP::txservice_.send(); // send it to UART
return;
}
if (command == "rx2") {
@@ -1221,6 +1292,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
for (uint8_t i = 0; i < 30; i++) {
uart_telegram({0x08, 0x0B, 0x33, 0x00, 0x08, 0xFF, 0x34, 0xFB, 0x00, 0x28, 0x00, 0x00, 0x46, 0x00, 0xFF, 0xFF, 0x00});
}
return;
}
if (command == "rx") {
@@ -1278,6 +1350,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
// test 0x2A - DHWStatus3
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});
return;
}
if (command == "tx") {
@@ -1315,6 +1388,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
for (uint8_t i = 0; i < 10; i++) {
EMSESP::txservice_.send(); // send it to UART
}
return;
}
if (command == "poll") {
@@ -1340,6 +1414,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
uint8_t t2[] = {0x21, 0x22};
EMSESP::send_write_request(0x91, 0x17, 0x00, t2, sizeof(t2), 0);
EMSESP::show_ems(shell);
return;
}
if (command == "cmd") {
@@ -1371,12 +1446,14 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
shell.invoke_command("call thermostat wwmode"); // should do nothing
shell.invoke_command("call thermostat mode auto 2"); // should error, no hc2
shell.invoke_command("call thermostat temp 22.56");
return;
}
if (command == "pin") {
shell.printfln("Testing pin...");
shell.invoke_command("call system pin");
shell.invoke_command("call system pin 1 true");
return;
}
if (command == "mqtt2") {
@@ -1400,6 +1477,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
Mqtt::publish("test", jo);
Mqtt::show_mqtt(shell); // show queue
return;
}
if (command == "mqtt") {
@@ -1494,6 +1572,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
Mqtt::resubscribe();
Mqtt::show_mqtt(shell); // show queue
return;
}
if (command == "poll2") {
@@ -1505,6 +1584,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
EMSESP::incoming_telegram(poll, 1);
EMSESP::show_ems(shell);
return;
}
if (command == "rx2") {
@@ -1512,6 +1592,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
uart_telegram({0x1B, 0x5B, 0xFD, 0x2D, 0x9E, 0x3A, 0xB6, 0xE5, 0x02, 0x20, 0x33, 0x30, 0x32, 0x3A, 0x20, 0x5B,
0x73, 0xFF, 0xFF, 0xCB, 0xDF, 0xB7, 0xA7, 0xB5, 0x67, 0x77, 0x77, 0xE4, 0xFF, 0xFD, 0x77, 0xFF});
return;
}
// https://github.com/emsesp/EMS-ESP/issues/380#issuecomment-633663007
@@ -1519,6 +1600,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
shell.printfln("Testing rx3...");
uart_telegram({0x21, 0x0B, 0xFF, 0x00});
return;
}
// testing the UART tx command, without a queue
@@ -1527,6 +1609,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
uint8_t t[] = {0x0B, 0x88, 0x18, 0x00, 0x20, 0xD4}; // including CRC
EMSuart::transmit(t, sizeof(t));
return;
}
// send read request with offset
@@ -1535,6 +1618,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
// send_read_request(0x18, 0x08);
EMSESP::txservice_.read_request(0x18, 0x08, 27); // no offset
return;
}
if (command == "mixer") {
@@ -1563,6 +1647,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
request.url("/api/mixer/wwc2/pumpstatus");
EMSESP::webAPIService.webAPIService_get(&request);
#endif
return;
}
if (command == "crash") {
@@ -1575,15 +1660,13 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
shell.printfln("Testing %s", a);
#pragma GCC diagnostic pop
return;
}
#endif
// if we're here, we didn't recognize the test
shell.printfln("Unknown test command: %s", command.c_str());
if (command == "limited") {
shell.printfln("Run a limited memory test...");
run_test("general");
}
#endif // EMSES_STANDALONE
}
// simulates a telegram in the Rx queue, but without the CRC which is added automatically