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

@@ -37,7 +37,7 @@ CXX_STANDARD := -std=c++17
# Defined Symbols
#----------------------------------------------------------------------
DEFINES += -DARDUINOJSON_ENABLE_STD_STRING=1 -DARDUINOJSON_ENABLE_PROGMEM=1 -DARDUINOJSON_ENABLE_ARDUINO_STRING -DARDUINOJSON_USE_DOUBLE=0
DEFINES += -DEMSESP_DEBUG -DEMSESP_STANDALONE -DEMSESP_USE_SERIAL
DEFINES += -DEMSESP_DEBUG -DEMSESP_STANDALONE
DEFINES += $(ARGS)
DEFAULTS = -DEMSESP_DEFAULT_LOCALE=\"en\" -DEMSESP_DEFAULT_TX_MODE=8 -DEMSESP_DEFAULT_VERSION=\"3.5.0-dev\" -DEMSESP_DEFAULT_BOARD_PROFILE=\"S32\"

View File

@@ -5,9 +5,9 @@
; options are: EMSESP_DEBUG, EMSESP_UART_DEBUG, EMSESP_DEBUG_SENSOR, EMSESP_WIFI_TWEAK, EMSESP_DEFAULT_BOARD_PROFILE EMSESP_DEBUG_LIMITED
; my_build_flags = -DEMSESP_DEBUG -DEMSESP_DEFAULT_BOARD_PROFILE=\"NODEMCU\"
; my_build_flags = -DEMSESP_DEBUG_SENSOR
; my_build_flags = -DEMSESP_DEBUG -DEMSESP_USE_SERIAL
; my_build_flags = -DEMSESP_DEBUG
; my_build_flags = -DEMSESP_DEBUG -DCORE_DEBUG_LEVEL=5 ; 5=verbose, 4=debug, 3=info
my_build_flags = -DEMSESP_DEBUG -DEMSESP_DEBUG_LIMITED -DEMSESP_USE_SERIAL
my_build_flags =
[env:esp32_4M]
; if using OTA enter your details below

View File

@@ -16,12 +16,12 @@ core_build_flags =
-D NDEBUG
-D ARDUINO_ARCH_ESP32=1
-D ESP32=1
-std=gnu++17
; -std=gnu++17
-Os
core_unbuild_flags = -std=gnu++11
; core_unbuild_flags = -std=gnu++11
; core_unbuild_flags = -std=gnu++17
; core_unbuild_flags =
core_unbuild_flags =
; my_build_flags is set in pio_local.ini
my_build_flags =
@@ -70,7 +70,8 @@ extra_scripts =
scripts/rename_fw.py
board = esp32dev
framework = arduino
platform = espressif32
; platform = espressif32
platform = espressif32@5.2.0
board_upload.flash_size = 4MB
board_build.partitions = esp32_partition_4M.csv
build_flags = ${common.build_flags}
@@ -134,7 +135,7 @@ platform = native
build_flags =
-DARDUINO
-DARDUINOJSON_ENABLE_STD_STRING=1 -DARDUINOJSON_ENABLE_PROGMEM=1 -DARDUINOJSON_ENABLE_ARDUINO_STRING -DARDUINOJSON_USE_DOUBLE=0
-DEMSESP_DEBUG -DEMSESP_STANDALONE -DEMSESP_USE_SERIAL
-DEMSESP_DEBUG -DEMSESP_STANDALONE
-DEMSESP_DEFAULT_LOCALE=\"en\" -DEMSESP_DEFAULT_TX_MODE=8 -DEMSESP_DEFAULT_VERSION=\"3.5.0-dev\" -DEMSESP_DEFAULT_BOARD_PROFILE=\"S32\"
-lpthread
-std=gnu++17 -Og -ggdb

View File

@@ -1,6 +1,6 @@
# strips out lines between two markers
# pipe a file into, for example:
# make clean; make ARGS=-DEMSESP_STANDALONE_DUMP; echo "test dump" | ./emsesp | python3 ./scripts/dump_entities.py
# make clean; make; echo "test dump" | ./emsesp | python3 ./scripts/dump_entities.py
import fileinput
with fileinput.input() as f_input:

View File

@@ -5,5 +5,5 @@
rm -f dump_entities.csv
make clean
make ARGS=-DEMSESP_STANDALONE_DUMP
echo "test dump" | ./emsesp | python3 ./scripts/dump_entities.py > dump_entities.csv
echo "test entity_dump" | ./emsesp | python3 ./scripts/dump_entities.py > dump_entities.csv
cat dump_entities.csv

View File

@@ -184,10 +184,11 @@ Thermostat::Thermostat(uint8_t device_type, uint8_t device_id, uint8_t product_i
// register device values for common values (not heating circuit)
register_device_values();
#if defined(EMSESP_STANDALONE_DUMP)
// if we're just dumping out values, create a single dummy hc1
register_device_values_hc(std::make_shared<emsesp::Thermostat::HeatingCircuit>(1, model)); // hc=1
#endif
if (System::test_set_all_active()) {
Serial.println("DEBUG TEST: adding a fake hc");
// if we're just dumping out values, create a single dummy hc1
register_device_values_hc(std::make_shared<emsesp::Thermostat::HeatingCircuit>(1, model)); // hc=1
}
// query all the heating circuits. This is only done once.
// The automatic fetch will from now on only update the active heating circuits

View File

@@ -477,19 +477,19 @@ void EMSdevice::add_device_value(uint8_t tag,
if (type == DeviceValueType::STRING) {
*(char *)(value_p) = {'\0'}; // this is important for string functions like strlen() to work later
} else if (type == DeviceValueType::INT) {
*(int8_t *)(value_p) = EMS_VALUE_DEFAULT_INT;
*(int8_t *)(value_p) = System::test_set_all_active() ? 11 : EMS_VALUE_DEFAULT_INT;
} else if (type == DeviceValueType::UINT) {
*(uint8_t *)(value_p) = EMS_VALUE_DEFAULT_UINT;
*(uint8_t *)(value_p) = System::test_set_all_active() ? -12 : EMS_VALUE_DEFAULT_UINT;
} else if (type == DeviceValueType::SHORT) {
*(int16_t *)(value_p) = EMS_VALUE_DEFAULT_SHORT;
*(int16_t *)(value_p) = System::test_set_all_active() ? -1234 : EMS_VALUE_DEFAULT_SHORT;
} else if (type == DeviceValueType::USHORT) {
*(uint16_t *)(value_p) = EMS_VALUE_DEFAULT_USHORT;
*(uint16_t *)(value_p) = System::test_set_all_active() ? 1234 : EMS_VALUE_DEFAULT_USHORT;
} else if ((type == DeviceValueType::ULONG) || (type == DeviceValueType::TIME)) {
*(uint32_t *)(value_p) = EMS_VALUE_DEFAULT_ULONG;
*(uint32_t *)(value_p) = System::test_set_all_active() ? 12356 : EMS_VALUE_DEFAULT_ULONG;
} else if (type == DeviceValueType::BOOL) {
*(int8_t *)(value_p) = EMS_VALUE_DEFAULT_BOOL; // bool is uint8_t, but other initial value
*(int8_t *)(value_p) = System::test_set_all_active() ? 1 : EMS_VALUE_DEFAULT_BOOL; // bool is uint8_t, but other initial value
} else if (type == DeviceValueType::ENUM) {
*(uint8_t *)(value_p) = EMS_VALUE_DEFAULT_ENUM; // enums behave as uint8_t
*(uint8_t *)(value_p) = System::test_set_all_active() ? 1 : EMS_VALUE_DEFAULT_ENUM; // enums behave as uint8_t
}
uint8_t state = DeviceValueState::DV_DEFAULT; // determine state
@@ -1112,7 +1112,7 @@ void EMSdevice::getCustomEntities(std::vector<std::string> & entity_ids) {
}
}
#if defined(EMSESP_STANDALONE_DUMP)
#if defined(EMSESP_STANDALONE)
// dumps all entity values in native English
// the code is intended to run only once standalone, outside the ESP32 so not optimized for memory efficiency
// pipe symbols (|) are escaped so they can be converted to Markdown in the Wiki
@@ -1485,7 +1485,7 @@ void EMSdevice::publish_all_values() {
// For each value in the device create the json object pair and add it to given json
// return false if empty
// this is used to create both the MQTT payloads, Console messages and Web API calls
// this is used to create the MQTT payloads, Console messages and Web API calls
bool EMSdevice::generate_values(JsonObject & output, const uint8_t tag_filter, const bool nested, const uint8_t output_target) {
bool has_values = false; // to see if we've added a value. it's faster than doing a json.size() at the end
uint8_t old_tag = 255; // NAN

View File

@@ -417,7 +417,7 @@ class EMSdevice {
uint8_t count_entities();
bool has_entities() const;
#if defined(EMSESP_STANDALONE_DUMP)
#if defined(EMSESP_STANDALONE)
void dump_value_info();
#endif

View File

@@ -114,7 +114,7 @@ const char * DeviceValue::DeviceValueUOM_s[] = {
};
// mapping of TAGs, to match order in DeviceValueTAG enum in emsdevice.h
// mapping of TAGs, to match order in DeviceValueTAG enum in emsdevicevalue.h
// must be an int of 4 bytes, 32bit aligned
const char * const * DeviceValue::DeviceValueTAG_s[] = {

View File

@@ -181,7 +181,7 @@ class DeviceValue {
// has values
bool hasValue() const;
bool has_tag() const {
return ((tag < DeviceValue::NUM_TAGS) && (tag != DeviceValue::DeviceValueTAG::TAG_NONE));
return ((tag < DeviceValue::NUM_TAGS) && (tag != DeviceValue::DeviceValueTAG::TAG_NONE) && strlen(DeviceValueTAG_s[tag][0]));
}
bool get_min_max(int16_t & dv_set_min, uint16_t & dv_set_max);

View File

@@ -316,7 +316,7 @@ void EMSESP::show_ems(uuid::console::Shell & shell) {
// Dump all entities to Serial out
// this is intended to run within the OS with lots of available memory!
#if defined(EMSESP_STANDALONE_DUMP)
#if defined(EMSESP_STANDALONE)
void EMSESP::dump_all_values(uuid::console::Shell & shell) {
Serial.println("---- CSV START ----"); // marker use by py script
// add header for CSV

View File

@@ -56,7 +56,8 @@ uuid::log::Logger System::logger_{F_(system), uuid::log::Facility::KERN};
// init statics
PButton System::myPButton_;
bool System::restart_requested_ = false;
bool System::restart_requested_ = false;
bool System::test_set_all_active_ = false;
// find the index of the language
// 0 = EN, 1 = DE, etc...

View File

@@ -230,9 +230,17 @@ class System {
return appused_;
}
static bool test_set_all_active() {
return test_set_all_active_;
}
static void test_set_all_active(bool n) {
test_set_all_active_ = n;
}
private:
static uuid::log::Logger logger_;
static bool restart_requested_;
static bool test_set_all_active_; // force all entities in a device to have a value
// button
static PButton myPButton_; // PButton instance

View File

@@ -37,30 +37,20 @@
#define MAX_TX_TELEGRAMS 50 // size of Tx queue
// default values for null values
static constexpr uint8_t EMS_VALUE_BOOL = 0xFF; // used to mark that something is a boolean
static constexpr uint8_t EMS_VALUE_BOOL_OFF = 0x00; // boolean false
static constexpr uint8_t EMS_VALUE_BOOL_ON = 0x01; // boolean true. True can be 0x01 or 0xFF sometimes
static constexpr uint8_t EMS_VALUE_BOOL = 0xFF; // used to mark that something is a boolean
static constexpr uint8_t EMS_VALUE_BOOL_OFF = 0x00; // boolean false
static constexpr uint8_t EMS_VALUE_BOOL_ON = 0x01; // boolean true. True can be 0x01 or 0xFF sometimes
static constexpr uint8_t EMS_VALUE_BOOL_NOTSET = 0xFE; // random number for booleans, that's not 0, 1 or FF
static constexpr uint8_t EMS_VALUE_UINT_NOTSET = 0xFF; // for 8-bit unsigned ints/bytes
static constexpr int8_t EMS_VALUE_INT_NOTSET = 0x7F; // for signed 8-bit ints/bytes
static constexpr uint16_t EMS_VALUE_USHORT_NOTSET = 0x7D00; // 32000: for 2-byte unsigned shorts
static constexpr int16_t EMS_VALUE_SHORT_NOTSET = 0x7D00; // 32000: for 2-byte signed shorts
static constexpr uint16_t EMS_VALUE_USHORT_NOTSET = 0x7D00; // 32000: for 2-byte unsigned shorts
static constexpr int16_t EMS_VALUE_SHORT_NOTSET = 0x7D00; // 32000: for 2-byte signed shorts
static constexpr uint32_t EMS_VALUE_ULONG_NOTSET = 0x00FFFFFF; // for 3-byte longs
static constexpr uint32_t EMS_VALUE_ULLONG_NOTSET = 0xFFFFFFFF; // for 4-byte longs
static constexpr uint8_t EMS_MAX_TELEGRAM_LENGTH = 32; // max length of a complete EMS telegram
static constexpr uint8_t EMS_MAX_TELEGRAM_MESSAGE_LENGTH = 27; // max length of message block, assuming EMS1.0
#if defined(EMSESP_STANDALONE_DUMP)
#define EMS_VALUE_DEFAULT_INT 11
#define EMS_VALUE_DEFAULT_UINT -12
#define EMS_VALUE_DEFAULT_SHORT -1234
#define EMS_VALUE_DEFAULT_USHORT 1234
#define EMS_VALUE_DEFAULT_ULONG 12356
#define EMS_VALUE_DEFAULT_BOOL 1
#define EMS_VALUE_DEFAULT_ENUM 1
#else
#define EMS_VALUE_DEFAULT_INT EMS_VALUE_INT_NOTSET
#define EMS_VALUE_DEFAULT_UINT EMS_VALUE_UINT_NOTSET
#define EMS_VALUE_DEFAULT_SHORT EMS_VALUE_SHORT_NOTSET
@@ -68,7 +58,6 @@ static constexpr uint8_t EMS_MAX_TELEGRAM_MESSAGE_LENGTH = 27; // max length of
#define EMS_VALUE_DEFAULT_ULONG EMS_VALUE_ULONG_NOTSET
#define EMS_VALUE_DEFAULT_BOOL EMS_VALUE_BOOL_NOTSET
#define EMS_VALUE_DEFAULT_ENUM EMS_VALUE_UINT_NOTSET
#endif
namespace emsesp {

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

View File

@@ -28,7 +28,6 @@ namespace emsesp {
// #define EMSESP_DEBUG_DEFAULT "thermostat"
// #define EMSESP_DEBUG_DEFAULT "solar"
#define EMSESP_DEBUG_DEFAULT "mixer"
// #define EMSESP_DEBUG_DEFAULT "web"
// #define EMSESP_DEBUG_DEFAULT "mqtt"
// #define EMSESP_DEBUG_DEFAULT "general"
@@ -52,7 +51,8 @@ namespace emsesp {
// #define EMSESP_DEBUG_DEFAULT "mqtt_post"
// #define EMSESP_DEBUG_DEFAULT "api_wwmode"
// #define EMSESP_DEBUG_DEFAULT "custom"
// #define EMSESP_DEBUG_DEFAULT "dump"
// #define EMSESP_DEBUG_DEFAULT "entity_dump"
#define EMSESP_DEBUG_DEFAULT "memory"
class Test {
public: