mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 00:39:50 +03:00
telegram functions can't be static - #445
This commit is contained in:
@@ -26,6 +26,8 @@ uuid::log::Logger Boiler::logger_{F_(boiler), uuid::log::Facility::CONSOLE};
|
||||
|
||||
Boiler::Boiler(uint8_t device_type, int8_t device_id, uint8_t product_id, const std::string & version, const std::string & name, uint8_t flags, uint8_t brand)
|
||||
: EMSdevice(device_type, device_id, product_id, version, name, flags, brand) {
|
||||
this->reserve_mem(20); // reserve some space for the telegram registries, to avoid memory fragmentation
|
||||
|
||||
LOG_DEBUG(F("Adding new Boiler with device ID 0x%02X"), device_id);
|
||||
|
||||
// the telegram handlers...
|
||||
|
||||
@@ -26,6 +26,8 @@ uuid::log::Logger Thermostat::logger_{F_(thermostat), uuid::log::Facility::CONSO
|
||||
|
||||
Thermostat::Thermostat(uint8_t device_type, uint8_t device_id, uint8_t product_id, const std::string & version, const std::string & name, uint8_t flags, uint8_t brand)
|
||||
: EMSdevice(device_type, device_id, product_id, version, name, flags, brand) {
|
||||
this->reserve_mem(25); // reserve some space for the telegram registries, to avoid memory fragmentation
|
||||
|
||||
// common telegram handlers
|
||||
register_telegram_type(EMS_TYPE_RCOutdoorTemp, F("RCOutdoorTemp"), false, [&](std::shared_ptr<const Telegram> t) { process_RCOutdoorTemp(t); });
|
||||
register_telegram_type(EMS_TYPE_RCTime, F("RCTime"), false, [&](std::shared_ptr<const Telegram> t) { process_RCTime(t); });
|
||||
|
||||
@@ -24,8 +24,6 @@ namespace emsesp {
|
||||
|
||||
uuid::log::Logger EMSdevice::logger_{F_(emsesp), uuid::log::Facility::CONSOLE};
|
||||
|
||||
std::vector<EMSdevice::TelegramFunction> EMSdevice::telegram_functions_;
|
||||
|
||||
std::string EMSdevice::brand_to_string() const {
|
||||
switch (brand_) {
|
||||
case EMSdevice::Brand::BOSCH:
|
||||
@@ -248,7 +246,6 @@ void EMSdevice::register_mqtt_topic(const std::string & topic, mqtt_subfunction_
|
||||
}
|
||||
|
||||
void EMSdevice::register_mqtt_cmd(const __FlashStringHelper * cmd, mqtt_cmdfunction_p f) {
|
||||
LOG_DEBUG(F("Registering MQTT cmd %s for device type %s"), uuid::read_flash_string(cmd).c_str(), this->device_type_name().c_str());
|
||||
Mqtt::add_command(this->device_type_, this->device_id_, cmd, f);
|
||||
}
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ class EMSdevice {
|
||||
void fetch_values();
|
||||
void toggle_fetch(uint16_t telegram_id, bool toggle);
|
||||
|
||||
static void reserve_mem(size_t n) {
|
||||
void reserve_mem(size_t n) {
|
||||
telegram_functions_.reserve(n);
|
||||
}
|
||||
|
||||
@@ -229,8 +229,7 @@ class EMSdevice {
|
||||
};
|
||||
|
||||
enum DeviceType : uint8_t {
|
||||
UNKNOWN = 0,
|
||||
SERVICEKEY, // us
|
||||
SERVICEKEY = 0, // this is us
|
||||
BOILER,
|
||||
THERMOSTAT,
|
||||
MIXING,
|
||||
@@ -280,11 +279,11 @@ class EMSdevice {
|
||||
|
||||
private:
|
||||
uint8_t unique_id_;
|
||||
uint8_t device_type_ = DeviceType::UNKNOWN;
|
||||
uint8_t device_type_ = DeviceType::SERVICEKEY;
|
||||
uint8_t device_id_ = 0;
|
||||
uint8_t product_id_ = 0;
|
||||
std::string version_;
|
||||
std::string name_; // the long name of the EMS model
|
||||
std::string name_; // the long name for the EMS model
|
||||
uint8_t flags_ = 0;
|
||||
uint8_t brand_ = Brand::NO_BRAND;
|
||||
|
||||
@@ -304,7 +303,7 @@ class EMSdevice {
|
||||
, process_function_(process_function) {
|
||||
}
|
||||
};
|
||||
static std::vector<TelegramFunction> telegram_functions_; // each EMS device has its own set of registered telegram types
|
||||
std::vector<TelegramFunction> telegram_functions_; // each EMS device has its own set of registered telegram types
|
||||
};
|
||||
|
||||
} // namespace emsesp
|
||||
|
||||
@@ -573,7 +573,7 @@ void EMSESP::show_devices(uuid::console::Shell & shell) {
|
||||
}
|
||||
shell.println();
|
||||
emsdevice->show_telegram_handlers(shell);
|
||||
emsdevice->show_mqtt_handlers(shell);
|
||||
// emsdevice->show_mqtt_handlers(shell);
|
||||
shell.println();
|
||||
}
|
||||
}
|
||||
@@ -793,19 +793,21 @@ void EMSESP::start() {
|
||||
esp8266React.begin(); // loads system settings (wifi, mqtt, etc)
|
||||
emsespSettingsService.begin(); // load EMS-ESP specific settings
|
||||
// system_.check_upgrade(); // see if we need to migrate from previous versions
|
||||
mqtt_.start(); // mqtt init
|
||||
console_.start(); // telnet and serial console
|
||||
mqtt_.start(); // mqtt init
|
||||
system_.start(); // starts syslog, uart, sets version, initializes LED. Requires pre-loaded settings.
|
||||
shower_.start(); // initialize shower timer and shower alert
|
||||
txservice_.start(); // sets bus ID, sends out request for EMS devices
|
||||
sensors_.start(); // dallas external sensors
|
||||
webServer.begin(); // start web server
|
||||
|
||||
// reserve some space for the telegram registries, to avoid memory fragmentation
|
||||
EMSdevice::reserve_mem(EMSdevice::EMS_DEVICES_MAX_TELEGRAMS); // space for 20 telegram handlers
|
||||
emsdevices.reserve(5); // reserve space for initially 5 devices
|
||||
emsdevices.reserve(5); // reserve space for initially 5 devices to avoid mem
|
||||
|
||||
LOG_INFO("EMS Device library loaded with %d records", device_library_.size());
|
||||
|
||||
#if defined(EMSESP_STANDALONE)
|
||||
mqtt_.on_connect(); // simulate an MQTT connection
|
||||
#endif
|
||||
}
|
||||
|
||||
// main loop calling all services
|
||||
|
||||
Reference in New Issue
Block a user