Replace confini with toml
This commit is contained in:
parent
25eab5d38e
commit
79b1f3b2cf
27 changed files with 3081 additions and 5926 deletions
13
include/cli.h
Normal file
13
include/cli.h
Normal file
|
@ -0,0 +1,13 @@
|
|||
#ifndef CONTROLLER_CLI_H
|
||||
#define CONTROLLER_CLI_H
|
||||
|
||||
typedef struct cli
|
||||
{
|
||||
const char *config_file;
|
||||
int demo_mode;
|
||||
} cli_t;
|
||||
|
||||
void
|
||||
cli_parse(int argc, const char **argv, cli_t *cli);
|
||||
|
||||
#endif /* CONTROLLER_CLI_H */
|
|
@ -2,7 +2,8 @@
|
|||
#define CONTROLLER_CONFIG_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <confini.h>
|
||||
|
||||
#include <toml.h>
|
||||
|
||||
#include <constants.h>
|
||||
#include <enums.h>
|
||||
|
@ -16,27 +17,50 @@ typedef struct
|
|||
uint8_t pulse_duration;
|
||||
} config_relay_t;
|
||||
|
||||
int
|
||||
config_load(IniDispatch *disp, void *config_void);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *file;
|
||||
char database[256];
|
||||
char user[256];
|
||||
char group[256];
|
||||
int log_level;
|
||||
FILE *log_file;
|
||||
run_type_t run_type;
|
||||
char name[MAX_NAME_LENGTH + 1];
|
||||
uint16_t discovery_port;
|
||||
uint16_t mqtt_port;
|
||||
char mqtt_host[256];
|
||||
uint8_t relay_count;
|
||||
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;
|
||||
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
|
||||
|
|
|
@ -14,13 +14,6 @@
|
|||
*/
|
||||
#define MAX_NAME_LENGTH 128
|
||||
|
||||
/**
|
||||
* @brief Maximum number of dbs for the databases for the MDB_env
|
||||
*
|
||||
* Used when calling mdb_env_set_maxdbs() in database_setup()
|
||||
*/
|
||||
#define MDB_MAXDBS 8
|
||||
|
||||
/**
|
||||
* @brief How many milli seconds to wait until poll timeout in main loop
|
||||
*/
|
||||
|
@ -28,4 +21,12 @@
|
|||
|
||||
#define PIFACE_GPIO_BASE 200
|
||||
|
||||
#define DEFAULT_CONTROLLER_NAME "emgauwa-controller"
|
||||
#define DEFAULT_CONFIG_PATH "emgauwa-controller.conf"
|
||||
#define DEFAULT_GLOBAL_CONFIG_PATH "/etc/emgauwa/controller.conf"
|
||||
#define DEFAULT_DATABASE_PATH "emgauwa-controller.sqlite"
|
||||
#define DEFAULT_DISCOVERY_PORT 4421
|
||||
#define DEFAULT_MQTT_PORT 1885
|
||||
#define DEFAULT_MQTT_HOST "127.0.0.1"
|
||||
|
||||
#endif /* CONTROLLER_CONTANTS_H */
|
||||
|
|
|
@ -22,10 +22,4 @@ typedef enum
|
|||
RELAY_DRIVER_PIFACE,
|
||||
} relay_driver_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
RUN_TYPE_START,
|
||||
RUN_TYPE_TEST,
|
||||
} run_type_t;
|
||||
|
||||
#endif /* CONTROLLER_ENUMS_H */
|
||||
|
|
|
@ -25,9 +25,6 @@ helper_get_port(int sock);
|
|||
int
|
||||
helper_open_discovery_socket(uint16_t discovery_port);
|
||||
|
||||
void
|
||||
helper_parse_cli(int argc, const char **argv, config_t *config);
|
||||
|
||||
int
|
||||
helper_get_weekday(const struct tm *time_struct);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue