Browse Source

Free jsonBuffer after printing

fastled^2
Maxim Prokhorov 6 years ago
parent
commit
3ca1692827
5 changed files with 12 additions and 0 deletions
  1. +1
    -0
      code/espurna/api.ino
  2. +6
    -0
      code/espurna/homeassistant.ino
  3. +2
    -0
      code/espurna/mqtt.ino
  4. +1
    -0
      code/espurna/web.ino
  5. +2
    -0
      code/espurna/ws.ino

+ 1
- 0
code/espurna/api.ino View File

@ -134,6 +134,7 @@ void _onAPIs(AsyncWebServerRequest *request) {
root[_apis[i].key] = String(buffer);
}
root.printTo(output);
jsonBuffer.clear();
request->send(200, "application/json", output);
} else {


+ 6
- 0
code/espurna/homeassistant.ino View File

@ -44,6 +44,7 @@ void _haSendMagnitudes() {
JsonObject& config = jsonBuffer.createObject();
_haSendMagnitude(i, config);
config.printTo(output);
jsonBuffer.clear();
}
mqttSendRaw(topic.c_str(), output.c_str());
@ -123,6 +124,7 @@ void _haSendSwitches() {
JsonObject& config = jsonBuffer.createObject();
_haSendSwitch(i, config);
config.printTo(output);
jsonBuffer.clear();
}
mqttSendRaw(topic.c_str(), output.c_str());
@ -163,6 +165,8 @@ String _haGetConfig() {
}
output += "\n";
jsonBuffer.clear();
}
#if SENSOR_SUPPORT
@ -186,6 +190,8 @@ String _haGetConfig() {
}
output += "\n";
jsonBuffer.clear();
}
#endif


+ 2
- 0
code/espurna/mqtt.ino View File

@ -613,6 +613,8 @@ void mqttFlush() {
// Send
String output;
root.printTo(output);
jsonBuffer.clear();
mqttSendRaw(_mqtt_topic_json.c_str(), output.c_str(), false);
// Clear queue


+ 1
- 0
code/espurna/web.ino View File

@ -55,6 +55,7 @@ void _onGetConfig(AsyncWebServerRequest *request) {
root["version"] = APP_VERSION;
settingsGetJson(root);
root.prettyPrintTo(*response);
jsonBuffer.clear();
char buffer[100];
snprintf_P(buffer, sizeof(buffer), PSTR("attachment; filename=\"%s-backup.json\""), (char *) getSetting("hostname").c_str());


+ 2
- 0
code/espurna/ws.ino View File

@ -440,6 +440,7 @@ void wsSend(ws_on_send_callback_f callback) {
callback(root);
String output;
root.printTo(output);
jsonBuffer.clear();
_ws.textAll((char *) output.c_str());
}
}
@ -464,6 +465,7 @@ void wsSend(uint32_t client_id, ws_on_send_callback_f callback) {
callback(root);
String output;
root.printTo(output);
jsonBuffer.clear();
_ws.text(client_id, (char *) output.c_str());
}


Loading…
Cancel
Save