From 727138415eafe13c3fea27ea0b9d7e314581e1cd Mon Sep 17 00:00:00 2001 From: Ole Odendahl Date: Tue, 11 Apr 2023 12:51:58 +0200 Subject: [PATCH] Added restart handler module. --- code/nrf-connect/samples/zigbee/CMakeLists.txt | 3 ++- .../samples/zigbee/src/restart_handler.c | 14 ++++++++++++++ .../samples/zigbee/src/restart_handler.h | 6 ++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 code/nrf-connect/samples/zigbee/src/restart_handler.c create mode 100644 code/nrf-connect/samples/zigbee/src/restart_handler.h diff --git a/code/nrf-connect/samples/zigbee/CMakeLists.txt b/code/nrf-connect/samples/zigbee/CMakeLists.txt index d000625..9fac7f5 100644 --- a/code/nrf-connect/samples/zigbee/CMakeLists.txt +++ b/code/nrf-connect/samples/zigbee/CMakeLists.txt @@ -16,8 +16,9 @@ target_sources(app PRIVATE src/factory_reset.c src/prst_zb_attrs.c src/prst_zb_soil_moisture_defs.c + src/restart_handler.c ) add_subdirectory(../../prstlib prstlib) target_include_directories(app PRIVATE ../../prstlib/include) -target_link_libraries(app PUBLIC prstlib) \ No newline at end of file +target_link_libraries(app PUBLIC prstlib) diff --git a/code/nrf-connect/samples/zigbee/src/restart_handler.c b/code/nrf-connect/samples/zigbee/src/restart_handler.c new file mode 100644 index 0000000..b6f6430 --- /dev/null +++ b/code/nrf-connect/samples/zigbee/src/restart_handler.c @@ -0,0 +1,14 @@ +#include +#include +#include + +#include "restart_handler.h" + +LOG_MODULE_REGISTER(restart_handler, CONFIG_LOG_DEFAULT_LEVEL); + +static void restart_network_steering_cb(struct k_timer *timer) { + LOG_DBG("Restart handler expired. Restarting network steering."); + user_input_indicate(); +} + +K_TIMER_DEFINE(restart_timer, restart_network_steering_cb, NULL); diff --git a/code/nrf-connect/samples/zigbee/src/restart_handler.h b/code/nrf-connect/samples/zigbee/src/restart_handler.h new file mode 100644 index 0000000..911470f --- /dev/null +++ b/code/nrf-connect/samples/zigbee/src/restart_handler.h @@ -0,0 +1,6 @@ +#ifndef _PRST_ZB_RESTART_HANDLER_H_ +#define _PRST_ZB_RESTART_HANDLER_H_ + +static const int PRST_ZB_RESET_TIMEOUT = 5 * 60; + +#endif // _PRST_ZB_RESTART_HANDLER_H_