Single json buffer (#2336)

* Single/static JSON buffer for all requests.

* Missing json.cpp changes.

* Async fix.

* Added conditional compile (WLED_USE_DYNAMIC_JSON).

* Advanced locking with time-out.

* Missing releaseJSONBufferLock() on error response.

* Fix for config saving.

* Fixes and optimisations.
Dadded debugging information.

* Fix for ledmaps.

* No unsolicited serial sending if GPIO1 allocated

* Stray semicolons

* Fix JSON ledmap

Co-authored-by: Blaz Kristan <blaz@kristan-sp.si>
This commit is contained in:
Christian Schwinne
2021-12-04 01:05:01 +01:00
committed by GitHub
parent 46ec504743
commit 66bad2b6f8
18 changed files with 272 additions and 91 deletions

View File

@@ -433,7 +433,12 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
//USERMODS
if (subPage == 8)
{
#ifdef WLED_USE_DYNAMIC_JSON
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
#else
if (!requestJSONBufferLock(5)) return;
#endif
JsonObject um = doc.createNestedObject("um");
size_t args = request->args();
@@ -508,6 +513,8 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
usermods.readFromConfig(um); // force change of usermod parameters
}
releaseJSONBufferLock();
if (subPage != 2 && (subPage != 6 || !doReboot)) serializeConfig(); //do not save if factory reset or LED settings (which are saved after LED re-init)
if (subPage == 4) alexaInit();
}