Skip to content

Commit 91fd517

Browse files
P-R-O-C-H-YCopilotpre-commit-ci-lite[bot]me-no-dev
authored
feat(zigbee): Check the type of leave signal (espressif#11385)
* feat(zigbee): Check the type of leave signal * Update libraries/Zigbee/src/ZigbeeCore.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update libraries/Zigbee/src/ZigbeeCore.cpp Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * ci(pre-commit): Apply automatic fixes --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Co-authored-by: Me No Dev <me-no-dev@users.noreply.github.com>
1 parent 31bfcb2 commit 91fd517

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

libraries/Zigbee/src/ZigbeeCore.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct) {
247247
esp_zb_app_signal_type_t sig_type = (esp_zb_app_signal_type_t)*p_sg_p;
248248
//coordinator variables
249249
esp_zb_zdo_signal_device_annce_params_t *dev_annce_params = NULL;
250+
esp_zb_zdo_signal_leave_params_t *leave_params = NULL;
250251
//router variables
251252
esp_zb_zdo_signal_device_update_params_t *dev_update_params = NULL;
252253

@@ -427,9 +428,17 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct) {
427428
}
428429
break;
429430
case ESP_ZB_ZDO_SIGNAL_LEAVE: // End Device + Router
430-
// Device was removed from the network, factory reset the device
431+
// Received signal to leave the network
431432
if ((zigbee_role_t)Zigbee.getRole() != ZIGBEE_COORDINATOR) {
432-
Zigbee.factoryReset(true);
433+
leave_params = (esp_zb_zdo_signal_leave_params_t *)esp_zb_app_signal_get_params(p_sg_p);
434+
log_v("Signal to leave the network, leave type: %d", leave_params->leave_type);
435+
if (leave_params->leave_type == ESP_ZB_NWK_LEAVE_TYPE_RESET) { // Leave without rejoin -> Factory reset
436+
log_i("Leave without rejoin, factory reset the device");
437+
Zigbee.factoryReset(true);
438+
} else { // Leave with rejoin -> Rejoin the network, only reboot the device
439+
log_i("Leave with rejoin, only reboot the device");
440+
ESP.restart();
441+
}
433442
}
434443
break;
435444
default: log_v("ZDO signal: %s (0x%x), status: %s", esp_zb_zdo_signal_to_string(sig_type), sig_type, esp_err_to_name(err_status)); break;

0 commit comments

Comments
 (0)