Single JSON buffer.
This commit is contained in:
@@ -43,18 +43,25 @@ void handleSerial()
|
||||
}
|
||||
else if (next == '{') { //JSON API
|
||||
bool verboseResponse = false;
|
||||
while (jsonBufferLock) delay(1);
|
||||
jsonBufferLock = true;
|
||||
doc.clear();
|
||||
{
|
||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||
//DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||
Serial.setTimeout(100);
|
||||
DeserializationError error = deserializeJson(doc, Serial);
|
||||
if (error) return;
|
||||
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);
|
||||
//DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||
doc.clear();
|
||||
JsonObject state = doc.createNestedObject("state");
|
||||
serializeState(state);
|
||||
JsonObject info = doc.createNestedObject("info");
|
||||
@@ -62,6 +69,7 @@ void handleSerial()
|
||||
|
||||
serializeJson(doc, Serial);
|
||||
}
|
||||
jsonBufferLock = false;
|
||||
}
|
||||
break;
|
||||
case AdaState::Header_d:
|
||||
|
||||
Reference in New Issue
Block a user