diff options
Diffstat (limited to 'fw/app/src/syslog.c')
-rw-r--r-- | fw/app/src/syslog.c | 13 |
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 */ |