change json package size, min 384, max 1024 for static, 2048 for dynamic

This commit is contained in:
MichaelDvP
2020-11-14 15:52:02 +01:00
parent 992f325078
commit 548c07f932
3 changed files with 8 additions and 8 deletions

View File

@@ -14,6 +14,7 @@
- change syslog settings without reboot
- HA-config split in smaller blocks
- commands `fetch` and `publish [ha]` as call
- mqtt json package size
### Removed
- old scripts

View File

@@ -71,7 +71,7 @@ void WebAPIService::webAPIService(AsyncWebServerRequest * request) {
id = "-1";
}
DynamicJsonDocument doc(EMSESP_MAX_JSON_SIZE_LARGE);
DynamicJsonDocument doc(EMSESP_MAX_JSON_SIZE_DYN);
JsonObject json = doc.to<JsonObject>();
bool ok = false;
@@ -101,7 +101,7 @@ void WebAPIService::webAPIService(AsyncWebServerRequest * request) {
ok ? PSTR("OK") : PSTR("Invalid"));
EMSESP::logger().info(debug.c_str());
if (json.size()) {
char buffer2[EMSESP_MAX_JSON_SIZE_LARGE];
char buffer2[EMSESP_MAX_JSON_SIZE_DYN];
serializeJson(doc, buffer2);
EMSESP::logger().info("json (max 255 chars): %s", buffer2);
}
@@ -110,7 +110,7 @@ void WebAPIService::webAPIService(AsyncWebServerRequest * request) {
// if we have returned data in JSON format, send this to the WEB
if (json.size()) {
doc.shrinkToFit();
char buffer[EMSESP_MAX_JSON_SIZE_LARGE];
char buffer[EMSESP_MAX_JSON_SIZE_DYN];
serializeJsonPretty(doc, buffer);
request->send(200, "text/plain", buffer);
} else {

View File

@@ -38,11 +38,10 @@
using uuid::console::Shell;
#define EMSESP_MAX_JSON_SIZE_SMALL 256 // for smaller json docs when using StaticJsonDocument
#define EMSESP_MAX_JSON_SIZE_MEDIUM 768 // for smaller json docs from ems devices, when using StaticJsonDocument
// #define EMSESP_MAX_JSON_SIZE_LARGE 2048 // for large json docs from ems devices, like boiler or thermostat data. Using DynamicJsonDocument
// mqtt does not publish larger than 1570 on esp8266, boiler message is split and now smaller
#define EMSESP_MAX_JSON_SIZE_LARGE 1536 // for large json docs from ems devices, like boiler or thermostat data. Using StaticJsonDocument
#define EMSESP_MAX_JSON_SIZE_SMALL 384 // for smaller json docs when using StaticJsonDocument
#define EMSESP_MAX_JSON_SIZE_MEDIUM 768 // for medium json docs from ems devices, when using StaticJsonDocument
#define EMSESP_MAX_JSON_SIZE_LARGE 1024 // for large json docs from ems devices, like boiler or thermostat data. Using StaticJsonDocument
#define EMSESP_MAX_JSON_SIZE_DYN 2048 // for large json docs from web. Using DynamicJsonDocument
namespace emsesp {