53 lines
1.1 KiB
C
53 lines
1.1 KiB
C
#ifndef CONFIG_STORE_H
|
|
#define CONFIG_STORE_H
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
|
|
#define DEVICE_NAME_MAX_LEN 32
|
|
#define WIFI_SSID_MAX_LEN 32
|
|
#define WIFI_PASSWORD_MAX_LEN 64
|
|
#define IPV4_STR_MAX_LEN 16
|
|
#define MAX_VIRTUAL_DEVICES 10
|
|
|
|
typedef struct
|
|
{
|
|
char ssid[WIFI_SSID_MAX_LEN];
|
|
char password[WIFI_PASSWORD_MAX_LEN];
|
|
|
|
bool dhcp;
|
|
|
|
char static_ip[IPV4_STR_MAX_LEN];
|
|
char gateway[IPV4_STR_MAX_LEN];
|
|
char netmask[IPV4_STR_MAX_LEN];
|
|
} wifi_settings_t;
|
|
|
|
typedef struct
|
|
{
|
|
uint16_t port;
|
|
uint8_t max_clients;
|
|
uint8_t device_count;
|
|
size_t max_points;
|
|
} modbus_settings_t;
|
|
|
|
typedef struct
|
|
{
|
|
bool enabled;
|
|
uint8_t unit_id;
|
|
char name[DEVICE_NAME_MAX_LEN];
|
|
char *csv;
|
|
} virtual_device_settings_t;
|
|
|
|
typedef struct
|
|
{
|
|
wifi_settings_t wifi;
|
|
modbus_settings_t modbus;
|
|
virtual_device_settings_t devices[MAX_VIRTUAL_DEVICES];
|
|
} device_config_t;
|
|
|
|
void config_store_free(device_config_t *cfg);
|
|
void config_store_set_defaults(device_config_t *cfg);
|
|
bool config_store_load(const char *filename, device_config_t *cfg);
|
|
|
|
#endif /* CONFIG_STORE_H */ |