Skip to content

Commit 4edf517

Browse files
committed
feat(zigbee): Save network channel after 1st joining for faster rejoin
1 parent 2a3de9c commit 4edf517

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

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

+13-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,16 @@
88

99
#define ZB_INIT_TIMEOUT 30000 // 30 seconds
1010

11-
extern "C" void zb_set_ed_node_descriptor(bool power_src, bool rx_on_when_idle, bool alloc_addr);
11+
#ifdef __cplusplus
12+
extern "C" {
13+
#endif
14+
#include "zboss_api.h"
15+
extern zb_ret_t zb_nvram_write_dataset(zb_nvram_dataset_types_t t); // rejoin scanning workaround
16+
extern void zb_set_ed_node_descriptor(bool power_src, bool rx_on_when_idle, bool alloc_addr); // sleepy device power mode workaround
17+
#ifdef __cplusplus
18+
}
19+
#endif
20+
1221
static bool edBatteryPowered = false;
1322

1423
ZigbeeCore::ZigbeeCore() {
@@ -289,6 +298,9 @@ void esp_zb_app_signal_handler(esp_zb_app_signal_t *signal_struct) {
289298
extended_pan_id[0], esp_zb_get_pan_id(), esp_zb_get_current_channel(), esp_zb_get_short_address()
290299
);
291300
Zigbee._connected = true;
301+
// Set channel mask and write to NVRAM, so that the device will re-join the network faster after reboot (scan only on the current channel)
302+
esp_zb_set_channel_mask((1 << esp_zb_get_current_channel()));
303+
zb_nvram_write_dataset(ZB_NVRAM_COMMON_DATA);
292304
} else {
293305
log_i("Network steering was not successful (status: %s)", esp_err_to_name(err_status));
294306
esp_zb_scheduler_alarm((esp_zb_callback_t)bdb_start_top_level_commissioning_cb, ESP_ZB_BDB_MODE_NETWORK_STEERING, 1000);

0 commit comments

Comments
 (0)