@@ -29,7 +29,7 @@ bool Configuration::writeFile() {
2929
3030 Serial.println (" Saving config.." );
3131
32- StaticJsonDocument< 3584 > data;
32+ JsonDocument data;
3333 File configFile = SPIFFS.open (" /tracker_conf.json" , " w" );
3434
3535 if (!configFile) {
@@ -138,15 +138,14 @@ bool Configuration::readFile() {
138138
139139 if (configFile) {
140140 bool needsRewrite = false ;
141- StaticJsonDocument<3584 > data;
142-
141+ JsonDocument data;
143142 DeserializationError error = deserializeJson (data, configFile);
144143 if (error) {
145144 Serial.println (" Failed to read file, using default configuration" );
146145 }
147146
148- if (! data[" wifiAP" ]. containsKey ( " active" ) ||
149- ! data[" wifiAP" ]. containsKey ( " password" )) needsRewrite = true ;
147+ if (data[" wifiAP" ][ " active" ]. isNull ( ) ||
148+ data[" wifiAP" ][ " password" ]. isNull ( )) needsRewrite = true ;
150149 wifiAP.active = data[" wifiAP" ][" active" ] | true ;
151150 wifiAP.password = data[" wifiAP" ][" password" ] | " 1234567890" ;
152151
@@ -168,19 +167,19 @@ bool Configuration::readFile() {
168167 beacons.push_back (bcn);
169168 }
170169
171- if (! data[" display" ]. containsKey ( " ecoMode" ) ||
172- ! data[" display" ]. containsKey ( " timeout" ) ||
173- ! data[" display" ]. containsKey ( " turn180" ) ||
174- ! data[" display" ]. containsKey ( " showSymbol" )) needsRewrite = true ;
170+ if (data[" display" ][ " ecoMode" ]. isNull ( ) ||
171+ data[" display" ][ " timeout" ]. isNull ( ) ||
172+ data[" display" ][ " turn180" ]. isNull ( ) ||
173+ data[" display" ][ " showSymbol" ]. isNull ( )) needsRewrite = true ;
175174 display.ecoMode = data[" display" ][" ecoMode" ] | false ;
176175 display.timeout = data[" display" ][" timeout" ] | 4 ;
177176 display.turn180 = data[" display" ][" turn180" ] | false ;
178177 display.showSymbol = data[" display" ][" showSymbol" ] | true ;
179178
180- if (! data[" bluetooth" ]. containsKey ( " active" ) ||
181- ! data[" bluetooth" ]. containsKey ( " deviceName" ) ||
182- ! data[" bluetooth" ]. containsKey ( " useBLE" ) ||
183- ! data[" bluetooth" ]. containsKey ( " useKISS" )) needsRewrite = true ;
179+ if (data[" bluetooth" ][ " active" ]. isNull ( ) ||
180+ data[" bluetooth" ][ " deviceName" ]. isNull ( ) ||
181+ data[" bluetooth" ][ " useBLE" ]. isNull ( ) ||
182+ data[" bluetooth" ][ " useKISS" ]. isNull ( )) needsRewrite = true ;
184183 bluetooth.active = data[" bluetooth" ][" active" ] | false ;
185184 bluetooth.deviceName = data[" bluetooth" ][" deviceName" ] | " LoRaTracker" ;
186185 #ifdef HAS_BT_CLASSIC
@@ -203,42 +202,42 @@ bool Configuration::readFile() {
203202 loraTypes.push_back (loraType);
204203 }
205204
206- if (! data[" battery" ]. containsKey ( " sendVoltage" ) ||
207- ! data[" battery" ]. containsKey ( " voltageAsTelemetry" ) ||
208- ! data[" battery" ]. containsKey ( " sendVoltageAlways" ) ||
209- ! data[" battery" ]. containsKey ( " monitorVoltage" ) ||
210- ! data[" battery" ]. containsKey ( " sleepVoltage" )) needsRewrite = true ;
205+ if (data[" battery" ][ " sendVoltage" ]. isNull ( ) ||
206+ data[" battery" ][ " voltageAsTelemetry" ]. isNull ( ) ||
207+ data[" battery" ][ " sendVoltageAlways" ]. isNull ( ) ||
208+ data[" battery" ][ " monitorVoltage" ]. isNull ( ) ||
209+ data[" battery" ][ " sleepVoltage" ]. isNull ( )) needsRewrite = true ;
211210 battery.sendVoltage = data[" battery" ][" sendVoltage" ] | false ;
212211 battery.voltageAsTelemetry = data[" battery" ][" voltageAsTelemetry" ] | false ;
213212 battery.sendVoltageAlways = data[" battery" ][" sendVoltageAlways" ] | false ;
214213 battery.monitorVoltage = data[" battery" ][" monitorVoltage" ] | false ;
215214 battery.sleepVoltage = data[" battery" ][" sleepVoltage" ] | 2.9 ;
216215
217- if (! data[" telemetry" ]. containsKey ( " active" ) ||
218- ! data[" telemetry" ]. containsKey ( " sendTelemetry" ) ||
219- ! data[" telemetry" ]. containsKey ( " temperatureCorrection" )) needsRewrite = true ;
216+ if (data[" telemetry" ][ " active" ]. isNull ( ) ||
217+ data[" telemetry" ][ " sendTelemetry" ]. isNull ( ) ||
218+ data[" telemetry" ][ " temperatureCorrection" ]. isNull ( )) needsRewrite = true ;
220219 telemetry.active = data[" telemetry" ][" active" ] | false ;
221220 telemetry.sendTelemetry = data[" telemetry" ][" sendTelemetry" ] | false ;
222221 telemetry.temperatureCorrection = data[" telemetry" ][" temperatureCorrection" ] | 0.0 ;
223222
224- if (! data[" winlink" ]. containsKey ( " password" )) needsRewrite = true ;
223+ if (data[" winlink" ][ " password" ]. isNull ( )) needsRewrite = true ;
225224 winlink.password = data[" winlink" ][" password" ] | " NOPASS" ;
226225
227- if (! data[" notification" ]. containsKey ( " ledTx" ) ||
228- ! data[" notification" ]. containsKey ( " ledTxPin" ) ||
229- ! data[" notification" ]. containsKey ( " ledMessage" ) ||
230- ! data[" notification" ]. containsKey ( " ledMessagePin" ) ||
231- ! data[" notification" ]. containsKey ( " buzzerActive" ) ||
232- ! data[" notification" ]. containsKey ( " buzzerPinTone" ) ||
233- ! data[" notification" ]. containsKey ( " buzzerPinVcc" ) ||
234- ! data[" notification" ]. containsKey ( " bootUpBeep" ) ||
235- ! data[" notification" ]. containsKey ( " txBeep" ) ||
236- ! data[" notification" ]. containsKey ( " messageRxBeep" ) ||
237- ! data[" notification" ]. containsKey ( " stationBeep" ) ||
238- ! data[" notification" ]. containsKey ( " lowBatteryBeep" ) ||
239- ! data[" notification" ]. containsKey ( " shutDownBeep" ) ||
240- ! data[" notification" ]. containsKey ( " ledFlashlight" ) ||
241- ! data[" notification" ]. containsKey ( " ledFlashlightPin" )) needsRewrite = true ;
226+ if (data[" notification" ][ " ledTx" ]. isNull ( ) ||
227+ data[" notification" ][ " ledTxPin" ]. isNull ( ) ||
228+ data[" notification" ][ " ledMessage" ]. isNull ( ) ||
229+ data[" notification" ][ " ledMessagePin" ]. isNull ( ) ||
230+ data[" notification" ][ " buzzerActive" ]. isNull ( ) ||
231+ data[" notification" ][ " buzzerPinTone" ]. isNull ( ) ||
232+ data[" notification" ][ " buzzerPinVcc" ]. isNull ( ) ||
233+ data[" notification" ][ " bootUpBeep" ]. isNull ( ) ||
234+ data[" notification" ][ " txBeep" ]. isNull ( ) ||
235+ data[" notification" ][ " messageRxBeep" ]. isNull ( ) ||
236+ data[" notification" ][ " stationBeep" ]. isNull ( ) ||
237+ data[" notification" ][ " lowBatteryBeep" ]. isNull ( ) ||
238+ data[" notification" ][ " shutDownBeep" ]. isNull ( ) ||
239+ data[" notification" ][ " ledFlashlight" ]. isNull ( ) ||
240+ data[" notification" ][ " ledFlashlightPin" ]. isNull ( )) needsRewrite = true ;
242241 notification.ledTx = data[" notification" ][" ledTx" ] | false ;
243242 notification.ledTxPin = data[" notification" ][" ledTxPin" ]| 13 ;
244243 notification.ledMessage = data[" notification" ][" ledMessage" ] | false ;
@@ -255,26 +254,26 @@ bool Configuration::readFile() {
255254 notification.ledFlashlight = data[" notification" ][" ledFlashlight" ] | false ;
256255 notification.ledFlashlightPin = data[" notification" ][" ledFlashlightPin" ] | 14 ;
257256
258- if (! data[" pttTrigger" ]. containsKey ( " active" ) ||
259- ! data[" pttTrigger" ]. containsKey ( " reverse" ) ||
260- ! data[" pttTrigger" ]. containsKey ( " preDelay" ) ||
261- ! data[" pttTrigger" ]. containsKey ( " postDelay" ) ||
262- ! data[" pttTrigger" ]. containsKey ( " io_pin" )) needsRewrite = true ;
257+ if (data[" pttTrigger" ][ " active" ]. isNull ( ) ||
258+ data[" pttTrigger" ][ " reverse" ]. isNull ( ) ||
259+ data[" pttTrigger" ][ " preDelay" ]. isNull ( ) ||
260+ data[" pttTrigger" ][ " postDelay" ]. isNull ( ) ||
261+ data[" pttTrigger" ][ " io_pin" ]. isNull ( )) needsRewrite = true ;
263262 ptt.active = data[" pttTrigger" ][" active" ] | false ;
264263 ptt.reverse = data[" pttTrigger" ][" reverse" ] | false ;
265264 ptt.preDelay = data[" pttTrigger" ][" preDelay" ] | 0 ;
266265 ptt.postDelay = data[" pttTrigger" ][" postDelay" ] | 0 ;
267266 ptt.io_pin = data[" pttTrigger" ][" io_pin" ] | 4 ;
268267
269- if (! data[" other" ]. containsKey ( " simplifiedTrackerMode" ) ||
270- ! data[" other" ]. containsKey ( " sendCommentAfterXBeacons" ) ||
271- ! data[" other" ]. containsKey ( " path" ) ||
272- ! data[" other" ]. containsKey ( " nonSmartBeaconRate" ) ||
273- ! data[" other" ]. containsKey ( " rememberStationTime" ) ||
274- ! data[" other" ]. containsKey ( " standingUpdateTime" ) ||
275- ! data[" other" ]. containsKey ( " sendAltitude" ) ||
276- ! data[" other" ]. containsKey ( " disableGPS" ) ||
277- ! data[" other" ]. containsKey ( " email" )) needsRewrite = true ;
268+ if (data[" other" ][ " simplifiedTrackerMode" ]. isNull ( ) ||
269+ data[" other" ][ " sendCommentAfterXBeacons" ]. isNull ( ) ||
270+ data[" other" ][ " path" ]. isNull ( ) ||
271+ data[" other" ][ " nonSmartBeaconRate" ]. isNull ( ) ||
272+ data[" other" ][ " rememberStationTime" ]. isNull ( ) ||
273+ data[" other" ][ " standingUpdateTime" ]. isNull ( ) ||
274+ data[" other" ][ " sendAltitude" ]. isNull ( ) ||
275+ data[" other" ][ " disableGPS" ]. isNull ( ) ||
276+ data[" other" ][ " email" ]. isNull ( )) needsRewrite = true ;
278277 simplifiedTrackerMode = data[" other" ][" simplifiedTrackerMode" ] | false ;
279278 sendCommentAfterXBeacons = data[" other" ][" sendCommentAfterXBeacons" ] | 10 ;
280279 path = data[" other" ][" path" ] | " WIDE1-1" ;
0 commit comments