-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvars.h
164 lines (142 loc) · 4.39 KB
/
vars.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*
* vars.h
*/
// logging vars
byte logFlags;
/*
#define secFlag 1
#define minFlag 2
#define hourFlag 4
#define dayFlag 8
#define weekFlag 16
#define monthFlag 32
#define yearFlag 64
*/
bool timeIsSet = false;
bool TimeTriggersSet = false;
//bool secFlag = false;
bool minFlag = false;
bool hourFlag = false;
bool dayFlag = false;
bool weekFlag = false;
bool monthFlag = false;
bool yearFlag = false;
int EverSoOften = 0;
#define SET_FLAG(n, f) n = n | f; //((n) |= (f))
#define CLR_FLAG(n, f) n = n & !f; //((n) &= ~(f))
//#define TGL_FLAG(n, f) ((n) ^= (f))
#define CHK_FLAG(n, f) (n & f) //((n) & (f))
int checkMinute = 0; // holds when doHourly was called
char minG[12];
struct logvars{
char hourE1[12]; // delivered tariff 1
char hourE2[12]; // delivered tariff 2
char hourR1[12]; // return tariff 1
char hourR2[12]; // return tariff 2
char hourTE[12]; // total tariff 1
char hourTR[12]; // total tariff 2
char hourG[12]; // Gas
char dayE1[12];
char dayE2[12];
char dayR1[12];
char dayR2[12];
char dayTE[12];
char dayTR[12];
char dayG[12];
char weekE1[12];
char weekE2[12];
char weekR1[12];
char weekR2[12];
char weekTE[12];
char weekTR[12];
char weekG[12];
char monthE1[12];
char monthE2[12];
char monthR1[12];
char monthR2[12];
char monthTE[12];
char monthTR[12];
char monthG[12];
char yearE1[12];
char yearE2[12];
char yearR1[12];
char yearR2[12];
char yearTE[12];
char yearTR[12];
char yearG[12];
} log_data = {};
// energy management vars
int interval;
unsigned long nextUpdateTime = 0;
unsigned long LastReportinMillis = 0;
unsigned long LastSample = 0;
time_t LastReportinSecs = 0;
long last10 = 0;
unsigned long time_to_wake = 0; // calculated wakeup time
unsigned long time_to_sleep = 0; // calculated sleep time
unsigned long lastSleeptime = 0;
boolean entitledToSleep = false; // aangezien slaapinterval en meetinterval niet synchroon lopen, moeten we na ontwaken eerst een telegram inlezen en afleveren alvorens ModemSleep mag worden aangeroepen.
bool monitoring = false; // are we permitted to collect P1 data? Not if in setup or firmware update
bool atsleep = true;
bool bootSetup = false; // flag for adminpassword bypass
// datagram stuff
#define MAXLINELENGTH 1040 // 0-0:96.13.0 has a maximum lenght of 1024 chars + 11 of its identifier
char telegram[MAXLINELENGTH]; // holds a single line of the datagram
String datagram; // holds entire datagram for raw output
bool datagramValid = false; //
bool dataEnd = false; // signals that we have found the end char in the data (!)
unsigned int currentCRC=0; // the CRC v alue of the datagram
bool gas22Flag = false; // flag for parsing second gas line on dsmr2.2 meters
bool reportInDecimals = true;
bool CRCcheckEnabled = true; // by default enable CRC checking
String mtopic ="Een lange MQTT boodschap als placeholder";
// process stuff
#define DISABLED 0
#define WAITING 1
#define READING 2
#define CHECKSUM 3
#define DONE 4
#define FAILURE 5
int state = DISABLED;
#define CONFIG 0 // getting basic Meter data to select correct parse rules
#define GOTMETER 1
#define RUNNING 2
int devicestate = CONFIG;
#define NONE 0
#define MAIN 1
#define DATA 2
#define WCONFIG 3
#define UPDATE 4
int webstate = NONE;
bool wifiSta = false;
bool breaking = false;
bool softAp = false;
bool Json = false;
bool Telnet = false;
bool AdminAuthenticated = false;
bool Mqtt = false;
bool MqttConnected = false;
bool MqttDelivered = false;
String LastReport = ""; //timestamp of last telegram reported
bool mqtt_dsmr = false; // deliver mqtt data in 'dsmr reader" format
bool MQTT_debug = false;
// for cFos
bool cfos = true;
char actualPowerImport[8];
char actualPowerExport[8];
char actualPowerImportExport[8];
char CurrentL1[9];
char CurrentL2[9];
char CurrentL3[9];
// for cFos Ende
bool daystart = true;
bool OEstate = false; // 74125 OE output enable is off by default (EO signal high)
// a bit of a kludge to get the first readings at coldboot to reset the daycounter. the coldboot flags will be reset once the daycounters are reset with valid values. The availability of valid values is signalled by
// the two gotXReadings
bool coldbootE = true;
bool coldbootG = true;
bool gotPowerReading = false;
bool gotGasReading = false;
char setupToken[18];
bool needToInitLogVars = false;
bool needToInitLogVarsGas = false;