controller-legacy/include/config.h

67 lines
1 KiB
C
Raw Permalink Normal View History

2020-01-07 01:23:16 +00:00
#ifndef CONTROLLER_CONFIG_H
#define CONTROLLER_CONFIG_H
2020-04-16 23:38:25 +00:00
#include <stdint.h>
2020-11-21 23:56:01 +00:00
#include <toml.h>
2020-02-08 12:50:54 +00:00
2020-04-16 23:38:25 +00:00
#include <constants.h>
#include <enums.h>
2020-01-07 01:23:16 +00:00
2020-04-16 23:38:25 +00:00
typedef struct
{
uint8_t pin;
2020-04-18 00:09:50 +00:00
int inverted;
2020-08-20 19:51:42 +00:00
int init;
2020-04-16 23:38:25 +00:00
relay_driver_t driver;
2020-06-27 16:27:49 +00:00
uint8_t pulse_duration;
2020-04-16 23:38:25 +00:00
} config_relay_t;
2020-01-07 01:23:16 +00:00
2020-04-16 23:38:25 +00:00
typedef struct
{
2020-11-21 23:56:01 +00:00
char *name;
char *database;
char *user;
char *group;
char *mqtt_host;
char *include;
2020-08-20 19:51:42 +00:00
int relays_init;
2020-11-21 23:56:01 +00:00
uint8_t relay_count;
struct
{
int level;
FILE *file;
} logging;
struct
{
uint16_t discovery;
uint16_t mqtt;
} ports;
2020-04-16 23:38:25 +00:00
config_relay_t *relay_configs;
} config_t;
2020-02-23 00:13:27 +00:00
2020-11-21 23:56:01 +00:00
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);
2020-02-08 12:50:54 +00:00
2020-01-07 01:23:16 +00:00
#endif //CONTROLLER_CONFIG_H