mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 08:49:52 +03:00
add device version & product getter functions
This commit is contained in:
@@ -82,6 +82,10 @@ class EMSdevice {
|
|||||||
version_ = version;
|
version_ = version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline std::string version() const {
|
||||||
|
return version_;
|
||||||
|
}
|
||||||
|
|
||||||
inline void brand(uint8_t brand) {
|
inline void brand(uint8_t brand) {
|
||||||
brand_ = brand;
|
brand_ = brand;
|
||||||
}
|
}
|
||||||
@@ -94,6 +98,10 @@ class EMSdevice {
|
|||||||
name_ = name;
|
name_ = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline std::string name() const {
|
||||||
|
return name_;
|
||||||
|
}
|
||||||
|
|
||||||
std::string brand_to_string() const;
|
std::string brand_to_string() const;
|
||||||
static uint8_t decode_brand(uint8_t value);
|
static uint8_t decode_brand(uint8_t value);
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ EMSESPSettingsService EMSESP::emsespSettingsService = EMSESPSettingsService(&web
|
|||||||
EMSESPStatusService EMSESP::emsespStatusService =
|
EMSESPStatusService EMSESP::emsespStatusService =
|
||||||
EMSESPStatusService(&webServer, EMSESP::esp8266React.getSecurityManager(), EMSESP::esp8266React.getMqttClient());
|
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<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
|
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;
|
uint32_t EMSESP::last_fetch_ = 0;
|
||||||
|
|
||||||
// for a specific EMS device go and request data values
|
// 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) {
|
void EMSESP::fetch_device_values(const uint8_t device_id) {
|
||||||
for (const auto & emsdevice : emsdevices) {
|
for (const auto & emsdevice : emsdevices) {
|
||||||
if (emsdevice) {
|
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) {
|
void EMSESP::reset_tx(uint8_t const tx_mode) {
|
||||||
txservice_.telegram_read_count(0);
|
txservice_.telegram_read_count(0);
|
||||||
txservice_.telegram_write_count(0);
|
txservice_.telegram_write_count(0);
|
||||||
txservice_.telegram_fail_count(0);
|
txservice_.telegram_fail_count(0);
|
||||||
if (tx_mode) {
|
if (tx_mode) {
|
||||||
EMSuart::stop();
|
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 <ESP8266React.h>
|
||||||
#include "EMSESPStatusService.h"
|
#include "EMSESPStatusService.h"
|
||||||
|
#include "EMSESPDevicesService.h"
|
||||||
#include "EMSESPSettingsService.h"
|
#include "EMSESPSettingsService.h"
|
||||||
|
|
||||||
#include "emsdevice.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 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 Mqtt mqtt_;
|
||||||
static System system_;
|
static System system_;
|
||||||
static Sensors sensors_;
|
static Sensors sensors_;
|
||||||
@@ -144,6 +147,7 @@ class EMSESP {
|
|||||||
static ESP8266React esp8266React;
|
static ESP8266React esp8266React;
|
||||||
static EMSESPSettingsService emsespSettingsService;
|
static EMSESPSettingsService emsespSettingsService;
|
||||||
static EMSESPStatusService emsespStatusService;
|
static EMSESPStatusService emsespStatusService;
|
||||||
|
static EMSESPDevicesService emsespDevicesService;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EMSESP() = delete;
|
EMSESP() = delete;
|
||||||
@@ -165,7 +169,6 @@ class EMSESP {
|
|||||||
uint8_t flags;
|
uint8_t flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::vector<std::unique_ptr<EMSdevice>> emsdevices;
|
|
||||||
static std::vector<Device_record> device_library_;
|
static std::vector<Device_record> device_library_;
|
||||||
|
|
||||||
static uint8_t actual_master_thermostat_;
|
static uint8_t actual_master_thermostat_;
|
||||||
|
|||||||
Reference in New Issue
Block a user