@@ -133,7 +133,7 @@ class CONFIG {
133
133
134
134
/* * constructor
135
135
*/
136
- CONFIG () : json(CONFIG_JSON_MAXSIZE) {
136
+ CONFIG () {
137
137
mutex = xSemaphoreCreateMutex ();
138
138
ffsOk = false ;
139
139
// create a unique name from the mac
@@ -272,7 +272,6 @@ class CONFIG {
272
272
changed = !old.equals (value);
273
273
if (changed) {
274
274
json[String (key)] = value;
275
- json.garbageCollect ();
276
275
}
277
276
xSemaphoreGive (mutex);
278
277
}
@@ -294,7 +293,6 @@ class CONFIG {
294
293
changed = json.containsKey (key);
295
294
if (changed) {
296
295
json.remove (key);
297
- json.garbageCollect ();
298
296
}
299
297
xSemaphoreGive (mutex);
300
298
}
@@ -393,7 +391,7 @@ class CONFIG {
393
391
* \param size the size of the json buffer
394
392
*/
395
393
void setLbandFreqs (const uint8_t *buf, size_t size) {
396
- DynamicJsonDocument json ( 512 ) ;
394
+ JsonDocument json;
397
395
DeserializationError error = deserializeJson (json, buf, size);
398
396
if (DeserializationError::Ok != error) {
399
397
log_e (" deserializeJson failed with error %d" , error);
@@ -452,8 +450,6 @@ class CONFIG {
452
450
changed = true ;
453
451
}
454
452
}
455
- if (changed)
456
- json.garbageCollect ();
457
453
xSemaphoreGive (mutex);
458
454
}
459
455
if (changed) {
@@ -472,7 +468,6 @@ class CONFIG {
472
468
json.remove (CONFIG_VALUE_CLIENTCERT);
473
469
json.remove (CONFIG_VALUE_CLIENTKEY);
474
470
json.remove (CONFIG_VALUE_CLIENTID);
475
- json.garbageCollect ();
476
471
xSemaphoreGive (mutex);
477
472
}
478
473
log_i (" ZTP deleted" );
@@ -485,13 +480,13 @@ class CONFIG {
485
480
*/
486
481
String setZtp (String &ztp, String &rootCa) {
487
482
String id;
488
- StaticJsonDocument< 200 > filter;
483
+ JsonDocument filter;
489
484
filter[" clientId" ] = true ;
490
485
filter[" certificate" ] = true ;
491
486
filter[" privateKey" ] = true ;
492
487
filter[" brokerHost" ] = true ;
493
488
filter[" supportsLband" ] = true ;
494
- DynamicJsonDocument jsonZtp ( 4 * 1024 ) ;
489
+ JsonDocument jsonZtp;
495
490
DeserializationError error = deserializeJson (jsonZtp, ztp.c_str (), DeserializationOption::Filter (filter));
496
491
if (DeserializationError::Ok != error) {
497
492
log_e (" deserializeJson failed with error %d" , error);
@@ -510,7 +505,6 @@ class CONFIG {
510
505
json[CONFIG_VALUE_CLIENTCERT] = cert;
511
506
json[CONFIG_VALUE_CLIENTKEY] = key;
512
507
json[CONFIG_VALUE_CLIENTID] = id;
513
- json.garbageCollect ();
514
508
xSemaphoreGive (mutex);
515
509
}
516
510
save ();
@@ -532,7 +526,7 @@ class CONFIG {
532
526
}
533
527
String str;
534
528
if (token.length ()) {
535
- DynamicJsonDocument json ( 256 ) ;
529
+ JsonDocument json;
536
530
json[" tags" ][0 ] = " ztp" ;
537
531
json[" token" ] = token.c_str ();
538
532
json[" hardwareId" ] = getDeviceName ();
@@ -565,7 +559,7 @@ class CONFIG {
565
559
return ffsOk;
566
560
}
567
561
568
- DynamicJsonDocument json; // !< a local copy of the json buffer
562
+ JsonDocument json; // !< a local copy of the json buffer
569
563
SemaphoreHandle_t mutex; // !< protects json and FFS
570
564
bool ffsOk; // !< flag if the FFS is ok
571
565
String title; // !< the title of the device
0 commit comments