mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
replace STANDALONE_DUMP with a parameter set during tests call test_test_set_all_active
This commit is contained in:
2
Makefile
2
Makefile
@@ -37,7 +37,7 @@ CXX_STANDARD := -std=c++17
|
|||||||
# Defined Symbols
|
# Defined Symbols
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
DEFINES += -DARDUINOJSON_ENABLE_STD_STRING=1 -DARDUINOJSON_ENABLE_PROGMEM=1 -DARDUINOJSON_ENABLE_ARDUINO_STRING -DARDUINOJSON_USE_DOUBLE=0
|
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)
|
DEFINES += $(ARGS)
|
||||||
|
|
||||||
DEFAULTS = -DEMSESP_DEFAULT_LOCALE=\"en\" -DEMSESP_DEFAULT_TX_MODE=8 -DEMSESP_DEFAULT_VERSION=\"3.5.0-dev\" -DEMSESP_DEFAULT_BOARD_PROFILE=\"S32\"
|
DEFAULTS = -DEMSESP_DEFAULT_LOCALE=\"en\" -DEMSESP_DEFAULT_TX_MODE=8 -DEMSESP_DEFAULT_VERSION=\"3.5.0-dev\" -DEMSESP_DEFAULT_BOARD_PROFILE=\"S32\"
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
; options are: EMSESP_DEBUG, EMSESP_UART_DEBUG, EMSESP_DEBUG_SENSOR, EMSESP_WIFI_TWEAK, EMSESP_DEFAULT_BOARD_PROFILE EMSESP_DEBUG_LIMITED
|
; 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 -DEMSESP_DEFAULT_BOARD_PROFILE=\"NODEMCU\"
|
||||||
; my_build_flags = -DEMSESP_DEBUG_SENSOR
|
; 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 -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]
|
[env:esp32_4M]
|
||||||
; if using OTA enter your details below
|
; if using OTA enter your details below
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ core_build_flags =
|
|||||||
-D NDEBUG
|
-D NDEBUG
|
||||||
-D ARDUINO_ARCH_ESP32=1
|
-D ARDUINO_ARCH_ESP32=1
|
||||||
-D ESP32=1
|
-D ESP32=1
|
||||||
-std=gnu++17
|
; -std=gnu++17
|
||||||
-Os
|
-Os
|
||||||
|
|
||||||
core_unbuild_flags = -std=gnu++11
|
; core_unbuild_flags = -std=gnu++11
|
||||||
; core_unbuild_flags = -std=gnu++17
|
; core_unbuild_flags = -std=gnu++17
|
||||||
; core_unbuild_flags =
|
core_unbuild_flags =
|
||||||
|
|
||||||
; my_build_flags is set in pio_local.ini
|
; my_build_flags is set in pio_local.ini
|
||||||
my_build_flags =
|
my_build_flags =
|
||||||
@@ -70,7 +70,8 @@ extra_scripts =
|
|||||||
scripts/rename_fw.py
|
scripts/rename_fw.py
|
||||||
board = esp32dev
|
board = esp32dev
|
||||||
framework = arduino
|
framework = arduino
|
||||||
platform = espressif32
|
; platform = espressif32
|
||||||
|
platform = espressif32@5.2.0
|
||||||
board_upload.flash_size = 4MB
|
board_upload.flash_size = 4MB
|
||||||
board_build.partitions = esp32_partition_4M.csv
|
board_build.partitions = esp32_partition_4M.csv
|
||||||
build_flags = ${common.build_flags}
|
build_flags = ${common.build_flags}
|
||||||
@@ -134,7 +135,7 @@ platform = native
|
|||||||
build_flags =
|
build_flags =
|
||||||
-DARDUINO
|
-DARDUINO
|
||||||
-DARDUINOJSON_ENABLE_STD_STRING=1 -DARDUINOJSON_ENABLE_PROGMEM=1 -DARDUINOJSON_ENABLE_ARDUINO_STRING -DARDUINOJSON_USE_DOUBLE=0
|
-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\"
|
-DEMSESP_DEFAULT_LOCALE=\"en\" -DEMSESP_DEFAULT_TX_MODE=8 -DEMSESP_DEFAULT_VERSION=\"3.5.0-dev\" -DEMSESP_DEFAULT_BOARD_PROFILE=\"S32\"
|
||||||
-lpthread
|
-lpthread
|
||||||
-std=gnu++17 -Og -ggdb
|
-std=gnu++17 -Og -ggdb
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# strips out lines between two markers
|
# strips out lines between two markers
|
||||||
# pipe a file into, for example:
|
# 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
|
import fileinput
|
||||||
with fileinput.input() as f_input:
|
with fileinput.input() as f_input:
|
||||||
|
|||||||
@@ -5,5 +5,5 @@
|
|||||||
rm -f dump_entities.csv
|
rm -f dump_entities.csv
|
||||||
make clean
|
make clean
|
||||||
make ARGS=-DEMSESP_STANDALONE_DUMP
|
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
|
cat dump_entities.csv
|
||||||
@@ -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 for common values (not heating circuit)
|
||||||
register_device_values();
|
register_device_values();
|
||||||
|
|
||||||
#if defined(EMSESP_STANDALONE_DUMP)
|
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
|
// 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
|
register_device_values_hc(std::make_shared<emsesp::Thermostat::HeatingCircuit>(1, model)); // hc=1
|
||||||
#endif
|
}
|
||||||
|
|
||||||
// query all the heating circuits. This is only done once.
|
// query all the heating circuits. This is only done once.
|
||||||
// The automatic fetch will from now on only update the active heating circuits
|
// The automatic fetch will from now on only update the active heating circuits
|
||||||
|
|||||||
@@ -477,19 +477,19 @@ void EMSdevice::add_device_value(uint8_t tag,
|
|||||||
if (type == DeviceValueType::STRING) {
|
if (type == DeviceValueType::STRING) {
|
||||||
*(char *)(value_p) = {'\0'}; // this is important for string functions like strlen() to work later
|
*(char *)(value_p) = {'\0'}; // this is important for string functions like strlen() to work later
|
||||||
} else if (type == DeviceValueType::INT) {
|
} 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) {
|
} 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) {
|
} 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) {
|
} 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)) {
|
} 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) {
|
} 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) {
|
} 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
|
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
|
// 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
|
// 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
|
// 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
|
// For each value in the device create the json object pair and add it to given json
|
||||||
// return false if empty
|
// 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 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
|
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
|
uint8_t old_tag = 255; // NAN
|
||||||
|
|||||||
@@ -417,7 +417,7 @@ class EMSdevice {
|
|||||||
uint8_t count_entities();
|
uint8_t count_entities();
|
||||||
bool has_entities() const;
|
bool has_entities() const;
|
||||||
|
|
||||||
#if defined(EMSESP_STANDALONE_DUMP)
|
#if defined(EMSESP_STANDALONE)
|
||||||
void dump_value_info();
|
void dump_value_info();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
// must be an int of 4 bytes, 32bit aligned
|
||||||
const char * const * DeviceValue::DeviceValueTAG_s[] = {
|
const char * const * DeviceValue::DeviceValueTAG_s[] = {
|
||||||
|
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ class DeviceValue {
|
|||||||
// has values
|
// has values
|
||||||
bool hasValue() const;
|
bool hasValue() const;
|
||||||
bool has_tag() 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);
|
bool get_min_max(int16_t & dv_set_min, uint16_t & dv_set_max);
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ void EMSESP::show_ems(uuid::console::Shell & shell) {
|
|||||||
|
|
||||||
// Dump all entities to Serial out
|
// Dump all entities to Serial out
|
||||||
// this is intended to run within the OS with lots of available memory!
|
// 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) {
|
void EMSESP::dump_all_values(uuid::console::Shell & shell) {
|
||||||
Serial.println("---- CSV START ----"); // marker use by py script
|
Serial.println("---- CSV START ----"); // marker use by py script
|
||||||
// add header for CSV
|
// add header for CSV
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ uuid::log::Logger System::logger_{F_(system), uuid::log::Facility::KERN};
|
|||||||
// init statics
|
// init statics
|
||||||
PButton System::myPButton_;
|
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
|
// find the index of the language
|
||||||
// 0 = EN, 1 = DE, etc...
|
// 0 = EN, 1 = DE, etc...
|
||||||
|
|||||||
@@ -230,9 +230,17 @@ class System {
|
|||||||
return appused_;
|
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:
|
private:
|
||||||
static uuid::log::Logger logger_;
|
static uuid::log::Logger logger_;
|
||||||
static bool restart_requested_;
|
static bool restart_requested_;
|
||||||
|
static bool test_set_all_active_; // force all entities in a device to have a value
|
||||||
|
|
||||||
// button
|
// button
|
||||||
static PButton myPButton_; // PButton instance
|
static PButton myPButton_; // PButton instance
|
||||||
|
|||||||
@@ -40,7 +40,6 @@
|
|||||||
static constexpr uint8_t EMS_VALUE_BOOL = 0xFF; // used to mark that something is a boolean
|
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_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_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_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 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 int8_t EMS_VALUE_INT_NOTSET = 0x7F; // for signed 8-bit ints/bytes
|
||||||
@@ -52,15 +51,6 @@ static constexpr uint32_t EMS_VALUE_ULLONG_NOTSET = 0xFFFFFFFF; // for 4-byte lo
|
|||||||
static constexpr uint8_t EMS_MAX_TELEGRAM_LENGTH = 32; // max length of a complete EMS telegram
|
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
|
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_INT EMS_VALUE_INT_NOTSET
|
||||||
#define EMS_VALUE_DEFAULT_UINT EMS_VALUE_UINT_NOTSET
|
#define EMS_VALUE_DEFAULT_UINT EMS_VALUE_UINT_NOTSET
|
||||||
#define EMS_VALUE_DEFAULT_SHORT EMS_VALUE_SHORT_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_ULONG EMS_VALUE_ULONG_NOTSET
|
||||||
#define EMS_VALUE_DEFAULT_BOOL EMS_VALUE_BOOL_NOTSET
|
#define EMS_VALUE_DEFAULT_BOOL EMS_VALUE_BOOL_NOTSET
|
||||||
#define EMS_VALUE_DEFAULT_ENUM EMS_VALUE_UINT_NOTSET
|
#define EMS_VALUE_DEFAULT_ENUM EMS_VALUE_UINT_NOTSET
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace emsesp {
|
namespace emsesp {
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,11 @@ bool Test::run_test(const char * command, int8_t id) {
|
|||||||
return true;
|
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) {
|
if (strcmp(command, "2thermostats") == 0) {
|
||||||
EMSESP::logger().info("Testing with multiple thermostats...");
|
EMSESP::logger().info("Testing with multiple thermostats...");
|
||||||
@@ -223,7 +227,7 @@ bool Test::run_test(const char * command, int8_t id) {
|
|||||||
return false;
|
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
|
// using the test command
|
||||||
void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const std::string & data) {
|
void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const std::string & data) {
|
||||||
// switch to su
|
// 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');
|
std::string command(20, '\0');
|
||||||
|
|
||||||
#ifndef EMSESP_DEBUG_LIMITED
|
|
||||||
|
|
||||||
if ((cmd.empty()) || (cmd == "default")) {
|
if ((cmd.empty()) || (cmd == "default")) {
|
||||||
command = EMSESP_DEBUG_DEFAULT;
|
command = EMSESP_DEBUG_DEFAULT;
|
||||||
} else {
|
} else {
|
||||||
command = cmd;
|
command = cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(EMSESP_STANDALONE_DUMP)
|
if (command == "memory") {
|
||||||
if (command == "dump") {
|
shell.printfln("Testing memory by adding lots of devices and entities...");
|
||||||
shell.printfln("Adding all devices and entities...");
|
|
||||||
EMSESP::dump_all_values(shell);
|
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") {
|
if (command == "general") {
|
||||||
shell.printfln("Testing adding a general boiler & thermostat...");
|
shell.printfln("Testing adding a general boiler & thermostat...");
|
||||||
run_test("general");
|
run_test("general");
|
||||||
shell.invoke_command("show devices");
|
shell.invoke_command("show devices");
|
||||||
shell.invoke_command("show");
|
shell.invoke_command("show values");
|
||||||
shell.invoke_command("call system publish");
|
shell.invoke_command("call system publish");
|
||||||
shell.invoke_command("show mqtt");
|
shell.invoke_command("show mqtt");
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "modes") {
|
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 auto");
|
||||||
shell.invoke_command("call thermostat mode Manuell"); // DE
|
shell.invoke_command("call thermostat mode Manuell"); // DE
|
||||||
shell.invoke_command("call thermostat mode 1");
|
shell.invoke_command("call thermostat mode 1");
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "render") {
|
if (command == "render") {
|
||||||
@@ -334,6 +361,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
temp = 0x63;
|
temp = 0x63;
|
||||||
doub = Helpers::transformNumFloat(temp, 2); // divide by 2
|
doub = Helpers::transformNumFloat(temp, 2); // divide by 2
|
||||||
shell.printfln("Round test div2 from x%02X to %d to %f", temp, temp, doub);
|
shell.printfln("Round test div2 from x%02X to %d to %f", temp, temp, doub);
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "devices") {
|
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)
|
// A fake response - UBADevices(0x07)
|
||||||
rx_telegram({0x08, 0x00, 0x07, 0x00, 0x0B, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00});
|
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
|
// 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
|
// UBAuptime
|
||||||
uart_telegram({0x08, 0x0B, 0x14, 00, 0x3C, 0x1F, 0xAC, 0x70});
|
uart_telegram({0x08, 0x0B, 0x14, 00, 0x3C, 0x1F, 0xAC, 0x70});
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "620") {
|
if (command == "620") {
|
||||||
@@ -362,6 +395,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
|
|
||||||
// Version Boiler
|
// Version Boiler
|
||||||
uart_telegram({0x08, 0x0B, 0x02, 0x00, 0x5F, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00});
|
uart_telegram({0x08, 0x0B, 0x02, 0x00, 0x5F, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00});
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// unknown device
|
// 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("show devices");
|
||||||
shell.invoke_command("call system report");
|
shell.invoke_command("call system report");
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "unknown2") {
|
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
|
// 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
|
rx_telegram({0x09, 0x0B, 0x02, 0x00, 0x5A, 0x01, 0x02}); // productID is 90 which doesn't exist
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "gateway") {
|
if (command == "gateway") {
|
||||||
shell.printfln("Testing Gateway...");
|
shell.printfln("Testing Gateway...");
|
||||||
run_test("gateway");
|
run_test("gateway");
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "310") {
|
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("show");
|
||||||
shell.invoke_command("call system publish");
|
shell.invoke_command("call system publish");
|
||||||
shell.invoke_command("show mqtt");
|
shell.invoke_command("show mqtt");
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "2thermostats") {
|
if (command == "2thermostats") {
|
||||||
@@ -408,6 +451,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
run_test("2thermostats");
|
run_test("2thermostats");
|
||||||
shell.invoke_command("show");
|
shell.invoke_command("show");
|
||||||
shell.invoke_command("show devices");
|
shell.invoke_command("show devices");
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "web") {
|
if (command == "web") {
|
||||||
@@ -420,7 +465,6 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
run_test("thermostat");
|
run_test("thermostat");
|
||||||
|
|
||||||
#if defined(EMSESP_STANDALONE)
|
#if defined(EMSESP_STANDALONE)
|
||||||
|
|
||||||
DynamicJsonDocument doc(8000); // some absurd high number
|
DynamicJsonDocument doc(8000); // some absurd high number
|
||||||
for (const auto & emsdevice : EMSESP::emsdevices) {
|
for (const auto & emsdevice : EMSESP::emsdevices) {
|
||||||
if (emsdevice) {
|
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("set board_profile wemos");
|
||||||
shell.invoke_command("exit");
|
shell.invoke_command("exit");
|
||||||
shell.invoke_command("call system settings");
|
shell.invoke_command("call system settings");
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "boiler") {
|
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}");
|
EMSESP::mqtt_.incoming("ems-esp/boiler", "{\"cmd\":\"heatingactivated\",\"data\":1}");
|
||||||
|
|
||||||
shell.invoke_command("show mqtt");
|
shell.invoke_command("show mqtt");
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "shower_alert") {
|
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
|
// device type, command, data
|
||||||
Command::call(EMSdevice::DeviceType::BOILER, "wwtapactivated", "false");
|
Command::call(EMSdevice::DeviceType::BOILER, "wwtapactivated", "false");
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "fr120") {
|
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");
|
||||||
shell.invoke_command("show devices");
|
shell.invoke_command("show devices");
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "ha") {
|
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 seltemp"); // sensor.thermostat_hc1_selected_room_temperature
|
||||||
// shell.invoke_command("call thermostat entities");
|
// shell.invoke_command("call thermostat entities");
|
||||||
// shell.invoke_command("call boiler entities");
|
// shell.invoke_command("call boiler entities");
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "lastcode") {
|
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});
|
{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");
|
// shell.invoke_command("show");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "dv") {
|
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 boiler wwseltemp");
|
||||||
shell.invoke_command("call system publish");
|
shell.invoke_command("call system publish");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "dallas") {
|
if (command == "dallas") {
|
||||||
shell.printfln("Testing adding Dallas sensor");
|
shell.printfln("Testing adding Dallas sensor");
|
||||||
emsesp::EMSESP::dallassensor_.test();
|
emsesp::EMSESP::dallassensor_.test();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "dallas_full") {
|
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);
|
EMSESP::dallassensor_.update("01-0203-0405-0607", "testdallas", 2);
|
||||||
shell.invoke_command("show");
|
shell.invoke_command("show");
|
||||||
shell.invoke_command("call system publish");
|
shell.invoke_command("call system publish");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "analog") {
|
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);
|
EMSESP::analogsensor_.update(36, "analogtest", 2, 0.7, 17, 1);
|
||||||
shell.invoke_command("show");
|
shell.invoke_command("show");
|
||||||
// shell.invoke_command("call system publish");
|
// shell.invoke_command("call system publish");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "healthcheck") {
|
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
|
// n=2 = EMSESP::system_.HEALTHCHECK_NO_NETWORK
|
||||||
shell.printfln("Testing healthcheck with %d", n);
|
shell.printfln("Testing healthcheck with %d", n);
|
||||||
EMSESP::system_.healthcheck(n);
|
EMSESP::system_.healthcheck(n);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "custom") {
|
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 thermostat seltemp");
|
||||||
shell.invoke_command("call system publish");
|
shell.invoke_command("call system publish");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (command == "masked") {
|
if (command == "masked") {
|
||||||
shell.printfln("Testing masked entities");
|
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 boiler wwseltemp");
|
||||||
shell.invoke_command("call system publish");
|
shell.invoke_command("call system publish");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "dv2") {
|
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 boiler wwseltemp");
|
||||||
shell.invoke_command("call system publish");
|
shell.invoke_command("call system publish");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "api_values") {
|
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");
|
request.url("/api/boiler/flamecurr/bad");
|
||||||
EMSESP::webAPIService.webAPIService_get(&request);
|
EMSESP::webAPIService.webAPIService_get(&request);
|
||||||
#endif
|
#endif
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "mqtt_post") {
|
if (command == "mqtt_post") {
|
||||||
@@ -743,6 +806,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
run_test("thermostat");
|
run_test("thermostat");
|
||||||
|
|
||||||
EMSESP::mqtt_.incoming("ems-esp/boiler/wwseltemp", "59");
|
EMSESP::mqtt_.incoming("ems-esp/boiler/wwseltemp", "59");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(EMSESP_STANDALONE)
|
#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>();
|
json = doc.as<JsonVariant>();
|
||||||
request.url("/api/thermostat/wwmode");
|
request.url("/api/thermostat/wwmode");
|
||||||
EMSESP::webAPIService.webAPIService_post(&request, json);
|
EMSESP::webAPIService.webAPIService_post(&request, json);
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -779,7 +845,6 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
run_test("thermostat");
|
run_test("thermostat");
|
||||||
|
|
||||||
#if defined(EMSESP_STANDALONE)
|
#if defined(EMSESP_STANDALONE)
|
||||||
|
|
||||||
AsyncWebServerRequest requestX;
|
AsyncWebServerRequest requestX;
|
||||||
DynamicJsonDocument docX(2000);
|
DynamicJsonDocument docX(2000);
|
||||||
JsonVariant jsonX;
|
JsonVariant jsonX;
|
||||||
@@ -871,7 +936,6 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
return;
|
return;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// char dataX[] = "{\"value\":\"0B 88 19 19 02\"}";
|
// char dataX[] = "{\"value\":\"0B 88 19 19 02\"}";
|
||||||
char dataX[] = "{\"name\":\"temp\",\"value\":11}";
|
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));
|
strlcpy(command_s, "hc3_seltemp", sizeof(command_s));
|
||||||
ncmd = Command::parse_command_string(command_s, id_n);
|
ncmd = Command::parse_command_string(command_s, id_n);
|
||||||
shell.printfln("test cmd parse cmd=%s id=%d", ncmd, id_n);
|
shell.printfln("test cmd parse cmd=%s id=%d", ncmd, id_n);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Console tests
|
// Console tests
|
||||||
@@ -1037,8 +1100,8 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
json = doc.as<JsonVariant>();
|
json = doc.as<JsonVariant>();
|
||||||
request.url("/api/thermostat/mode/auto");
|
request.url("/api/thermostat/mode/auto");
|
||||||
EMSESP::webAPIService.webAPIService_post(&request, json);
|
EMSESP::webAPIService.webAPIService_post(&request, json);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "mqtt_nested") {
|
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);
|
Mqtt::nested_format(2);
|
||||||
shell.invoke_command("call system publish");
|
shell.invoke_command("call system publish");
|
||||||
shell.invoke_command("show mqtt");
|
shell.invoke_command("show mqtt");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "thermostat") {
|
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}");
|
EMSESP::mqtt_.incoming("ems-esp/thermostat_hc3", "{\"cmd\":\"temp\",\"data\":-3}");
|
||||||
|
|
||||||
shell.invoke_command("show mqtt");
|
shell.invoke_command("show mqtt");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "tc100") {
|
if (command == "tc100") {
|
||||||
@@ -1086,6 +1151,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
// 0x0A
|
// 0x0A
|
||||||
uart_telegram({0x98, 0x0B, 0x0A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
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});
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "solar") {
|
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");
|
shell.invoke_command("call system publish");
|
||||||
|
|
||||||
// EMSESP::txservice_.send_raw("B0 00 FF 18 02 62 80 00 B8");
|
// EMSESP::txservice_.send_raw("B0 00 FF 18 02 62 80 00 B8");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "heatpump") {
|
if (command == "heatpump") {
|
||||||
@@ -1106,6 +1173,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
run_test("heatpump");
|
run_test("heatpump");
|
||||||
shell.invoke_command("call");
|
shell.invoke_command("call");
|
||||||
shell.invoke_command("call heatpump info");
|
shell.invoke_command("call heatpump info");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "solar200") {
|
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
|
uart_telegram("30 00 FF 0A 02 6A 03"); // SM100 pump off 0
|
||||||
|
|
||||||
shell.invoke_command("show");
|
shell.invoke_command("show");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "km") {
|
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_ems(shell);
|
||||||
EMSESP::show_device_values(shell);
|
EMSESP::show_device_values(shell);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "cr100") {
|
if (command == "cr100") {
|
||||||
@@ -1214,6 +1284,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
shell.loop_all();
|
shell.loop_all();
|
||||||
|
|
||||||
EMSESP::txservice_.send(); // send it to UART
|
EMSESP::txservice_.send(); // send it to UART
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "rx2") {
|
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++) {
|
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});
|
uart_telegram({0x08, 0x0B, 0x33, 0x00, 0x08, 0xFF, 0x34, 0xFB, 0x00, 0x28, 0x00, 0x00, 0x46, 0x00, 0xFF, 0xFF, 0x00});
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "rx") {
|
if (command == "rx") {
|
||||||
@@ -1278,6 +1350,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
|
|
||||||
// test 0x2A - DHWStatus3
|
// 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});
|
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") {
|
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++) {
|
for (uint8_t i = 0; i < 10; i++) {
|
||||||
EMSESP::txservice_.send(); // send it to UART
|
EMSESP::txservice_.send(); // send it to UART
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "poll") {
|
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};
|
uint8_t t2[] = {0x21, 0x22};
|
||||||
EMSESP::send_write_request(0x91, 0x17, 0x00, t2, sizeof(t2), 0);
|
EMSESP::send_write_request(0x91, 0x17, 0x00, t2, sizeof(t2), 0);
|
||||||
EMSESP::show_ems(shell);
|
EMSESP::show_ems(shell);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "cmd") {
|
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 wwmode"); // should do nothing
|
||||||
shell.invoke_command("call thermostat mode auto 2"); // should error, no hc2
|
shell.invoke_command("call thermostat mode auto 2"); // should error, no hc2
|
||||||
shell.invoke_command("call thermostat temp 22.56");
|
shell.invoke_command("call thermostat temp 22.56");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "pin") {
|
if (command == "pin") {
|
||||||
shell.printfln("Testing pin...");
|
shell.printfln("Testing pin...");
|
||||||
shell.invoke_command("call system pin");
|
shell.invoke_command("call system pin");
|
||||||
shell.invoke_command("call system pin 1 true");
|
shell.invoke_command("call system pin 1 true");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "mqtt2") {
|
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::publish("test", jo);
|
||||||
Mqtt::show_mqtt(shell); // show queue
|
Mqtt::show_mqtt(shell); // show queue
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "mqtt") {
|
if (command == "mqtt") {
|
||||||
@@ -1494,6 +1572,7 @@ void Test::run_test(uuid::console::Shell & shell, const std::string & cmd, const
|
|||||||
|
|
||||||
Mqtt::resubscribe();
|
Mqtt::resubscribe();
|
||||||
Mqtt::show_mqtt(shell); // show queue
|
Mqtt::show_mqtt(shell); // show queue
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "poll2") {
|
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::incoming_telegram(poll, 1);
|
||||||
|
|
||||||
EMSESP::show_ems(shell);
|
EMSESP::show_ems(shell);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "rx2") {
|
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,
|
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});
|
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
|
// 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...");
|
shell.printfln("Testing rx3...");
|
||||||
|
|
||||||
uart_telegram({0x21, 0x0B, 0xFF, 0x00});
|
uart_telegram({0x21, 0x0B, 0xFF, 0x00});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// testing the UART tx command, without a queue
|
// 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
|
uint8_t t[] = {0x0B, 0x88, 0x18, 0x00, 0x20, 0xD4}; // including CRC
|
||||||
EMSuart::transmit(t, sizeof(t));
|
EMSuart::transmit(t, sizeof(t));
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// send read request with offset
|
// 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);
|
// send_read_request(0x18, 0x08);
|
||||||
EMSESP::txservice_.read_request(0x18, 0x08, 27); // no offset
|
EMSESP::txservice_.read_request(0x18, 0x08, 27); // no offset
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "mixer") {
|
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");
|
request.url("/api/mixer/wwc2/pumpstatus");
|
||||||
EMSESP::webAPIService.webAPIService_get(&request);
|
EMSESP::webAPIService.webAPIService_get(&request);
|
||||||
#endif
|
#endif
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (command == "crash") {
|
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);
|
shell.printfln("Testing %s", a);
|
||||||
|
|
||||||
#pragma GCC diagnostic pop
|
#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") {
|
#endif // EMSES_STANDALONE
|
||||||
shell.printfln("Run a limited memory test...");
|
|
||||||
|
|
||||||
run_test("general");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// simulates a telegram in the Rx queue, but without the CRC which is added automatically
|
// simulates a telegram in the Rx queue, but without the CRC which is added automatically
|
||||||
|
|||||||
@@ -28,7 +28,6 @@ namespace emsesp {
|
|||||||
|
|
||||||
// #define EMSESP_DEBUG_DEFAULT "thermostat"
|
// #define EMSESP_DEBUG_DEFAULT "thermostat"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "solar"
|
// #define EMSESP_DEBUG_DEFAULT "solar"
|
||||||
#define EMSESP_DEBUG_DEFAULT "mixer"
|
|
||||||
// #define EMSESP_DEBUG_DEFAULT "web"
|
// #define EMSESP_DEBUG_DEFAULT "web"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "mqtt"
|
// #define EMSESP_DEBUG_DEFAULT "mqtt"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "general"
|
// #define EMSESP_DEBUG_DEFAULT "general"
|
||||||
@@ -52,7 +51,8 @@ namespace emsesp {
|
|||||||
// #define EMSESP_DEBUG_DEFAULT "mqtt_post"
|
// #define EMSESP_DEBUG_DEFAULT "mqtt_post"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "api_wwmode"
|
// #define EMSESP_DEBUG_DEFAULT "api_wwmode"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "custom"
|
// #define EMSESP_DEBUG_DEFAULT "custom"
|
||||||
// #define EMSESP_DEBUG_DEFAULT "dump"
|
// #define EMSESP_DEBUG_DEFAULT "entity_dump"
|
||||||
|
#define EMSESP_DEBUG_DEFAULT "memory"
|
||||||
|
|
||||||
class Test {
|
class Test {
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user