42 lines
970 B
C++
42 lines
970 B
C++
#pragma once
|
|
|
|
#include <Arduino.h>
|
|
|
|
#define CONFIG_FILENAME "/config.bin"
|
|
#define CONFIG_VERSION 0x00010400 // 0.1.4 // make sure to clean all after change
|
|
|
|
#define WIFI_MAX_SSID_STRLEN 31
|
|
#define WIFI_MAX_PASSWORD_STRLEN 31
|
|
#define WIFI_MAX_HOSTNAME_STRLEN 31
|
|
|
|
#define NTP_MAX_SERVER_STRLEN 31
|
|
#define NTP_MAX_TIMEZONE_STRLEN 50
|
|
|
|
struct CONFIG_T {
|
|
uint32_t Cfg_Version;
|
|
uint Cfg_SaveCount;
|
|
|
|
char WiFi_Ssid[WIFI_MAX_SSID_STRLEN + 1];
|
|
char WiFi_Password[WIFI_MAX_PASSWORD_STRLEN + 1];
|
|
byte WiFi_Ip[4];
|
|
byte WiFi_Netmask[4];
|
|
byte WiFi_Gateway[4];
|
|
byte WiFi_Dns1[4];
|
|
byte WiFi_Dns2[4];
|
|
bool WiFi_Dhcp;
|
|
char WiFi_Hostname[WIFI_MAX_HOSTNAME_STRLEN + 1];
|
|
|
|
char Ntp_Server[NTP_MAX_SERVER_STRLEN + 1];
|
|
char Ntp_Timezone[NTP_MAX_TIMEZONE_STRLEN + 1];
|
|
};
|
|
|
|
class ConfigurationClass {
|
|
public:
|
|
void init();
|
|
bool read();
|
|
bool write();
|
|
void migrate();
|
|
CONFIG_T& get();
|
|
};
|
|
|
|
extern ConfigurationClass Configuration; |