From b073db4017008ceb638a9c23c8cc93e60a3a7fdb Mon Sep 17 00:00:00 2001 From: xengineering Date: Sun, 23 Mar 2025 17:53:24 +0100 Subject: fw: app: Move application firmware code here This makes the structure of the `fw` folder more clear and separates application-related code from bootloader- or rtos-related code. --- fw/src/syslog.c | 75 --------------------------------------------------------- 1 file changed, 75 deletions(-) delete mode 100644 fw/src/syslog.c (limited to 'fw/src/syslog.c') diff --git a/fw/src/syslog.c b/fw/src/syslog.c deleted file mode 100644 index b1a1077..0000000 --- a/fw/src/syslog.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * This Source Code Form is subject to the terms of the Mozilla Public License, - * v. 2.0. If a copy of the MPL was not distributed with this file, You can - * obtain one at https://mozilla.org/MPL/2.0/. - */ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -LOG_MODULE_REGISTER(syslog); - -#define L4_EVENT_MASK (NET_EVENT_L4_CONNECTED | NET_EVENT_L4_DISCONNECTED) - -struct net_mgmt_event_callback l4_cb; -static K_SEM_DEFINE(network_connected, 0, 1); - -void l4_event_handler( - struct net_mgmt_event_callback *cb, - uint32_t event, - struct net_if *iface) -{ - LOG_DBG("Executing L4 event handler"); - - switch (event) { - case NET_EVENT_L4_CONNECTED: - k_sem_give(&network_connected); - LOG_INF("Network connected"); - break; - case NET_EVENT_L4_DISCONNECTED: - LOG_INF("Network disconnected"); - break; - default: - break; - } -} - -int init_network_monitoring(void) -{ - net_mgmt_init_event_callback(&l4_cb, l4_event_handler, L4_EVENT_MASK); - net_mgmt_add_event_callback(&l4_cb); - - return 0; -} -SYS_INIT(init_network_monitoring, APPLICATION, 0); - -int init_syslog(void) -{ - LOG_DBG("Initializing syslog logging backend"); - - LOG_DBG("Waiting for network ..."); - k_sem_take(&network_connected, K_FOREVER); - - LOG_DBG("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 */ - while (log_process()); - log_backend_init(backend); - log_backend_enable(backend, backend->cb->ctx, CONFIG_LOG_MAX_LEVEL); - LOG_INF("Syslog backend enabled"); - } else { - LOG_INF("Syslog backend was already enabled"); - } - - return 0; -} -SYS_INIT(init_syslog, APPLICATION, 50); -- cgit v1.2.3-70-g09d2