66 lines
1 KiB
C
66 lines
1 KiB
C
#ifndef CONTROLLER_CONFIG_H
|
|
#define CONTROLLER_CONFIG_H
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <toml.h>
|
|
|
|
#include <constants.h>
|
|
#include <enums.h>
|
|
|
|
typedef struct
|
|
{
|
|
uint8_t pin;
|
|
int inverted;
|
|
int init;
|
|
relay_driver_t driver;
|
|
uint8_t pulse_duration;
|
|
} config_relay_t;
|
|
|
|
typedef struct
|
|
{
|
|
char *name;
|
|
char *database;
|
|
char *user;
|
|
char *group;
|
|
char *mqtt_host;
|
|
char *include;
|
|
int relays_init;
|
|
uint8_t relay_count;
|
|
|
|
struct
|
|
{
|
|
int level;
|
|
FILE *file;
|
|
} logging;
|
|
|
|
struct
|
|
{
|
|
uint16_t discovery;
|
|
uint16_t mqtt;
|
|
} ports;
|
|
|
|
config_relay_t *relay_configs;
|
|
} config_t;
|
|
|
|
extern config_t *global_config;
|
|
|
|
void
|
|
config_init();
|
|
|
|
void
|
|
config_free();
|
|
|
|
void
|
|
config_load_string(char **holder, const char *value);
|
|
|
|
void
|
|
config_load(config_t *config, const char *cli_config_file);
|
|
|
|
void
|
|
config_load_file(config_t *config, const char *file_name);
|
|
|
|
void
|
|
config_load_directory(config_t *config, const char *directory_name);
|
|
|
|
#endif //CONTROLLER_CONFIG_H
|