Refactor: sys_status in separate component ausgelagert

This commit is contained in:
2025-12-11 01:16:06 +01:00
parent 882f7d6784
commit 5f60ea3841
4 changed files with 10 additions and 2 deletions
-1
View File
@@ -4,7 +4,6 @@ set(app_sources
"net_influx.c"
"net_mdns.c"
"sen5x_app.c"
"sys_status.c"
"wifi_mgr.c"
)
-21
View File
@@ -1,21 +0,0 @@
#include "sys_status.h"
#include "freertos/FreeRTOS.h"
#include "freertos/event_groups.h"
#include "esp_check.h"
static EventGroupHandle_t s_status_group = NULL;
void sys_status_init(void)
{
if (!s_status_group) {
s_status_group = xEventGroupCreate();
/* Initial: alles auf 0 */
xEventGroupClearBits(s_status_group, SYS_STATUS_WIFI_OK | SYS_STATUS_INFLUX_OK | SYS_STATUS_MDNS_OK);
}
}
EventGroupHandle_t sys_status_group(void)
{
if (!s_status_group) sys_status_init();
return s_status_group;
}
-29
View File
@@ -1,29 +0,0 @@
#pragma once
#include <stdbool.h>
#include "freertos/FreeRTOS.h"
#include "freertos/event_groups.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Bits im EventGroup */
#define SYS_STATUS_WIFI_OK (1 << 0)
#define SYS_STATUS_INFLUX_OK (1 << 1)
#define SYS_STATUS_MDNS_OK (1 << 2)
void sys_status_init(void);
EventGroupHandle_t sys_status_group(void);
/* Convenience-Setter/Getter */
static inline void sys_status_set_wifi_ok(bool ok) { EventGroupHandle_t g = sys_status_group(); if (ok) xEventGroupSetBits(g, SYS_STATUS_WIFI_OK); else xEventGroupClearBits(g, SYS_STATUS_WIFI_OK); }
static inline void sys_status_set_influx_ok(bool ok) { EventGroupHandle_t g = sys_status_group(); if (ok) xEventGroupSetBits(g, SYS_STATUS_INFLUX_OK); else xEventGroupClearBits(g, SYS_STATUS_INFLUX_OK); }
static inline void sys_status_set_mdns_ok(bool ok) { EventGroupHandle_t g = sys_status_group(); if (ok) xEventGroupSetBits(g, SYS_STATUS_MDNS_OK); else xEventGroupClearBits(g, SYS_STATUS_MDNS_OK); }
static inline bool sys_status_get_wifi_ok(void) { return (xEventGroupGetBits(sys_status_group()) & SYS_STATUS_WIFI_OK) != 0; }
static inline bool sys_status_get_influx_ok(void) { return (xEventGroupGetBits(sys_status_group()) & SYS_STATUS_INFLUX_OK) != 0; }
static inline bool sys_status_get_mdns_ok(void) { return (xEventGroupGetBits(sys_status_group()) & SYS_STATUS_MDNS_OK) != 0; }
#ifdef __cplusplus
}
#endif