fix crashes, clean up, update packages

This commit is contained in:
MichaelDvP
2022-12-22 18:47:21 +01:00
parent d300ed38ea
commit f66e7712c3
7 changed files with 781 additions and 542 deletions

View File

@@ -1,5 +1,5 @@
{ {
"adapter": "react", "adapter": "react",
"baseLocale": "pl", "baseLocale": "pl",
"$schema": "https://unpkg.com/typesafe-i18n@5.17.2/schema/typesafe-i18n.json" "$schema": "https://unpkg.com/typesafe-i18n@5.18.0/schema/typesafe-i18n.json"
} }

File diff suppressed because it is too large Load Diff

View File

@@ -8,7 +8,7 @@
"@emotion/styled": "^11.10.5", "@emotion/styled": "^11.10.5",
"@msgpack/msgpack": "^2.8.0", "@msgpack/msgpack": "^2.8.0",
"@mui/icons-material": "^5.11.0", "@mui/icons-material": "^5.11.0",
"@mui/material": "^5.11.0", "@mui/material": "^5.11.1",
"@table-library/react-table-library": "4.0.23", "@table-library/react-table-library": "4.0.23",
"@types/lodash": "^4.14.191", "@types/lodash": "^4.14.191",
"@types/node": "^18.11.17", "@types/node": "^18.11.17",
@@ -27,10 +27,10 @@
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-dropzone": "^14.2.3", "react-dropzone": "^14.2.3",
"react-icons": "^4.7.1", "react-icons": "^4.7.1",
"react-router-dom": "^6.5.0", "react-router-dom": "^6.6.0",
"react-scripts": "5.0.1", "react-scripts": "5.0.1",
"sockette": "^2.0.6", "sockette": "^2.0.6",
"typesafe-i18n": "^5.17.2", "typesafe-i18n": "^5.18.0",
"typescript": "^4.9.4" "typescript": "^4.9.4"
}, },
"scripts": { "scripts": {

View File

@@ -250,13 +250,7 @@ uint8_t Command::call(const uint8_t device_type, const char * cmd, const char *
uint8_t return_code = CommandRet::OK; uint8_t return_code = CommandRet::OK;
auto dname = EMSdevice::device_type_2_device_name(device_type); auto dname = EMSdevice::device_type_2_device_name(device_type);
uint8_t device_id = EMSESP::device_id_from_cmd(device_type, id, cmd);
uint8_t device_id = 0;
for (const auto & emsdevice : emsesp::EMSESP::emsdevices) {
if (emsdevice->device_type() == device_type && emsdevice->has_cmd(id, cmd)) {
device_id = emsdevice->device_id();
}
}
// see if there is a command registered // see if there is a command registered
auto cf = find_command(device_type, device_id, cmd); auto cf = find_command(device_type, device_id, cmd);

View File

@@ -813,9 +813,9 @@ void EMSdevice::generate_values_web(JsonObject & output) {
} else if ((dv.type == DeviceValueType::USHORT) && Helpers::hasValue(*(uint16_t *)(dv.value_p))) { } else if ((dv.type == DeviceValueType::USHORT) && Helpers::hasValue(*(uint16_t *)(dv.value_p))) {
obj["v"] = Helpers::transformNumFloat(*(uint16_t *)(dv.value_p), dv.numeric_operator, fahrenheit); obj["v"] = Helpers::transformNumFloat(*(uint16_t *)(dv.value_p), dv.numeric_operator, fahrenheit);
} else if ((dv.type == DeviceValueType::ULONG) && Helpers::hasValue(*(uint32_t *)(dv.value_p))) { } else if ((dv.type == DeviceValueType::ULONG) && Helpers::hasValue(*(uint32_t *)(dv.value_p))) {
obj["v"] = (*(uint32_t *)(dv.value_p) / dv.numeric_operator); // ULONG always have positive num_op obj["v"] = dv.numeric_operator > 0 ? *(uint32_t *)(dv.value_p) / dv.numeric_operator : *(uint32_t *)(dv.value_p);
} else if ((dv.type == DeviceValueType::TIME) && Helpers::hasValue(*(uint32_t *)(dv.value_p))) { } else if ((dv.type == DeviceValueType::TIME) && Helpers::hasValue(*(uint32_t *)(dv.value_p))) {
obj["v"] = (*(uint32_t *)(dv.value_p) / dv.numeric_operator); obj["v"] = dv.numeric_operator > 0 ? *(uint32_t *)(dv.value_p) / dv.numeric_operator : *(uint32_t *)(dv.value_p);
} else { } else {
obj["v"] = ""; // must have a value for sorting to work obj["v"] = ""; // must have a value for sorting to work
} }
@@ -923,9 +923,9 @@ void EMSdevice::generate_values_web_customization(JsonArray & output) {
} else if (dv.type == DeviceValueType::USHORT) { } else if (dv.type == DeviceValueType::USHORT) {
obj["v"] = Helpers::transformNumFloat(*(uint16_t *)(dv.value_p), dv.numeric_operator, fahrenheit); obj["v"] = Helpers::transformNumFloat(*(uint16_t *)(dv.value_p), dv.numeric_operator, fahrenheit);
} else if (dv.type == DeviceValueType::ULONG) { } else if (dv.type == DeviceValueType::ULONG) {
obj["v"] = (*(uint32_t *)(dv.value_p) / dv.numeric_operator); obj["v"] = dv.numeric_operator > 0 ? *(uint32_t *)(dv.value_p) / dv.numeric_operator : *(uint32_t *)(dv.value_p);
} else if (dv.type == DeviceValueType::TIME) { } else if (dv.type == DeviceValueType::TIME) {
obj["v"] = (*(uint32_t *)(dv.value_p) / dv.numeric_operator); obj["v"] = dv.numeric_operator > 0 ? *(uint32_t *)(dv.value_p) / dv.numeric_operator : *(uint32_t *)(dv.value_p);
} }
} }
} }

View File

@@ -114,6 +114,15 @@ bool EMSESP::cmd_is_readonly(const uint8_t device_type, const uint8_t device_id,
return false; return false;
} }
uint8_t EMSESP::device_id_from_cmd(const uint8_t device_type, const int8_t id, const char * cmd) {
for (const auto & emsdevice : emsdevices) {
if (emsdevice && emsdevice->device_type() == device_type && emsdevice->has_cmd(id, cmd)) {
return emsdevice->device_id();
}
}
return 0;
}
// clears list of recognized devices // clears list of recognized devices
void EMSESP::clear_all_devices() { void EMSESP::clear_all_devices() {
// temporarily removed: clearing the list causes a crash, the associated commands and mqtt should also be removed. // temporarily removed: clearing the list causes a crash, the associated commands and mqtt should also be removed.

View File

@@ -131,6 +131,7 @@ class EMSESP {
static bool device_exists(const uint8_t device_id); static bool device_exists(const uint8_t device_id);
static bool cmd_is_readonly(const uint8_t device_type, const uint8_t device_id, const char * cmd, const int8_t id); static bool cmd_is_readonly(const uint8_t device_type, const uint8_t device_id, const char * cmd, const int8_t id);
static uint8_t device_id_from_cmd(const uint8_t device_type, const int8_t id, const char * cmd);
static uint8_t count_devices(const uint8_t device_type); static uint8_t count_devices(const uint8_t device_type);
static uint8_t count_devices(); static uint8_t count_devices();
static uint8_t device_index(const uint8_t device_type, const uint8_t unique_id); static uint8_t device_index(const uint8_t device_type, const uint8_t unique_id);