summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2025-03-30 13:38:05 +0200
committerxengineering <me@xengineering.eu>2025-03-30 13:38:05 +0200
commit8bfece93b1e8835929d3f270cb61628abf2e3aef (patch)
tree3de1d22ccf1b33a60d7b1da086f09f524866c777
parentff5d76084b1d10e780426b22e0bdb320e525bf79 (diff)
downloadiot-contact-8bfece93b1e8835929d3f270cb61628abf2e3aef.tar
iot-contact-8bfece93b1e8835929d3f270cb61628abf2e3aef.tar.zst
iot-contact-8bfece93b1e8835929d3f270cb61628abf2e3aef.zip
fw: app: Reboot in case of no network
Because of an issue likely related to hardware design on the nucleo_f767zi board (see issue [1] for details) the firmware should reboot in case network access cannot be established after 4 seconds. This makes the firmware more robust at the moment. As soon as iot-contact hardware without this issue exists the behavior can be changed again. [1]: https://github.com/zephyrproject-rtos/zephyr/issues/77794
-rw-r--r--fw/app/src/syslog.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/fw/app/src/syslog.c b/fw/app/src/syslog.c
index b1a1077..edc2839 100644
--- a/fw/app/src/syslog.c
+++ b/fw/app/src/syslog.c
@@ -14,9 +14,11 @@
#include <zephyr/logging/log_ctrl.h>
#include <zephyr/logging/log_core.h>
#include <zephyr/net/conn_mgr_connectivity.h>
+#include <zephyr/sys/reboot.h>
LOG_MODULE_REGISTER(syslog);
+#define NETWORK_BUG_DELAY K_MSEC(4000)
#define L4_EVENT_MASK (NET_EVENT_L4_CONNECTED | NET_EVENT_L4_DISCONNECTED)
struct net_mgmt_event_callback l4_cb;
@@ -55,10 +57,15 @@ int init_syslog(void)
{
LOG_DBG("Initializing syslog logging backend");
- LOG_DBG("Waiting for network ...");
- k_sem_take(&network_connected, K_FOREVER);
+ LOG_INF("Waiting for network ...");
+ int ret = k_sem_take(&network_connected, NETWORK_BUG_DELAY);
+ if (ret == -EAGAIN) {
+ LOG_ERR("Could not connect to network - rebooting system");
+ log_flush();
+ sys_reboot(SYS_REBOOT_COLD);
+ }
- LOG_DBG("Enabling syslog backend");
+ LOG_INF("Enabling syslog backend");
const struct log_backend *backend = log_backend_net_get();
if (log_backend_is_active(backend) == false) {
/* flush log messages to ensure first syslog message is reproducible */