Skip to content

Commit c3b8552

Browse files
committed
type and migrate to ArduinoJson 7.x
- typo in config page - migrate to ArduinoJson 7.x (do not use depricated functions)
1 parent 3e2fcff commit c3b8552

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

software/CONFIG.h

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ class CONFIG {
133133

134134
/** constructor
135135
*/
136-
CONFIG() : json(CONFIG_JSON_MAXSIZE) {
136+
CONFIG() {
137137
mutex = xSemaphoreCreateMutex();
138138
ffsOk = false;
139139
// create a unique name from the mac
@@ -272,7 +272,6 @@ class CONFIG {
272272
changed = !old.equals(value);
273273
if (changed) {
274274
json[String(key)] = value;
275-
json.garbageCollect();
276275
}
277276
xSemaphoreGive(mutex);
278277
}
@@ -294,7 +293,6 @@ class CONFIG {
294293
changed = json.containsKey(key);
295294
if (changed) {
296295
json.remove(key);
297-
json.garbageCollect();
298296
}
299297
xSemaphoreGive(mutex);
300298
}
@@ -393,7 +391,7 @@ class CONFIG {
393391
* \param size the size of the json buffer
394392
*/
395393
void setLbandFreqs(const uint8_t *buf, size_t size) {
396-
DynamicJsonDocument json(512);
394+
JsonDocument json;
397395
DeserializationError error = deserializeJson(json, buf, size);
398396
if (DeserializationError::Ok != error) {
399397
log_e("deserializeJson failed with error %d", error);
@@ -452,8 +450,6 @@ class CONFIG {
452450
changed = true;
453451
}
454452
}
455-
if (changed)
456-
json.garbageCollect();
457453
xSemaphoreGive(mutex);
458454
}
459455
if (changed) {
@@ -472,7 +468,6 @@ class CONFIG {
472468
json.remove(CONFIG_VALUE_CLIENTCERT);
473469
json.remove(CONFIG_VALUE_CLIENTKEY);
474470
json.remove(CONFIG_VALUE_CLIENTID);
475-
json.garbageCollect();
476471
xSemaphoreGive(mutex);
477472
}
478473
log_i("ZTP deleted");
@@ -485,13 +480,13 @@ class CONFIG {
485480
*/
486481
String setZtp(String &ztp, String &rootCa) {
487482
String id;
488-
StaticJsonDocument<200> filter;
483+
JsonDocument filter;
489484
filter["clientId"] = true;
490485
filter["certificate"] = true;
491486
filter["privateKey"] = true;
492487
filter["brokerHost"] = true;
493488
filter["supportsLband"] = true;
494-
DynamicJsonDocument jsonZtp(4*1024);
489+
JsonDocument jsonZtp;
495490
DeserializationError error = deserializeJson(jsonZtp, ztp.c_str(), DeserializationOption::Filter(filter));
496491
if (DeserializationError::Ok != error) {
497492
log_e("deserializeJson failed with error %d", error);
@@ -510,7 +505,6 @@ class CONFIG {
510505
json[CONFIG_VALUE_CLIENTCERT] = cert;
511506
json[CONFIG_VALUE_CLIENTKEY] = key;
512507
json[CONFIG_VALUE_CLIENTID] = id;
513-
json.garbageCollect();
514508
xSemaphoreGive(mutex);
515509
}
516510
save();
@@ -532,7 +526,7 @@ class CONFIG {
532526
}
533527
String str;
534528
if (token.length()) {
535-
DynamicJsonDocument json(256);
529+
JsonDocument json;
536530
json["tags"][0] = "ztp";
537531
json["token"] = token.c_str();
538532
json["hardwareId"] = getDeviceName();
@@ -565,7 +559,7 @@ class CONFIG {
565559
return ffsOk;
566560
}
567561

568-
DynamicJsonDocument json; //!< a local copy of the json buffer
562+
JsonDocument json; //!< a local copy of the json buffer
569563
SemaphoreHandle_t mutex; //!< protects json and FFS
570564
bool ffsOk; //!< flag if the FFS is ok
571565
String title; //!< the title of the device

software/WLAN.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class WLAN {
132132
new (&parameters[p++]) WiFiManagerParameter(CONFIG_VALUE_LTEAPN, "APN", Config.getValue(CONFIG_VALUE_LTEAPN).c_str(), 64);
133133
new (&parameters[p++]) WiFiManagerParameter(CONFIG_VALUE_SIMPIN, "SIM pin", Config.getValue(CONFIG_VALUE_SIMPIN).c_str(), 8, " type=\"password\"");
134134
new (&parameters[p++]) WiFiManagerParameter("<p style=\"font-weight:Bold;\">NTRIP configuration</p>"
135-
"<p>To use NTRIP you need to set Correction source to one of the NTRIP options.</p>");
135+
"<p>To use NTRIP you need to set Correction Source to one of the NTRIP options.</p>");
136136
new (&parameters[p++]) WiFiManagerParameter(CONFIG_VALUE_NTRIP_SERVER, "NTRIP correction service", Config.getValue(CONFIG_VALUE_NTRIP_SERVER).c_str(), 64,
137137
" placeholder=\"server.com:2101/MountPoint\" pattern=\"^([0-9a-zA-Z_\\-]+\\.)+([0-9a-zA-Z_\\-]{2,})(:[0-9]+)?\\/[0-9a-zA-Z_\\-]+$\"");
138138
new (&parameters[p++]) WiFiManagerParameter(CONFIG_VALUE_NTRIP_USERNAME, "Username", Config.getValue(CONFIG_VALUE_NTRIP_USERNAME).c_str(), 64);

0 commit comments

Comments
 (0)