Skip to content

Commit 2ede22b

Browse files
committed
fix(zigbee): Check if device is not bound before bounding again
1 parent f007dca commit 2ede22b

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Diff for: libraries/Zigbee/src/ZigbeeCore.cpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,20 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct) {
314314
// for each endpoint in the list call the findEndpoint function if not bounded or allowed to bind multiple devices
315315
for (std::list<ZigbeeEP *>::iterator it = Zigbee.ep_objects.begin(); it != Zigbee.ep_objects.end(); ++it) {
316316
if (!(*it)->bound() || (*it)->epAllowMultipleBinding()) {
317-
(*it)->findEndpoint(&cmd_req);
317+
// Check if the device is already bound
318+
bool found = false;
319+
// Gte the list of devices bound to the EP
320+
std::list<zb_device_params_t *> bound_devices = (*it)->getBoundDevices();
321+
for (std::list<zb_device_params_t *>::iterator device = bound_devices.begin(); device != bound_devices.end(); ++device) {
322+
if (((*device)->short_addr == dev_annce_params->device_short_addr) || (memcmp((*device)->ieee_addr, dev_annce_params->ieee_addr, 8) == 0)) {
323+
found = true;
324+
log_d("Device already bound to endpoint %d", (*it)->getEndpoint());
325+
break;
326+
}
327+
}
328+
if (!found) {
329+
(*it)->findEndpoint(&cmd_req);
330+
}
318331
}
319332
}
320333
}

0 commit comments

Comments
 (0)