-
Notifications
You must be signed in to change notification settings - Fork 5
/
Config.h
124 lines (103 loc) · 2.34 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#ifndef config_h
#define config_h
#include <sstream>
#include <vector>
#include <map>
#include "common.h"
#include "Seismometer.h"
/**
* Configuration management class
*/
class Config {
public:
/**
* Init config class
*/
static void init();
/**
* Returns if MAC address is configured
* @param True if MAC is configured, false otherwise
*/
static bool hasMACAddress();
/**
* Get MAC Address
* @return MAC Address
*/
static std::string getMacAddress();
/**
* Get MAC Address as byte array
* @param mac Byte array where MAC is stored
*/
static void getMacAddressAsByte(byte mac[6]);
/**
* Get configured latitude
* @return Configured latitude
*/
static double getLatitude();
/**
* Get configured longitude
* @return Configured longitude
*/
static double getLongitude();
/**
* Device is configured with a GPS position?
* @return True if position is set, false otherwise
*/
static bool hasPosition();
/**
* Check server config, then refresh locally
* @return True if config is OK, false if an error occurred
*/
static bool checkServerConfig();
/**
* Print config to log
*/
static void printConfig();
/**
* Set MAC Address
* @param macAddress MAC Address to use
*/
static void setMacAddress(std::string macAddress);
/**
* Set latitude
* @return Latitude to set
*/
static void setLatitude(double lat);
/**
* Set longitude
* @return Longitude to set
*/
static void setLongitude(double lon);
/**
* Returns the syslog server
* @return Syslog server
*/
static uint32_t getSyslogServer();
/**
* Save config to file
*/
static void save();
private:
/**
* Load default values for config
*/
static void loadDefault();
/**
* Read the config file
*/
static bool readConfigFile(const char *filepath);
/**
* Functions used to parse the config string from server (deprecated)
*/
static std::map<std::string, std::string> &configSplit(const std::string &s, char delim, std::map<std::string, std::string> &elems);
static std::map<std::string, std::string> configSplit(const std::string &s, char delim);
/**
* Function used to save file
*/
static void file_put_contents(const char* path, std::string content);
static double lat;
static double lon;
static std::string macAddress;
static uint32_t syslogServer;
};
#endif