Merge pull request #2745 from MichaelDvP/dev

process_telegram in single loop, update AsyncWebServer, dev30
This commit is contained in:
Proddy
2025-11-15 16:26:23 +01:00
committed by GitHub
5 changed files with 39 additions and 55 deletions

View File

@@ -66,3 +66,4 @@ For more details go to [docs.emsesp.org](https://docs.emsesp.org/).
- double click button reconnects EMS-ESP to AP
- place system message command in side scheduler loop to reduce stack memory usage by 2KB
- syslog mark interval set to 1 hour
- handle process_telegram in oneloop

View File

@@ -106,7 +106,7 @@ board_build.filesystem = littlefs
lib_deps =
bblanchon/ArduinoJson @ 7.4.2
ESP32Async/AsyncTCP @ 3.4.9
ESP32Async/ESPAsyncWebServer @ 3.8.1
ESP32Async/ESPAsyncWebServer @ 3.9.0
https://github.com/emsesp/EMS-ESP-Modules.git @ 1.0.8

View File

@@ -1157,6 +1157,10 @@ bool EMSESP::process_telegram(std::shared_ptr<const Telegram> telegram) {
return false;
}
if (wait_validate_ == telegram->type_id) {
wait_validate_ = 0;
}
// Check for custom entities reding this telegram
webCustomEntityService.get_value(telegram);
@@ -1180,50 +1184,16 @@ bool EMSESP::process_telegram(std::shared_ptr<const Telegram> telegram) {
// returns false if the device_id doesn't recognize it
// after the telegram has been processed, see if there have been values changed and we need to do a MQTT publish
bool telegram_found = false;
uint8_t device_found = 0;
EMSdevice * found_device = nullptr;
// check all conditions
// check all conditions in one loop
for (const auto & emsdevice : emsdevices) {
// broadcast or send to us
if (emsdevice->is_device_id(telegram->src) && (telegram->dest == 0 || telegram->dest == EMSbus::ems_bus_id())) {
telegram_found = emsdevice->handle_telegram(telegram);
if ((emsdevice->is_device_id(telegram->src) && (telegram->dest == 0 || telegram->dest == EMSbus::ems_bus_id() || telegram->dest == 0x10))
|| (emsdevice->is_device_id(telegram->dest) && telegram->src != EMSbus::ems_bus_id())) {
found_device = emsdevice.get();
break;
}
}
if (!telegram_found) {
for (const auto & emsdevice : emsdevices) {
// check for command to the device
if (emsdevice->is_device_id(telegram->dest) && telegram->src != EMSbus::ems_bus_id()) {
telegram_found = emsdevice->handle_telegram(telegram);
found_device = emsdevice.get();
break;
}
}
}
if (!telegram_found) {
for (const auto & emsdevice : emsdevices) {
// check for sends to master thermostat
if (emsdevice->is_device_id(telegram->src) && telegram->dest == 0x10) {
telegram_found = emsdevice->handle_telegram(telegram);
found_device = emsdevice.get();
break;
}
}
}
if (found_device) {
device_found = found_device->unique_id();
// Process the found device directly without another loop
if (!telegram_found && telegram->message_length > 0) {
found_device->add_handlers_ignored(telegram->type_id);
}
if (wait_validate_ == telegram->type_id) {
wait_validate_ = 0;
}
if (Mqtt::connected() && telegram_found
if (emsdevice->handle_telegram(telegram)) {
telegram_found = true;
if (Mqtt::connected()
&& ((mqtt_.get_publish_onchange(found_device->device_type()) && found_device->has_update())
|| (telegram->type_id == publish_id_ && telegram->dest == EMSbus::ems_bus_id()))) {
if (telegram->type_id == publish_id_) {
@@ -1234,18 +1204,27 @@ bool EMSESP::process_telegram(std::shared_ptr<const Telegram> telegram) {
publish_device_values(found_device->device_type()); // publish to MQTT if we explicitly have too
}
}
break; // remove this to handle same telegrams on multiple devices
}
}
}
// handle unknown telegrams
if (!telegram_found) {
// mark nonempty telegrams as ignored
if (found_device && telegram->message_length > 0) {
found_device->add_handlers_ignored(telegram->type_id);
}
// handle unknown broadcasted telegrams (or send to us)
if (!telegram_found && (telegram->dest == 0 || telegram->dest == EMSbus::ems_bus_id())) {
if (telegram->dest == 0 || telegram->dest == EMSbus::ems_bus_id()) {
LOG_DEBUG("No telegram type handler found for ID 0x%02X (src 0x%02X)", telegram->type_id, telegram->src);
if (watch() == WATCH_UNKNOWN) {
LOG_NOTICE("%s", pretty_telegram(telegram).c_str());
}
if (!wait_km_ && !device_found && (telegram->src != EMSbus::ems_bus_id()) && (telegram->message_length > 0)) {
if (!wait_km_ && !found_device && (telegram->src != EMSbus::ems_bus_id()) && (telegram->message_length > 0)) {
send_read_request(EMSdevice::EMS_TYPE_VERSION, telegram->src);
}
}
}
return telegram_found;
}

View File

@@ -766,8 +766,12 @@ void Thermostat::process_RC20Remote(std::shared_ptr<const Telegram> telegram) {
// 0x42B - for reading the roomtemperature from the RC100H remote thermostat (0x38, 0x39, ..)
// e.g. "38 10 FF 00 03 2B 00 D1 08 2A 01"
// also RF temp from 0x435
void Thermostat::process_RemoteTemp(std::shared_ptr<const Telegram> telegram) {
has_update(telegram, tempsensor1_, 0);
if (telegram->type_id >= 0x435) {
return;
}
uint8_t hc = telegram->type_id - 0x42B;
if (Roomctrl::is_remote(hc)) {
toggle_fetch(0x273 + hc, false);

View File

@@ -1 +1 @@
#define EMSESP_APP_VERSION "3.7.3-dev.29"
#define EMSESP_APP_VERSION "3.7.3-dev.30"