-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEepromConfiguration.h
46 lines (37 loc) · 1.28 KB
/
EepromConfiguration.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
46
#pragma once
#include <stdint.h>
class EepromConfiguration
{
public:
EepromConfiguration(void (*callback)());
virtual ~EepromConfiguration() = default;
char mqttServerAddress[41] = "";
char dnsServerAddress[17] = "";
char gatewayAddress[17] = "";
char ipAddress[17] = "192.168.168.168";
char subnetMask[17] = "255.255.255.0";
uint8_t mac[6];
char mqttPublishInterval[7] = "5000";
void writeEeprom();
void clearEeprom();
bool hasValidSignature();
long numericMqttPublishInterval()
{
return _numericMqttPublishInterval;
}
private:
const int MQTT_EEPROM_OFFSET = 10;
const int DNS_EEPROM_OFFSET = MQTT_EEPROM_OFFSET + sizeof(mqttServerAddress);
const int GATEWAY_EEPROM_OFFSET = DNS_EEPROM_OFFSET + sizeof(dnsServerAddress);
const int IP_EEPROM_OFFSET = GATEWAY_EEPROM_OFFSET + sizeof(gatewayAddress);
const int SUBNET_MASK_OFFSET = IP_EEPROM_OFFSET + sizeof(ipAddress);
const int MAC_OFFSET = SUBNET_MASK_OFFSET + sizeof(subnetMask);
const int MQTT_PUBLISH_INTERVAL = MAC_OFFSET + sizeof(mac);
void readEeprom();
void writeSignature();
void initialize();
void generateMacAddress();
void parseMqttPublishInterval();
void (*_callback)();
long _numericMqttPublishInterval = 1000;
};