Skip to content
This repository has been archived by the owner on Oct 4, 2021. It is now read-only.

Commit

Permalink
get version information on scan devices
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDvP committed Jan 24, 2021
1 parent 28e13e0 commit 6dd1083
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/emsesp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ uint8_t EMSESP::publish_all_idx_ = 0;
uint8_t EMSESP::unique_id_count_ = 0;
bool EMSESP::trace_raw_ = false;
uint64_t EMSESP::tx_delay_ = 0;
bool EMSESP::force_scan_ = false;

// 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
Expand Down Expand Up @@ -104,6 +105,7 @@ uint8_t EMSESP::count_devices(const uint8_t device_type) {
void EMSESP::scan_devices() {
EMSESP::clear_all_devices();
EMSESP::send_read_request(EMSdevice::EMS_TYPE_UBADevices, EMSdevice::EMS_DEVICE_ID_BOILER);
force_scan_ = true;
}

/**
Expand Down Expand Up @@ -568,7 +570,8 @@ void EMSESP::process_UBADevices(std::shared_ptr<const Telegram> telegram) {
// when the version info is received, it will automagically add the device
// always skip modem device 0x0D, it does not reply to version request
// see https://github.com/proddy/EMS-ESP/issues/460#issuecomment-709553012
if ((device_id != EMSbus::ems_bus_id()) && !(EMSESP::device_exists(device_id)) && (device_id != 0x0D) && (device_id != 0x0C)) {
if ((device_id != EMSbus::ems_bus_id()) && (!(EMSESP::device_exists(device_id)) || force_scan_) &&
(device_id != 0x0B) && (device_id != 0x0C) && (device_id != 0x0D)) {
LOG_DEBUG(F("New EMS device detected with ID 0x%02X. Requesting version information."), device_id);
send_read_request(EMSdevice::EMS_TYPE_VERSION, device_id);
}
Expand All @@ -577,6 +580,7 @@ void EMSESP::process_UBADevices(std::shared_ptr<const Telegram> telegram) {
}
}
}
force_scan_ = false;
}

// process the Version telegram (type 0x02), which is a common type
Expand Down
1 change: 1 addition & 0 deletions src/emsesp.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ class EMSESP {
static uint8_t unique_id_count_;
static bool trace_raw_;
static uint64_t tx_delay_;
static bool force_scan_;
};

} // namespace emsesp
Expand Down

0 comments on commit 6dd1083

Please sign in to comment.