Skip to content

Commit

Permalink
fix: liveData is not updated
Browse files Browse the repository at this point in the history
- due to roll back of upstream commit, duplicated code allocated json buffer twice
- enlarge json buffer to 4200
  • Loading branch information
helgeerbe committed Oct 24, 2023
1 parent 9ca3655 commit 49a1030
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/WebApi_ws_live.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,14 @@ void WebApiWsLiveClass::loop()

try {
std::lock_guard<std::mutex> lock(_mutex);
DynamicJsonDocument root(4096 * INV_MAX_COUNT);
DynamicJsonDocument root(4200 * INV_MAX_COUNT); // TODO(helge) check if this calculation is correct
JsonVariant var = root;
generateJsonResponse(var);

String buffer;
// free JsonDocument as soon as possible
{
DynamicJsonDocument root(4096 * INV_MAX_COUNT); // TODO(helge) check if this calculation is correct
JsonVariant var = root;
generateJsonResponse(var);
if (buffer) {
serializeJson(root, buffer);
}

if (buffer) {
if (Configuration.get().Security_AllowReadonly) {
_ws.setAuthentication("", "");
} else {
Expand Down Expand Up @@ -252,7 +246,7 @@ void WebApiWsLiveClass::onLivedataStatus(AsyncWebServerRequest* request)

try {
std::lock_guard<std::mutex> lock(_mutex);
AsyncJsonResponse* response = new AsyncJsonResponse(false, 4096 * INV_MAX_COUNT);
AsyncJsonResponse* response = new AsyncJsonResponse(false, 4200 * INV_MAX_COUNT);
JsonVariant root = response->getRoot();

generateJsonResponse(root);
Expand Down

0 comments on commit 49a1030

Please sign in to comment.