Correct usage of measureJson()
- Fix https://github.com/toblum/McLighting/issues/206
This commit is contained in:
debsahu 2018-07-10 08:53:01 -04:00
parent a84bd04001
commit 6fc7a3a02e
3 changed files with 7 additions and 4 deletions

View file

@ -953,7 +953,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
for (uint8_t i = 0; i < strip.getModeCount(); i++) { for (uint8_t i = 0; i < strip.getModeCount(); i++) {
effect_list.add(strip.getModeName(i)); effect_list.add(strip.getModeName(i));
} }
char buffer[json.measureJson() + 1]; char buffer[measureJson(json) + 1];
serializeJson(json, buffer, sizeof(buffer)); serializeJson(json, buffer, sizeof(buffer));
mqtt_client.publish(String("homeassistant/light/" + String(HOSTNAME) + "/config").c_str(), buffer, true); mqtt_client.publish(String("homeassistant/light/" + String(HOSTNAME) + "/config").c_str(), buffer, true);
#endif #endif
@ -1033,7 +1033,7 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t * payload, size_t lenght
for (uint8_t i = 0; i < strip.getModeCount(); i++) { for (uint8_t i = 0; i < strip.getModeCount(); i++) {
effect_list.add(strip.getModeName(i)); effect_list.add(strip.getModeName(i));
} }
char buffer[json.measureJson() + 1]; char buffer[measureJson(json) + 1];
serializeJson(json, buffer, sizeof(buffer)); serializeJson(json, buffer, sizeof(buffer));
DBG_OUTPUT_PORT.println(buffer); DBG_OUTPUT_PORT.println(buffer);
amqttClient.publish(String("homeassistant/light/" + String(HOSTNAME) + "/config").c_str(), qospub, true, buffer); amqttClient.publish(String("homeassistant/light/" + String(HOSTNAME) + "/config").c_str(), qospub, true, buffer);

View file

@ -1 +1 @@
#define SKETCH_VERSION "2.1.3" #define SKETCH_VERSION "2.1.4"

View file

@ -12,6 +12,9 @@
* - Added example for static IP * - Added example for static IP
* - Added more internal variables to /esp_status * - Added more internal variables to /esp_status
* *
* 5 Jul 2018 c 2.1.3 * 5 Jul 2018 v 2.1.3
* - Fixes for ArduinoJson 6.1.0-beta * - Fixes for ArduinoJson 6.1.0-beta
*
* 10 Jul 2018 v 2.1.4
* - Fixes measureJson() as pointed in #206
*/ */