-
Notifications
You must be signed in to change notification settings - Fork 0
/
Config.h
46 lines (35 loc) · 947 Bytes
/
Config.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Config.h
#ifndef _CONFIG_h
#define _CONFIG_h
#include <EEPROM.h>
#include <arduino.h>
class Config
{
public:
char* ssid;
char* ssidPassword;
char* mqtt;
int mqttPort;
char* mqttClientID;
char* mqttPublishTopic;
char* mqttSubscribeTopic;
char* mqttUser;
char* mqttPass;
bool IsSecure();
bool Save(int pAddress);
bool Load(int pAddress);
void Print(Stream& serial);
protected:
private:
const int EEPROM_SIZE = 512;
const byte EEPROM_CHECK_SUM = 124; // Used to check if config is stored. Change if structure changes
int SaveString(int pAddress, char* pString);
int ReadString(int pAddress, char* pString[]);
int SaveInt(int pAddress, int pValue);
int ReadInt(int pAddress, int *pValue);
int SaveBool(int pAddress, bool pValue);
int ReadBool(int pAddress, bool *pValue);
template <class T> int EEPROM_writeAnything(int ee, const T& value);
template <class T> int EEPROM_readAnything(int ee, T& value);
};
#endif