mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 00:39:50 +03:00
move device unique_id count into constructor
This commit is contained in:
@@ -43,6 +43,7 @@ class EMSdevice {
|
|||||||
, name_(name)
|
, name_(name)
|
||||||
, flags_(flags)
|
, flags_(flags)
|
||||||
, brand_(brand) {
|
, brand_(brand) {
|
||||||
|
unique_id_++;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~EMSdevice() = default; // destructor of base class must always be virtual because it's a polymorphic class
|
virtual ~EMSdevice() = default; // destructor of base class must always be virtual because it's a polymorphic class
|
||||||
@@ -270,7 +271,7 @@ class EMSdevice {
|
|||||||
static constexpr uint8_t EMS_DEVICE_FLAG_JUNKERS_2 = (1 << 6); // 6th bit set if older models, like FR120, FR100
|
static constexpr uint8_t EMS_DEVICE_FLAG_JUNKERS_2 = (1 << 6); // 6th bit set if older models, like FR120, FR100
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint8_t unique_id_;
|
uint8_t unique_id_ = 0;
|
||||||
uint8_t device_type_ = DeviceType::SYSTEM;
|
uint8_t device_type_ = DeviceType::SYSTEM;
|
||||||
uint8_t device_id_ = 0;
|
uint8_t device_id_ = 0;
|
||||||
uint8_t product_id_ = 0;
|
uint8_t product_id_ = 0;
|
||||||
|
|||||||
@@ -63,7 +63,6 @@ bool EMSESP::read_next_ = false;
|
|||||||
uint16_t EMSESP::publish_id_ = 0;
|
uint16_t EMSESP::publish_id_ = 0;
|
||||||
bool EMSESP::tap_water_active_ = false; // for when Boiler states we having running warm water. used in Shower()
|
bool EMSESP::tap_water_active_ = false; // for when Boiler states we having running warm water. used in Shower()
|
||||||
uint32_t EMSESP::last_fetch_ = 0;
|
uint32_t EMSESP::last_fetch_ = 0;
|
||||||
uint8_t EMSESP::unique_id_count_ = 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 our known and active devices
|
// or if device_id is 0 it will fetch from all our known and active devices
|
||||||
@@ -722,17 +721,19 @@ bool EMSESP::add_device(const uint8_t device_id, const uint8_t product_id, std::
|
|||||||
return false; // not found
|
return false; // not found
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string name = uuid::read_flash_string(device_p->name);
|
auto name = uuid::read_flash_string(device_p->name);
|
||||||
emsdevices.push_back(EMSFactory::add(device_p->device_type, device_id, device_p->product_id, version, name, device_p->flags, brand));
|
auto device_type = device_p->device_type;
|
||||||
emsdevices.back()->unique_id(++unique_id_count_);
|
auto flags = device_p->flags;
|
||||||
LOG_DEBUG(F("Adding new device %s (device ID 0x%02X, product ID %d, version %s)"), name.c_str(), device_id, product_id, version.c_str());
|
LOG_DEBUG(F("Adding new device %s (device ID 0x%02X, product ID %d, version %s)"), name.c_str(), device_id, product_id, version.c_str());
|
||||||
|
emsdevices.push_back(EMSFactory::add(device_type, device_id, product_id, version, name, flags, brand));
|
||||||
|
|
||||||
fetch_device_values(device_id); // go and fetch its data
|
fetch_device_values(device_id); // go and fetch its data
|
||||||
|
|
||||||
// add info command, but not for all devices
|
// add info command, but not for all devices
|
||||||
uint8_t device_type = device_p->device_type;
|
|
||||||
if ((device_type == DeviceType::CONNECT) || (device_type == DeviceType::CONTROLLER) || (device_type == DeviceType::GATEWAY)) {
|
if ((device_type == DeviceType::CONNECT) || (device_type == DeviceType::CONTROLLER) || (device_type == DeviceType::GATEWAY)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Command::add_with_json(device_type, F_(info), [device_type](const char * value, const int8_t id, JsonObject & json) {
|
Command::add_with_json(device_type, F_(info), [device_type](const char * value, const int8_t id, JsonObject & json) {
|
||||||
return command_info(device_type, json);
|
return command_info(device_type, json);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -206,7 +206,6 @@ class EMSESP {
|
|||||||
static bool read_next_;
|
static bool read_next_;
|
||||||
static uint16_t publish_id_;
|
static uint16_t publish_id_;
|
||||||
static bool tap_water_active_;
|
static bool tap_water_active_;
|
||||||
static uint8_t unique_id_count_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace emsesp
|
} // namespace emsesp
|
||||||
|
|||||||
Reference in New Issue
Block a user