bruhautomation / ESP-MQTT-JSON-Digital-LEDs

(OBSOLETE) ESP8266 MQTT JSON Digital LEDs for Home Assistant
https://youtu.be/9KI36GTgwuQ
Apache License 2.0
511 stars 268 forks source link

Compiling error 'StaticJsonBuffer' was not declared in this scope #103

Open jccarey5 opened 5 years ago

jccarey5 commented 5 years ago

When compiling i get an error:

exit status 1 'StaticJsonBuffer' was not declared in this scope

This is the location of the error /** START SEND STATE*****/ void sendState() { StaticJsonBuffer jsonBuffer;

JsonObject& root = jsonBuffer.createObject();

root["state"] = (stateOn) ? on_cmd : off_cmd; JsonObject& color = root.createNestedObject("color"); color["r"] = red; color["g"] = green; color["b"] = blue;

root["brightness"] = brightness; root["effect"] = effectString.c_str();

char buffer[root.measureLength() + 1]; root.printTo(buffer, sizeof(buffer));

client.publish(light_state_topic, buffer, true); }

Is there a fix for this?

Joeboyc2 commented 5 years ago

Use the older version of arduinojson, v5x

On Thu, 22 Nov 2018, 03:42 jccarey5 <notifications@github.com wrote:

When compiling i get an error:

exit status 1 'StaticJsonBuffer' was not declared in this scope

This is the location of the error /** START SEND STATE*****/ void sendState() { StaticJsonBuffer jsonBuffer;

JsonObject& root = jsonBuffer.createObject();

root["state"] = (stateOn) ? on_cmd : off_cmd; JsonObject& color = root.createNestedObject("color"); color["r"] = red; color["g"] = green; color["b"] = blue;

root["brightness"] = brightness; root["effect"] = effectString.c_str();

char buffer[root.measureLength() + 1]; root.printTo(buffer, sizeof(buffer));

client.publish(light_state_topic, buffer, true); }

Is there a fix for this?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/bruhautomation/ESP-MQTT-JSON-Digital-LEDs/issues/103, or mute the thread https://github.com/notifications/unsubscribe-auth/AH0nLmSYeBEZtwUyFQEAJJT82ufJJzkxks5uxh0kgaJpZM4YunOZ .

andilge commented 4 years ago

according to ArduinoJson, Migrating from version 5 to 6 on https://arduinojson.org/v6/doc/upgrade/

StaticJsonBuffer has to be changed to StaticJsonDocument and DynamicJsonBuffer to DynamicJsonDocument

please go to the scetch in Arduin ID, find cJsonBuffer and replace cJsonDocument

It'll find and replace 2 codes. Save and pre compile to test. Worked fine for me and now I'm at the newest ArduinoJson lib version