Modbus TCP - Multi Devices
This commit is contained in:
52
main/config_store.h
Normal file
52
main/config_store.h
Normal file
@@ -0,0 +1,52 @@
|
||||
#ifndef CONFIG_STORE_H
|
||||
#define CONFIG_STORE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#define DEVICE_NAME_MAX_LEN 32
|
||||
#define DEVICE_CSV_MAX_LEN 64
|
||||
#define WIFI_SSID_MAX_LEN 32
|
||||
#define WIFI_PASSWORD_MAX_LEN 64
|
||||
#define IPV4_STR_MAX_LEN 16
|
||||
#define MAX_VIRTUAL_DEVICES 2
|
||||
|
||||
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;
|
||||
} modbus_settings_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bool enabled;
|
||||
uint8_t unit_id;
|
||||
char name[DEVICE_NAME_MAX_LEN];
|
||||
char csv[DEVICE_CSV_MAX_LEN];
|
||||
} 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_set_defaults(device_config_t *cfg);
|
||||
bool config_store_load(const char *filename, device_config_t *cfg);
|
||||
|
||||
#endif /* CONFIG_STORE_H */
|
||||
Reference in New Issue
Block a user