diff --git a/src/emsdevice.h b/src/emsdevice.h index 55de3445c..8b691bcee 100644 --- a/src/emsdevice.h +++ b/src/emsdevice.h @@ -82,6 +82,10 @@ class EMSdevice { version_ = version; } + inline std::string version() const { + return version_; + } + inline void brand(uint8_t brand) { brand_ = brand; } @@ -94,6 +98,10 @@ class EMSdevice { name_ = name; } + inline std::string name() const { + return name_; + } + std::string brand_to_string() const; static uint8_t decode_brand(uint8_t value); diff --git a/src/emsesp.cpp b/src/emsesp.cpp index bd81b8147..638c2b92e 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -38,6 +38,8 @@ EMSESPSettingsService EMSESP::emsespSettingsService = EMSESPSettingsService(&web EMSESPStatusService EMSESP::emsespStatusService = EMSESPStatusService(&webServer, EMSESP::esp8266React.getSecurityManager(), EMSESP::esp8266React.getMqttClient()); +EMSESPDevicesService EMSESP::emsespDevicesService = EMSESPDevicesService(&webServer, EMSESP::esp8266React.getSecurityManager()); + std::vector> EMSESP::emsdevices; // array of all the detected EMS devices std::vector EMSESP::device_library_; // libary of all our known EMS devices so far @@ -60,7 +62,7 @@ bool EMSESP::tap_water_active_ = false; / uint32_t EMSESP::last_fetch_ = 0; // for a specific EMS device go and request data values -// or if device_id is 0 it will fetch from all known devices +// or if device_id is 0 it will fetch from all our known and active devices void EMSESP::fetch_device_values(const uint8_t device_id) { for (const auto & emsdevice : emsdevices) { if (emsdevice) { @@ -103,13 +105,16 @@ void EMSESP::watch_id(uint16_t watch_id) { } } +// change the tx_mode +// resets all counters and bumps the UART void EMSESP::reset_tx(uint8_t const tx_mode) { txservice_.telegram_read_count(0); txservice_.telegram_write_count(0); txservice_.telegram_fail_count(0); if (tx_mode) { EMSuart::stop(); - EMSuart::start(tx_mode); // reset the UART + EMSuart::start(tx_mode); + EMSESP::fetch_device_values(); } } diff --git a/src/emsesp.h b/src/emsesp.h index afe885d17..50c8f5bb1 100644 --- a/src/emsesp.h +++ b/src/emsesp.h @@ -35,6 +35,7 @@ #include #include "EMSESPStatusService.h" +#include "EMSESPDevicesService.h" #include "EMSESPSettingsService.h" #include "emsdevice.h" @@ -133,6 +134,8 @@ class EMSESP { static bool add_device(const uint8_t device_id, const uint8_t product_id, std::string & version, const uint8_t brand); + static std::vector> emsdevices; + static Mqtt mqtt_; static System system_; static Sensors sensors_; @@ -144,6 +147,7 @@ class EMSESP { static ESP8266React esp8266React; static EMSESPSettingsService emsespSettingsService; static EMSESPStatusService emsespStatusService; + static EMSESPDevicesService emsespDevicesService; private: EMSESP() = delete; @@ -165,7 +169,6 @@ class EMSESP { uint8_t flags; }; - static std::vector> emsdevices; static std::vector device_library_; static uint8_t actual_master_thermostat_;