Skip to content

Commit bdac2b9

Browse files
committed
feat(zigbee): Add option to allow binding multiple endpoints with single device
1 parent 111e35d commit bdac2b9

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

libraries/Zigbee/src/ZigbeeCore.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ ZigbeeCore::ZigbeeCore() {
4646
_scan_duration = 3; // default scan duration
4747
_rx_on_when_idle = true;
4848
_debug = false;
49+
_allow_multi_endpoint_binding = false;
4950
_global_default_response_cb = nullptr; // Initialize global callback to nullptr
5051
if (!lock) {
5152
lock = xSemaphoreCreateBinary();
@@ -392,7 +393,9 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct) {
392393
log_d("Device not bound to endpoint %d and it is free to bound!", (*it)->getEndpoint());
393394
(*it)->findEndpoint(&cmd_req);
394395
log_d("Endpoint %d is searching for device", (*it)->getEndpoint());
395-
break; // Only one endpoint per device
396+
if(!Zigbee.allowMultiEndpointBinding()) { // If multi endpoint binding is not allowed, break the loop to keep backwards compatibility
397+
break;
398+
}
396399
}
397400
}
398401
}
@@ -422,11 +425,13 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct) {
422425
break;
423426
}
424427
}
425-
log_d("Device not bound to endpoint %d and it is free to bound!", (*it)->getEndpoint());
426428
if (!found) {
429+
log_d("Device not bound to endpoint %d and it is free to bound!", (*it)->getEndpoint());
427430
(*it)->findEndpoint(&cmd_req);
428431
log_d("Endpoint %d is searching for device", (*it)->getEndpoint());
429-
break; // Only one endpoint per device
432+
if(!Zigbee.allowMultiEndpointBinding()) { // If multi endpoint binding is not allowed, break the loop to keep backwards compatibility
433+
break;
434+
}
430435
}
431436
}
432437
}

libraries/Zigbee/src/ZigbeeCore.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ class ZigbeeCore {
117117
zigbee_scan_result_t *_scan_result;
118118
SemaphoreHandle_t lock;
119119
bool _debug;
120+
bool _allow_multi_endpoint_binding;
120121

121122
// Global default response callback
122123
void (*_global_default_response_cb)(zb_cmd_type_t resp_to_cmd, esp_zb_zcl_status_t status, uint8_t endpoint, uint16_t cluster);
@@ -196,6 +197,13 @@ class ZigbeeCore {
196197
return _debug;
197198
}
198199

200+
void allowMultiEndpointBinding(bool allow) {
201+
_allow_multi_endpoint_binding = allow;
202+
}
203+
bool allowMultiEndpointBinding() {
204+
return _allow_multi_endpoint_binding;
205+
}
206+
199207
// Set global default response callback
200208
void onGlobalDefaultResponse(void (*callback)(zb_cmd_type_t resp_to_cmd, esp_zb_zcl_status_t status, uint8_t endpoint, uint16_t cluster)) {
201209
_global_default_response_cb = callback;

0 commit comments

Comments
 (0)