-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfig.h
67 lines (61 loc) · 1.46 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
#ifndef Config_h
#define Config_h
/*
* Config
*
* Library for a Config object that loads/saves state to eeprom
*
* Greg Cope <[email protected]>
* 02-Jul-2016 Initial version
*
*/
#include <Arduino.h>
#include <EEPROM.h>
#include "CRC8.h"
#define CONFIG_START 0
#define CONFIG_VERSION "001"
class Config
{
public:
Config();
boolean load(void);
boolean save(void);
void setGSMPhone(const char*);
char* getGSMPhone(void);
void setSavedLat(const double*);
double* getSavedLat(void);
void setSavedLng(const double*);
double* getSavedLng(void);
private:
CRC8 crc;
byte _c = 0; // char buffer
boolean _needSave; // flag to save
byte _crcCheckSumSaved;
byte _crcCheckSumLoaded;
String _tempBuffer; // checksum buffer holder
unsigned long _NOW = 0; // time placeholder
unsigned long _timeTaken = 0; //var to hold time taken
// config goes in here ....
struct ConfigStruct {
// config is versioned as the struct is fixed
char version[4];
// 20 chars, plus a few for luck, the leading +, and null char ending
char gsmPhone[24];
// FIX probably not the best name
double savedLat;
double savedLng;
// how many writes
unsigned int serial;
// checksum?
unsigned int crc;
} _config = {
CONFIG_VERSION,
// this need double quotes? gcc parsing bug?
"+441234567890",
100,
100,
0,
0
};
};
#endif