Added conditional compile for dynamic JSON buffer.

- WLED_USE_DYNAMIC_JSON
Minor fixes.
This commit is contained in:
Blaz Kristan
2021-11-07 11:58:16 +01:00
parent f7de055f67
commit f8da8f6929
17 changed files with 111 additions and 44 deletions

View File

@@ -43,24 +43,25 @@ void handleSerial()
}
else if (next == '{') { //JSON API
bool verboseResponse = false;
#ifdef WLED_USE_DYNAMIC_JSON
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
#else
while (jsonBufferLock) delay(1);
jsonBufferLock = true;
doc.clear();
{
//DynamicJsonDocument doc(JSON_BUFFER_SIZE);
Serial.setTimeout(100);
DeserializationError error = deserializeJson(doc, Serial);
if (error) {
jsonBufferLock = false;
return;
}
fileDoc = &doc;
verboseResponse = deserializeState(doc.as<JsonObject>());
fileDoc = nullptr;
#endif
Serial.setTimeout(100);
DeserializationError error = deserializeJson(doc, Serial);
if (error) {
jsonBufferLock = false;
return;
}
fileDoc = &doc;
verboseResponse = deserializeState(doc.as<JsonObject>());
fileDoc = nullptr;
//only send response if TX pin is unused for other purposes
if (verboseResponse && !pinManager.isPinAllocated(1)) {
//DynamicJsonDocument doc(JSON_BUFFER_SIZE);
doc.clear();
JsonObject state = doc.createNestedObject("state");
serializeState(state);