mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
add device version & product getter functions
This commit is contained in:
@@ -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);
|
||||
|
||||
|
||||
@@ -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<std::unique_ptr<EMSdevice>> EMSESP::emsdevices; // array of all the detected EMS devices
|
||||
std::vector<emsesp::EMSESP::Device_record> 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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
|
||||
#include <ESP8266React.h>
|
||||
#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<std::unique_ptr<EMSdevice>> 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<std::unique_ptr<EMSdevice>> emsdevices;
|
||||
static std::vector<Device_record> device_library_;
|
||||
|
||||
static uint8_t actual_master_thermostat_;
|
||||
|
||||
Reference in New Issue
Block a user