From c86f04e4066f528f11d8021a490df28c7c7d7d3e Mon Sep 17 00:00:00 2001 From: rbaron Date: Wed, 28 Jun 2023 22:22:34 +0200 Subject: [PATCH] Nuclear reset option if recurring sensor task cannot be rescheduled Famous last words: "this should never happen" --- code/nrf-connect/samples/zigbee/src/main.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/code/nrf-connect/samples/zigbee/src/main.c b/code/nrf-connect/samples/zigbee/src/main.c index 2077004..3e4432c 100644 --- a/code/nrf-connect/samples/zigbee/src/main.c +++ b/code/nrf-connect/samples/zigbee/src/main.c @@ -126,9 +126,14 @@ void update_sensors_cb(zb_uint8_t arg) { LOG_INF("Updating sensors"); // Reschedule the same callback. - ZB_SCHEDULE_APP_ALARM(update_sensors_cb, - /*param=*/0, - ZB_MILLISECONDS_TO_BEACON_INTERVAL(1000 * CONFIG_PRST_ZB_SLEEP_DURATION_SEC)); + zb_ret_t ret = ZB_SCHEDULE_APP_ALARM( + update_sensors_cb, + /*param=*/0, + ZB_MILLISECONDS_TO_BEACON_INTERVAL(1000 * CONFIG_PRST_ZB_SLEEP_DURATION_SEC)); + if (ret != RET_OK) { + prst_debug_counters_increment("sens_cb_schedule_err"); + zb_reset(0); + } prst_debug_counters_increment("sensors_read_before"); if (prst_sensors_read_all(&sensors)) {