diff --git a/code/nrf-connect/samples/zigbee/Kconfig b/code/nrf-connect/samples/zigbee/Kconfig index 1092ced..2e86690 100644 --- a/code/nrf-connect/samples/zigbee/Kconfig +++ b/code/nrf-connect/samples/zigbee/Kconfig @@ -34,6 +34,9 @@ config PRST_ZB_FACTORY_RESET_VIA_RESET_PIN config PRST_ZB_FACTORY_RESET_VIA_SW1 bool "Resetting while pressing and holding SW1 for 5 seconds will factory reset the device. Only available on v2.0.0+ hardware revisions." +config PRST_ZB_FACTORY_RESET_DISABLED + bool "No factory reset procedure." + endchoice # PRST_ZB_FACTORY_RESET_METHOD config PRST_ZB_RESTART_WATCHDOG_TIMEOUT_SEC diff --git a/code/nrf-connect/samples/zigbee/prj.conf b/code/nrf-connect/samples/zigbee/prj.conf index e5d8f1b..53b6508 100644 --- a/code/nrf-connect/samples/zigbee/prj.conf +++ b/code/nrf-connect/samples/zigbee/prj.conf @@ -60,3 +60,4 @@ 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/debug_counters.c b/code/nrf-connect/samples/zigbee/src/debug_counters.c index ede174c..72f006a 100644 --- a/code/nrf-connect/samples/zigbee/src/debug_counters.c +++ b/code/nrf-connect/samples/zigbee/src/debug_counters.c @@ -65,6 +65,7 @@ int prst_debug_counters_increment(const char* counter_name) { if (written != sizeof(value)) { LOG_ERR("fs_write returned %d, expected %d", written, sizeof(value)); } + RET_IF_ERR(fs_sync(&file)); return fs_close(&file); } diff --git a/code/nrf-connect/samples/zigbee/src/factory_reset.c b/code/nrf-connect/samples/zigbee/src/factory_reset.c index 7ada82b..5b64cdc 100644 --- a/code/nrf-connect/samples/zigbee/src/factory_reset.c +++ b/code/nrf-connect/samples/zigbee/src/factory_reset.c @@ -66,6 +66,7 @@ int prst_zb_factory_reset_check() { LOG_DBG("SW1 pressed. Scheduling timer"); k_timer_start(&sw1_factory_reset_check_timer, K_SECONDS(5), K_NO_WAIT); } -#endif +#elif CONFIG_PRST_ZB_FACTORY_RESET_DISABLED return 0; +#endif // CONFIG_PRST_ZB_FACTORY_RESET_VIA_RESET_PIN } \ 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 b1c1c42..7fb52c4 100644 --- a/code/nrf-connect/samples/zigbee/src/main.c +++ b/code/nrf-connect/samples/zigbee/src/main.c @@ -198,11 +198,13 @@ void update_sensors_cb(zb_uint8_t arg) { /*param=*/0, ZB_TIME_ONE_SECOND * CONFIG_PRST_ZB_SLEEP_DURATION_SEC); + prst_debug_counters_increment("sensors_read_before"); if (prst_sensors_read_all(&sensors)) { prst_debug_counters_increment("sensors_read_error"); LOG_ERR("Unable to read sensors"); return; } + prst_debug_counters_increment("sensors_read_after"); // Battery voltage in units of 100 mV. uint8_t batt_voltage = sensors.batt.adc_read.millivolts / 100; diff --git a/code/nrf-connect/samples/zigbee/src/restart_handler.c b/code/nrf-connect/samples/zigbee/src/restart_handler.c index 0a23df3..a504bf6 100644 --- a/code/nrf-connect/samples/zigbee/src/restart_handler.c +++ b/code/nrf-connect/samples/zigbee/src/restart_handler.c @@ -11,8 +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"); - // If the device is not commissioned, the rejoin procedure is started. - user_input_indicate(); + zb_reset(0); } K_WORK_DEFINE(callback_work, callback_work_handler);