30 lines
1.4 KiB
C
30 lines
1.4 KiB
C
#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
|