// File: firmware/components/sys_status/include/sys_status.h #pragma once #include #include #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; } /* Monotonic timestamp of a confirmed HTTP 204, never merely a WLAN connection. */ void sys_status_record_influx_success(void); uint64_t sys_status_last_influx_success_ms(void); #ifdef __cplusplus } #endif