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

@@ -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