mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 16:29:51 +03:00
increase ws buffer sizes - https://github.com/proddy/EMS-ESP/issues/250
This commit is contained in:
@@ -1472,8 +1472,8 @@ void MyESP::_heartbeatCheck(bool force) {
|
||||
uint32_t free_memory = ESP.getFreeHeap();
|
||||
uint8_t mem_available = 100 * free_memory / total_memory; // as a %
|
||||
|
||||
StaticJsonDocument<200> doc;
|
||||
JsonObject rootHeartbeat = doc.to<JsonObject>();
|
||||
StaticJsonDocument<MYESP_JSON_MAXSIZE_SMALL> doc;
|
||||
JsonObject rootHeartbeat = doc.to<JsonObject>();
|
||||
|
||||
rootHeartbeat["version"] = _app_version;
|
||||
rootHeartbeat["IP"] = WiFi.localIP().toString();
|
||||
@@ -2312,11 +2312,13 @@ void MyESP::_onWsEvent(AsyncWebSocket * server, AsyncWebSocketClient * client, A
|
||||
// handle ws from browser
|
||||
void MyESP::_procMsg(AsyncWebSocketClient * client, size_t sz) {
|
||||
// We should always get a JSON object from browser, so parse it
|
||||
StaticJsonDocument<500> doc;
|
||||
char json[sz + 1];
|
||||
StaticJsonDocument<MYESP_JSON_MAXSIZE_MEDIUM> doc;
|
||||
char json[sz + 1];
|
||||
memcpy(json, (char *)(client->_tempObject), sz);
|
||||
json[sz] = '\0';
|
||||
|
||||
// Serial.printf("[%s]", json);
|
||||
|
||||
JsonObject root = doc.to<JsonObject>(); // create empty object
|
||||
DeserializationError error = deserializeJson(doc, json); // Deserialize the JSON document
|
||||
if (error) {
|
||||
@@ -2410,8 +2412,7 @@ bool MyESP::_fs_sendConfig() {
|
||||
|
||||
// send custom status via ws
|
||||
void MyESP::_sendCustomStatus() {
|
||||
// StaticJsonDocument<300> doc;
|
||||
DynamicJsonDocument doc(MYESP_JSON_MAXSIZE);
|
||||
DynamicJsonDocument doc(MYESP_JSON_MAXSIZE_LARGE);
|
||||
|
||||
JsonObject root = doc.to<JsonObject>();
|
||||
|
||||
@@ -2427,7 +2428,7 @@ void MyESP::_sendCustomStatus() {
|
||||
(_web_callback_f)(root);
|
||||
}
|
||||
|
||||
char buffer[MYESP_JSON_MAXSIZE];
|
||||
char buffer[MYESP_JSON_MAXSIZE_LARGE];
|
||||
size_t len = serializeJson(root, buffer);
|
||||
|
||||
#ifdef MYESP_DEBUG
|
||||
@@ -2536,9 +2537,9 @@ void MyESP::_printScanResult(int networksFound) {
|
||||
}
|
||||
}
|
||||
|
||||
StaticJsonDocument<400> doc;
|
||||
JsonObject root = doc.to<JsonObject>();
|
||||
root["command"] = "ssidlist";
|
||||
StaticJsonDocument<MYESP_JSON_MAXSIZE_MEDIUM> doc;
|
||||
JsonObject root = doc.to<JsonObject>();
|
||||
root["command"] = "ssidlist";
|
||||
|
||||
JsonArray list = doc.createNestedArray("list");
|
||||
for (int i = 0; i <= 5 && i < networksFound; ++i) {
|
||||
@@ -2548,7 +2549,7 @@ void MyESP::_printScanResult(int networksFound) {
|
||||
item["rssi"] = WiFi.RSSI(indices[i]);
|
||||
}
|
||||
|
||||
char buffer[400];
|
||||
char buffer[MYESP_JSON_MAXSIZE_MEDIUM];
|
||||
size_t len = serializeJson(root, buffer);
|
||||
_ws->textAll(buffer, len);
|
||||
}
|
||||
@@ -2750,12 +2751,12 @@ void MyESP::_addMQTTLog(const char * topic, const char * payload, const MYESP_MQ
|
||||
|
||||
// send UTC time via ws
|
||||
void MyESP::_sendTime() {
|
||||
StaticJsonDocument<100> doc;
|
||||
JsonObject root = doc.to<JsonObject>();
|
||||
root["command"] = "gettime";
|
||||
root["epoch"] = now();
|
||||
StaticJsonDocument<MYESP_JSON_MAXSIZE_SMALL> doc;
|
||||
JsonObject root = doc.to<JsonObject>();
|
||||
root["command"] = "gettime";
|
||||
root["epoch"] = now();
|
||||
|
||||
char buffer[100];
|
||||
char buffer[MYESP_JSON_MAXSIZE_SMALL];
|
||||
size_t len = serializeJson(root, buffer);
|
||||
_ws->textAll(buffer, len);
|
||||
}
|
||||
|
||||
@@ -103,9 +103,11 @@ extern struct rst_info resetInfo;
|
||||
#define MQTT_DISCONNECT_EVENT 1
|
||||
#define MQTT_MESSAGE_EVENT 2
|
||||
|
||||
#define MYESP_JSON_MAXSIZE 2000 // for large Dynamic json files
|
||||
#define MYESP_MQTTLOG_MAX 60 // max number of log entries for MQTT publishes and subscribes
|
||||
#define MYESP_JSON_LOG_MAXSIZE 300 // max size of an JSON log entry
|
||||
#define MYESP_JSON_MAXSIZE_LARGE 2000 // for large Dynamic json files
|
||||
#define MYESP_JSON_MAXSIZE_MEDIUM 800 // for medium Dynamic json files
|
||||
#define MYESP_JSON_MAXSIZE_SMALL 200 // for smaller Static json documents
|
||||
|
||||
#define MYESP_MQTTLOG_MAX 60 // max number of log entries for MQTT publishes and subscribes
|
||||
|
||||
#define MYESP_MQTT_PAYLOAD_ON '1' // for MQTT switch on
|
||||
#define MYESP_MQTT_PAYLOAD_OFF '0' // for MQTT switch off
|
||||
|
||||
@@ -515,8 +515,8 @@ void publishSensorValues(bool force) {
|
||||
return; // no sensors attached
|
||||
}
|
||||
|
||||
StaticJsonDocument<200> doc;
|
||||
JsonObject sensors = doc.to<JsonObject>();
|
||||
StaticJsonDocument<MYESP_JSON_MAXSIZE_SMALL> doc;
|
||||
JsonObject sensors = doc.to<JsonObject>();
|
||||
|
||||
bool hasdata = false;
|
||||
char label[8] = {0};
|
||||
@@ -539,7 +539,7 @@ void publishSensorValues(bool force) {
|
||||
CRC32 crc;
|
||||
uint32_t fchecksum;
|
||||
|
||||
char data[200] = {0};
|
||||
char data[MYESP_JSON_MAXSIZE_SMALL] = {0};
|
||||
serializeJson(doc, data, sizeof(data));
|
||||
|
||||
size_t jsonSize = measureJson(doc);
|
||||
@@ -1038,10 +1038,10 @@ bool LoadSaveCallback(MYESP_FSACTION_t action, JsonObject settings) {
|
||||
|
||||
// Publish shower data
|
||||
bool do_publishShowerData() {
|
||||
StaticJsonDocument<200> doc;
|
||||
JsonObject rootShower = doc.to<JsonObject>();
|
||||
rootShower[TOPIC_SHOWER_TIMER] = EMSESP_Settings.shower_timer ? "1" : "0";
|
||||
rootShower[TOPIC_SHOWER_ALERT] = EMSESP_Settings.shower_alert ? "1" : "0";
|
||||
StaticJsonDocument<MYESP_JSON_MAXSIZE_SMALL> doc;
|
||||
JsonObject rootShower = doc.to<JsonObject>();
|
||||
rootShower[TOPIC_SHOWER_TIMER] = EMSESP_Settings.shower_timer ? "1" : "0";
|
||||
rootShower[TOPIC_SHOWER_ALERT] = EMSESP_Settings.shower_alert ? "1" : "0";
|
||||
|
||||
// only publish shower duration if there is a value
|
||||
char s[50] = {0};
|
||||
@@ -1486,8 +1486,8 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
|
||||
// check first for generic commands
|
||||
if (strcmp(topic, TOPIC_GENERIC_CMD) == 0) {
|
||||
// convert JSON and get the command
|
||||
StaticJsonDocument<100> doc;
|
||||
DeserializationError error = deserializeJson(doc, message); // Deserialize the JSON document
|
||||
StaticJsonDocument<MYESP_JSON_MAXSIZE_SMALL> doc;
|
||||
DeserializationError error = deserializeJson(doc, message); // Deserialize the JSON document
|
||||
if (error) {
|
||||
myDebug_P(PSTR("[MQTT] Invalid command from topic %s, payload %s, error %s"), topic, message, error.c_str());
|
||||
return;
|
||||
@@ -1505,8 +1505,8 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
|
||||
|
||||
// check for shower commands
|
||||
if (strcmp(topic, TOPIC_SHOWER_DATA) == 0) {
|
||||
StaticJsonDocument<100> doc;
|
||||
DeserializationError error = deserializeJson(doc, message); // Deserialize the JSON document
|
||||
StaticJsonDocument<MYESP_JSON_MAXSIZE_SMALL> doc;
|
||||
DeserializationError error = deserializeJson(doc, message); // Deserialize the JSON document
|
||||
if (error) {
|
||||
myDebug_P(PSTR("[MQTT] Invalid command from topic %s, payload %s, error %s"), topic, message, error.c_str());
|
||||
return;
|
||||
@@ -1532,8 +1532,8 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
|
||||
// check for boiler commands
|
||||
if (strcmp(topic, TOPIC_BOILER_CMD) == 0) {
|
||||
// convert JSON and get the command
|
||||
StaticJsonDocument<100> doc;
|
||||
DeserializationError error = deserializeJson(doc, message); // Deserialize the JSON document
|
||||
StaticJsonDocument<MYESP_JSON_MAXSIZE_SMALL> doc;
|
||||
DeserializationError error = deserializeJson(doc, message); // Deserialize the JSON document
|
||||
if (error) {
|
||||
myDebug_P(PSTR("[MQTT] Invalid command from topic %s, payload %s, error %s"), topic, message, error.c_str());
|
||||
return;
|
||||
@@ -1619,8 +1619,8 @@ void MQTTCallback(unsigned int type, const char * topic, const char * message) {
|
||||
// check for generic thermostat commands
|
||||
if (strcmp(topic, TOPIC_THERMOSTAT_CMD) == 0) {
|
||||
// convert JSON and get the command
|
||||
StaticJsonDocument<100> doc;
|
||||
DeserializationError error = deserializeJson(doc, message); // Deserialize the JSON document
|
||||
StaticJsonDocument<MYESP_JSON_MAXSIZE_SMALL> doc;
|
||||
DeserializationError error = deserializeJson(doc, message); // Deserialize the JSON document
|
||||
if (error) {
|
||||
myDebug_P(PSTR("[MQTT] Invalid command from topic %s, payload %s, error %s"), topic, message, error.c_str());
|
||||
return;
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define APP_VERSION "1.9.4b21"
|
||||
#define APP_VERSION "1.9.4b22"
|
||||
|
||||
Reference in New Issue
Block a user