From a51bc276b56b70dd7f4eceda0fe4da9030c41ff1 Mon Sep 17 00:00:00 2001 From: Proddy Date: Thu, 5 Jan 2023 15:11:34 +0100 Subject: [PATCH] use new SIZES --- src/web/WebAPIService.cpp | 2 +- src/web/WebCustomizationService.cpp | 4 ++-- src/web/WebDataService.cpp | 6 +++--- src/web/WebLogService.cpp | 3 ++- src/web/WebStatusService.cpp | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/web/WebAPIService.cpp b/src/web/WebAPIService.cpp index 1fc33e827..666c76467 100644 --- a/src/web/WebAPIService.cpp +++ b/src/web/WebAPIService.cpp @@ -101,7 +101,7 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject & input) { } // output json buffer - size_t buffer = EMSESP_JSON_SIZE_XXLARGE_DYN; + size_t buffer = EMSESP_JSON_SIZE_XXXLARGE; auto * response = new PrettyAsyncJsonResponse(false, buffer); while (!response->getSize()) { delete response; diff --git a/src/web/WebCustomizationService.cpp b/src/web/WebCustomizationService.cpp index bf1ed8b41..67842bd3a 100644 --- a/src/web/WebCustomizationService.cpp +++ b/src/web/WebCustomizationService.cpp @@ -178,7 +178,7 @@ void WebCustomizationService::reset_customization(AsyncWebServerRequest * reques // send back a list of devices used in the customization web page void WebCustomizationService::devices(AsyncWebServerRequest * request) { - auto * response = new AsyncJsonResponse(false, EMSESP_JSON_SIZE_LARGE_DYN); + auto * response = new AsyncJsonResponse(false, EMSESP_JSON_SIZE_XLARGE); JsonObject root = response->getRoot(); // list is already sorted by device type @@ -201,7 +201,7 @@ void WebCustomizationService::devices(AsyncWebServerRequest * request) { // send back list of device entities void WebCustomizationService::device_entities(AsyncWebServerRequest * request, JsonVariant & json) { if (json.is()) { - size_t buffer = EMSESP_JSON_SIZE_XXXLARGE_DYN; + size_t buffer = EMSESP_JSON_SIZE_XXXXLARGE; auto * response = new MsgpackAsyncJsonResponse(true, buffer); while (!response->getSize()) { delete response; diff --git a/src/web/WebDataService.cpp b/src/web/WebDataService.cpp index 5331bd09f..b54028963 100644 --- a/src/web/WebDataService.cpp +++ b/src/web/WebDataService.cpp @@ -70,7 +70,7 @@ void WebDataService::scan_devices(AsyncWebServerRequest * request) { // this is used in the dashboard and contains all ems device information // /coreData endpoint void WebDataService::core_data(AsyncWebServerRequest * request) { - auto * response = new AsyncJsonResponse(false, EMSESP_JSON_SIZE_XLARGE_DYN); + auto * response = new AsyncJsonResponse(false, EMSESP_JSON_SIZE_XXLARGE); JsonObject root = response->getRoot(); // list is already sorted by device type @@ -105,7 +105,7 @@ void WebDataService::core_data(AsyncWebServerRequest * request) { // /sensorData endpoint // the "sensors" and "analogs" are arrays and must exist void WebDataService::sensor_data(AsyncWebServerRequest * request) { - auto * response = new AsyncJsonResponse(false, EMSESP_JSON_SIZE_XLARGE_DYN); + auto * response = new AsyncJsonResponse(false, EMSESP_JSON_SIZE_XXLARGE); JsonObject root = response->getRoot(); // dallas sensors @@ -166,7 +166,7 @@ void WebDataService::sensor_data(AsyncWebServerRequest * request) { // Compresses the JSON using MsgPack https://msgpack.org/index.html void WebDataService::device_data(AsyncWebServerRequest * request, JsonVariant & json) { if (json.is()) { - size_t buffer = EMSESP_JSON_SIZE_XXXLARGE_DYN; + size_t buffer = EMSESP_JSON_SIZE_XXXXLARGE; auto * response = new MsgpackAsyncJsonResponse(false, buffer); while (!response->getSize()) { delete response; diff --git a/src/web/WebLogService.cpp b/src/web/WebLogService.cpp index e76351cfb..1efea5d04 100644 --- a/src/web/WebLogService.cpp +++ b/src/web/WebLogService.cpp @@ -185,6 +185,7 @@ char * WebLogService::messagetime(char * out, const uint64_t t, const size_t buf // send to web eventsource void WebLogService::transmit(const QueuedLogMessage & message) { + // TODO use StaticJsonDocument ? auto jsonDocument = DynamicJsonDocument(EMSESP_JSON_SIZE_MEDIUM); JsonObject logEvent = jsonDocument.to(); char time_string[25]; @@ -206,7 +207,7 @@ void WebLogService::transmit(const QueuedLogMessage & message) { // send the complete log buffer to the API, not filtering on log level void WebLogService::fetchLog(AsyncWebServerRequest * request) { - auto * response = new MsgpackAsyncJsonResponse(false, EMSESP_JSON_SIZE_LARGE_DYN + 192 * log_messages_.size()); + auto * response = new MsgpackAsyncJsonResponse(false, EMSESP_JSON_SIZE_XLARGE + 192 * log_messages_.size()); JsonObject root = response->getRoot(); JsonArray log = root.createNestedArray("events"); diff --git a/src/web/WebStatusService.cpp b/src/web/WebStatusService.cpp index f3bfb9003..476bddc7b 100644 --- a/src/web/WebStatusService.cpp +++ b/src/web/WebStatusService.cpp @@ -120,7 +120,7 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) { } void WebStatusService::webStatusService(AsyncWebServerRequest * request) { - auto * response = new AsyncJsonResponse(false, EMSESP_JSON_SIZE_MEDIUM_DYN); + auto * response = new AsyncJsonResponse(false, EMSESP_JSON_SIZE_LARGE); JsonObject root = response->getRoot(); root["status"] = EMSESP::bus_status(); // 0, 1 or 2