Merge remote-tracking branch 'emsesp/core3' into core3

This commit is contained in:
MichaelDvP
2026-07-13 14:55:37 +02:00
8 changed files with 83 additions and 61 deletions

View File

@@ -88,12 +88,13 @@ class Module {}; // forward declaration
//
// MAKE_PF_CB(member) produces a non-capturing trampoline that decays to a
// plain function pointer (EMSdevice::process_function_p). The outer IILE
// (immediately-invoked lambda expression) captures `this` purely to deduce
// the derived-class type via decltype; the inner lambda is non-capturing and
// therefore convertible to a function pointer via the unary `+` operator.
// (immediately-invoked lambda expression) uses `decltype(this)` in an
// unevaluated context to deduce the derived-class type without capturing
// `this`; the inner lambda is non-capturing and therefore convertible to a
// function pointer via the unary `+` operator.
// Result: zero heap (no std::function control block) and direct dispatch.
#define MAKE_PF_CB(__f) \
([this]() { \
([]() { \
using SelfT = std::remove_pointer_t<decltype(this)>; \
return +[](emsesp::EMSdevice * dev, const std::shared_ptr<const Telegram> & t) { static_cast<SelfT *>(dev)->__f(t); }; \
}())

View File

@@ -64,8 +64,8 @@ void WebDataService::core_data(AsyncWebServerRequest * request) {
// list is already sorted by device type
JsonArray devices = root["devices"].to<JsonArray>();
for (const auto & emsdevice : EMSESP::emsdevices) {
// ignore controller
if (emsdevice && (emsdevice->device_type() != EMSdevice::DeviceType::CONTROLLER || emsdevice->count_entities() > 0)) {
// ignore controller and gateway
if (emsdevice && (emsdevice->device_type() != EMSdevice::DeviceType::CONTROLLER && emsdevice->device_type() != EMSdevice::DeviceType::GATEWAY && emsdevice->count_entities() > 0)) {
JsonObject obj = devices.add<JsonObject>();
obj["id"] = emsdevice->unique_id(); // a unique id
obj["tn"] = emsdevice->device_type_2_device_name_translated(); // translated device type name