diff --git a/code/nrf-connect/samples/zigbee/Kconfig b/code/nrf-connect/samples/zigbee/Kconfig index 2e86690..6fbb42a 100644 --- a/code/nrf-connect/samples/zigbee/Kconfig +++ b/code/nrf-connect/samples/zigbee/Kconfig @@ -7,7 +7,7 @@ config PRST_ZB_SLEEP_DURATION_SEC config PRST_ZB_PARENT_POLL_INTERVAL_SEC int "Interval for when b-parasite polls its parent for data in seconds." - default 60 + default 10 config PRST_ZB_BUILD_DATE string "Zigbee basic cluster build date attribute. Max 16 bytes." diff --git a/code/nrf-connect/samples/zigbee/prj.conf b/code/nrf-connect/samples/zigbee/prj.conf index 53b6508..5583e41 100644 --- a/code/nrf-connect/samples/zigbee/prj.conf +++ b/code/nrf-connect/samples/zigbee/prj.conf @@ -8,9 +8,6 @@ CONFIG_GPIO=y CONFIG_USE_SEGGER_RTT=y CONFIG_SEGGER_RTT_BUFFER_SIZE_UP=4096 -CONFIG_PM=y -CONFIG_PM_DEVICE=y - CONFIG_NEWLIB_LIBC=y CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y @@ -39,8 +36,17 @@ CONFIG_NET_IPV6_RA_RDNSS=n CONFIG_NET_IP_ADDR_CHECK=n CONFIG_NET_UDP=n +## +## ZigBee Channel Selection +## # Get Zigbee to scan every channel. CONFIG_ZIGBEE_CHANNEL_SELECTION_MODE_MULTI=y +# By default only scans channel 11 (ZigBee2MQTT default) and 15 (ZHA default). +# Comment to scan all channels - this will make pairing consume more energy. +# CONFIG_ZIGBEE_CHANNEL_MASK=0x8800 + +# Uncomment to set a specific channel - this will make pairing more energy efficient. +# CONFIG_ZIGBEE_CHANNEL=11 # Enable API for powering down unused RAM parts. # https://developer.nordicsemi.com/nRF_Connect_SDK/doc/1.7.1/nrf/ug_zigbee_configuring.html#power-saving-during-sleep @@ -60,4 +66,3 @@ CONFIG_FILE_SYSTEM_LITTLEFS=y # Factory reset method selection. Only hardware revision 2.0.0+ has button SW1. Earlier # revisions must select a different method. See Kconfig for options. # CONFIG_PRST_ZB_FACTORY_RESET_VIA_SW1=y -CONFIG_PRST_ZB_FACTORY_RESET_DISABLED=y \ No newline at end of file diff --git a/code/nrf-connect/samples/zigbee/src/main.c b/code/nrf-connect/samples/zigbee/src/main.c index 7fb52c4..2899be9 100644 --- a/code/nrf-connect/samples/zigbee/src/main.c +++ b/code/nrf-connect/samples/zigbee/src/main.c @@ -138,6 +138,8 @@ void zboss_signal_handler(zb_bufid_t bufid) { k_timer_stop(&led_flashing_timer); prst_restart_watchdog_stop(); prst_led_off(); + // Update the long polling parent interval - needs to be done after joining. + zb_zdo_pim_set_long_poll_interval(1000 * CONFIG_PRST_ZB_PARENT_POLL_INTERVAL_SEC); } else { LOG_DBG("Steering failed. Status: %d", status); prst_debug_counters_increment("steering_failure"); @@ -244,7 +246,7 @@ void update_sensors_cb(zb_uint8_t arg) { } void log_counter(const char *counter_name, prst_debug_counter_t value) { - LOG_INF("- %s: %d", counter_name, value); + LOG_DBG("- %s: %d", counter_name, value); } int main(void) { @@ -254,9 +256,12 @@ int main(void) { RET_IF_ERR(prst_flash_fs_init()); RET_IF_ERR(prst_debug_counters_init()); + // Initialize sensors - quickly put them into low power mode. + RET_IF_ERR(prst_sensors_read_all(&sensors)); + prst_debug_counters_increment("boot"); - LOG_INF("Dumping debug counters:"); + LOG_DBG("Dumping debug counters:"); prst_debug_counters_get_all(log_counter); RET_IF_ERR(prst_zb_factory_reset_check()); @@ -265,19 +270,17 @@ int main(void) { ZB_AF_REGISTER_DEVICE_CTX(&app_template_ctx); + // Kick-off the recurring task to read sensors and update ZigBee clusters. update_sensors_cb(/*arg=*/0); - zb_zdo_pim_set_long_poll_interval( - ZB_TIME_ONE_SECOND * CONFIG_PRST_ZB_PARENT_POLL_INTERVAL_SEC); - power_down_unused_ram(); - RET_IF_ERR(prst_led_flash(2)); k_msleep(100); ZB_AF_SET_IDENTIFY_NOTIFICATION_HANDLER(PRST_ZIGBEE_ENDPOINT, identify_cb); - zigbee_enable(); zigbee_configure_sleepy_behavior(/*enable=*/true); + power_down_unused_ram(); + zigbee_enable(); prst_debug_counters_increment("main_finish"); diff --git a/code/nrf-connect/samples/zigbee/src/restart_handler.c b/code/nrf-connect/samples/zigbee/src/restart_handler.c index a504bf6..4959ae9 100644 --- a/code/nrf-connect/samples/zigbee/src/restart_handler.c +++ b/code/nrf-connect/samples/zigbee/src/restart_handler.c @@ -11,7 +11,7 @@ LOG_MODULE_REGISTER(restart_handler, CONFIG_LOG_DEFAULT_LEVEL); void callback_work_handler(struct k_work *work) { LOG_INF("Running restart callback_work_handler."); prst_debug_counters_increment("steering_watchdog_restart"); - zb_reset(0); + user_input_indicate(); } K_WORK_DEFINE(callback_work, callback_work_handler);