-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfiguration.h
68 lines (53 loc) · 1.65 KB
/
configuration.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef _CONFIGURATION_H
#define _CONFIGURATION_H
#define HEADER_MAGIC "V001"
#define NUMBER_OF_DEVICES 6
#define PRIVATE_DATA_SIZE 4
class Configuration {
public:
enum SupportedDevices {
E_DEVICE_UNKNOWN,
E_DEVICE_ON_OFF,
E_DEVICE_TRIGGER,
E_DEVICE_SENSOR,
E_DEVICE_SIZE
};
class PrivateData {
public:
byte m_privateData[PRIVATE_DATA_SIZE];
};
Configuration(const int _iResetPin);
~Configuration();
static SupportedDevices convert(const String& _sDevice);
static String convert(const SupportedDevices _eDevice);
bool restoreConfiguration();
bool storeConfiguration();
byte maxNumberOfDevices();
bool getDeviceParams(const byte _deviceIndex,
SupportedDevices& _deviceId,
byte& _param1,
byte& _param2,
Configuration::PrivateData& _privateData);
bool setDeviceParams(const byte _deviceIndex,
const SupportedDevices _deviceId,
const byte _param1,
const byte _param2,
const Configuration::PrivateData& _privateData);
void dumpConfiguration(String& _sDump);
private:
bool m_bRequireStoring;
int m_iResetPin;
struct {
struct {
byte m_magic[sizeof(HEADER_MAGIC) - 1];
byte m_size;
} m_header;
struct {
SupportedDevices m_deviceId;
byte m_param1;
byte m_param2;
PrivateData m_privateData;
} m_devices[NUMBER_OF_DEVICES];
} g_configuration;
};
#endif //_CONFIGURATION_H