23 #define OPTION_FILE_NAME "/options.txt"
73 MyOptions::MyOptions()
74 : isDebugActive(false)
79 , connectWifiAP(false)
81 , bme280CheckIntervalSec(60)
86 , gpsCheckIntervalSec(300)
87 , minMovingDistance(3000)
89 , smsCheckIntervalSec(600)
90 , isDeepSleepEnabled(false)
91 , powerSaveModeVoltage(16.0)
92 , powerCheckIntervalSec(300)
94 , deepSleepTimeSec(900)
95 , isMqttEnabled(false)
102 , mqttSendOnMoveEverySec(900)
103 , mqttSendOnNonMoveEverySec(10800)
114 MyDbg(F(
"Failed to read options file"));
117 while (file.available() && ret) {
118 String line = file.readStringUntil(
'\n');
119 int idx = line.indexOf(
'=');
122 MyDbg((String) F(
"Wrong option entry: ") + line);
125 String key = line.substring(0, idx);
126 String value = line.substring(idx + 1);
127 long lValue = atol(value.c_str());
128 double fValue = atof(value.c_str());
130 value.replace(
"\r",
"");
131 value.replace(
"\n",
"");
132 MyDbg((String) F(
"Load option '") + key + F(
"=") + value + F(
"'"));
134 if (key == F(
"isDebugActive")) {
136 }
else if (key == F(
"gprsAP")) {
138 }
else if (key == F(
"gprsUser")) {
140 }
else if (key == F(
"gprsPassword")) {
142 }
else if (key == F(
"wifiAP")) {
144 }
else if (key == F(
"connectWifiAP")) {
146 }
else if (key == F(
"wifiPassword")) {
148 }
else if (key == F(
"powerOn")) {
150 }
else if (key == F(
"bme280CheckIntervalSec")) {
152 }
else if (key == F(
"isSmsEnabled")) {
154 }
else if (key == F(
"isGpsEnabled")) {
156 }
else if (key == F(
"gpsTimeoutSec")) {
158 }
else if (key == F(
"gpsCheckIntervalSec")) {
160 }
else if (key == F(
"minMovingDistance")) {
162 }
else if (key == F(
"phoneNumber")) {
164 }
else if (key == F(
"smsCheckIntervalSec")) {
166 }
else if (key == F(
"isDeepSleepEnabled")) {
168 }
else if (key == F(
"powerSaveModeVoltage")) {
170 }
else if (key == F(
"powerCheckIntervalSec")) {
172 }
else if (key == F(
"activeTimeSec")) {
174 }
else if (key == F(
"deepSleepTimeSec")) {
176 }
else if (key == F(
"isMqttEnabled")) {
178 }
else if (key == F(
"mqttName")) {
180 }
else if (key == F(
"mqttId")) {
182 }
else if (key == F(
"mqttServer")) {
184 }
else if (key == F(
"mqttPort")) {
186 }
else if (key == F(
"mqttUser")) {
188 }
else if (key == F(
"mqttPassword")) {
190 }
else if (key == F(
"mqttSendOnMoveEverySec")) {
192 }
else if (key == F(
"mqttSendOnNonMoveEverySec")) {
195 MyDbg((String) F(
"Wrong option entry: ") + line);
203 MyDbg(F(
"Settings loaded"));
214 MyDbg(
"Failed to write options file");
216 file.println((String) F(
"isDebugActive=") + String(
isDebugActive));
217 file.println((String) F(
"gprsAP=") +
gprsAP);
218 file.println((String) F(
"gprsUser=") +
gprsUser);
219 file.println((String) F(
"gprsPassword=") +
gprsPassword);
220 file.println((String) F(
"connectWifiAP=") + String(
connectWifiAP));
221 file.println((String) F(
"wifiAP=") +
wifiAP);
222 file.println((String) F(
"wifiPassword=") +
wifiPassword);
223 file.println((String) F(
"powerOn=") + String(
powerOn));
225 file.println((String) F(
"isSmsEnabled=") + String(
isSmsEnabled));
226 file.println((String) F(
"isGpsEnabled=") + String(
isGpsEnabled));
227 file.println((String) F(
"gpsTimeoutSec=") + String(
gpsTimeoutSec));
230 file.println((String) F(
"phoneNumber=") +
phoneNumber);
235 file.println((String) F(
"activeTimeSec=") + String(
activeTimeSec));
237 file.println((String) F(
"isMqttEnabled=") + String(
isMqttEnabled));
238 file.println((String) F(
"mqttName=") +
mqttName);
239 file.println((String) F(
"mqttId=") +
mqttId);
240 file.println((String) F(
"mqttServer=") +
mqttServer);
241 file.println((String) F(
"mqttPort=") + String(
mqttPort));
242 file.println((String) F(
"mqttUser=") +
mqttUser);
243 file.println((String) F(
"mqttPassword=") +
mqttPassword);
247 MyDbg(F(
"Settings saved"));
long deepSleepTimeSec
Time to stay in deep sleep (without check interrupts)
String phoneNumber
Pone number for sms answers.
#define MQTT_USER
MQTT connection user.
bool isGpsEnabled
Is the gps part of the sim808 active?
double powerSaveModeVoltage
Minimum voltage to stay always alive.
long smsCheckIntervalSec
SMS check intervall.
#define PHONE_NUMBER
my phone number for sms communication
bool connectWifiAP
Should we connect to wifi.
String mqttUser
MQTT user.
String wifiAP
WiFi AP name.
long gpsCheckIntervalSec
Time interval to check the gps position.
void MyDbg(String info, bool fromWebServer=false, bool newline=true)
#define MQTT_PORT
MQTT Port (Default is 1883)
bool powerOn
Is the GSM power from the DC-DC modul switched on?
long gpsTimeoutSec
Timeout for waiting for gps position.
#define WIFI_PW
WiFi password.
String mqttPassword
MQTT password.
long powerCheckIntervalSec
Time interval to check the power supply.
String wifiPassword
WiFi AP password.
String gprsUser
GRPS access point User.
String mqttServer
MQTT server url.
bool isDebugActive
Is detailed debugging enabled?
long mqttPort
MQTT server port.
#define GPRS_PASSWORD
gprs password
long activeTimeSec
Maximum alive time after deepsleep.
long bme280CheckIntervalSec
Time interval to read the temp, hum and pressure.
String gprsPassword
GRPS access point Password.
#define GPRS_AP
gprs access point name
#define WIFI_SID
WiFi SID.
bool isSmsEnabled
Is the sms check functionality active?
#define MQTT_SERVER
MQTT Server URL.
String gprsAP
GRPS access point of the sim card supplier.
String mqttName
MQTT server name.
#define MQTT_NAME
MQTT name.
bool isMqttEnabled
Should the system connect to a MQTT server?
#define OPTION_FILE_NAME
Option file name.
#define MQTT_PASSWORD
MQTT connection password.
long mqttSendOnNonMoveEverySec
Send data interval to MQTT server on non moving.
bool isDeepSleepEnabled
Should the system go into deepsleep if needed.
#define GPRS_USER
gprs user
long mqttSendOnMoveEverySec
Send data interval to MQTT server on moving.
long minMovingDistance
Minimum distance to accept as moving or not.