From 7c7a15e016594e4d841d9270ecbe8158b086056f Mon Sep 17 00:00:00 2001 From: Bernhard Kirchen Date: Thu, 10 Aug 2023 13:40:09 +0200 Subject: [PATCH] VE.Direct: websocket and status API response size (#371) the size allocated for the HTTP request response was too little, while the size for the buffer of the websocket output was increased already. add a new member variable and use it in both context, such that increasing the buffer size to accomodate more space (for the JSON data in particular) will benefit both contexts in the future. --- include/WebApi_ws_vedirect_live.h | 1 + src/WebApi_ws_vedirect_live.cpp | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/WebApi_ws_vedirect_live.h b/include/WebApi_ws_vedirect_live.h index f85f332a..d17f51c0 100644 --- a/include/WebApi_ws_vedirect_live.h +++ b/include/WebApi_ws_vedirect_live.h @@ -23,4 +23,5 @@ private: uint32_t _lastVedirectUpdateCheck = 0; uint32_t _lastWsCleanup = 0; uint32_t _newestVedirectTimestamp = 0; + static constexpr uint16_t _responseSize = 1024 + 128; }; \ No newline at end of file diff --git a/src/WebApi_ws_vedirect_live.cpp b/src/WebApi_ws_vedirect_live.cpp index e416ff87..f4835e4c 100644 --- a/src/WebApi_ws_vedirect_live.cpp +++ b/src/WebApi_ws_vedirect_live.cpp @@ -61,7 +61,7 @@ void WebApiWsVedirectLiveClass::loop() String buffer; // free JsonDocument as soon as possible { - DynamicJsonDocument root(2048); + DynamicJsonDocument root(_responseSize); JsonVariant var = root; generateJsonResponse(var); serializeJson(root, buffer); @@ -173,7 +173,7 @@ void WebApiWsVedirectLiveClass::onLivedataStatus(AsyncWebServerRequest* request) return; } try { - AsyncJsonResponse* response = new AsyncJsonResponse(false, 1024U); + AsyncJsonResponse* response = new AsyncJsonResponse(false, _responseSize); JsonVariant root = response->getRoot(); generateJsonResponse(root);