问题描述
我目前正在尝试将我的 Sparkfun ESP8266 Thing 连接到我的 Azure IoT 中心.我已成功设置我的集线器,并且正在遵循有关如何将 Thing 连接到我的 Azure IoT 集线器的教程:https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-sparkfun-esp8266-thing-dev-get-started
I am currently trying to connect my Sparkfun ESP8266 Thing to my Azure IoT Hub. I have successfully set up my hub, and am following this tutorial on how to connect the Thing to my Azure IoT Hub: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-sparkfun-esp8266-thing-dev-get-started
不幸的是,我不断收到错误消息:
Unfortunately I keep getting the error:
'StaticJsonBuffer' 未在此范围内声明
'StaticJsonBuffer' was not declared in this scope
Arduino:1.8.5(Windows 10),开发板:SparkFun ESP8266 Thing,80 MHz,512K(无 SPIFFS),v2 低内存,禁用,无,仅 Sketch,115200"
Arduino: 1.8.5 (Windows 10), Board: "SparkFun ESP8266 Thing, 80 MHz, 512K (no SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 115200"
构建选项改变,重建所有C:\Users\L.FULL\Documents\Arduino\iot-hub-SparkFun-ThingDev-client-app\app\message.ino:在函数'bool readMessage(int, char*)'中:
Build options changed, rebuilding allC:\Users\L.FULL\Documents\Arduino\iot-hub-SparkFun-ThingDev-client-app\app\message.ino: In function 'bool readMessage(int, char*)':
消息:46:错误:'StaticJsonBuffer' 未在此范围内声明
message:46: error: 'StaticJsonBuffer' was not declared in this scope
StaticJsonBuffer<MESSAGE_MAX_LEN> jsonBuffer;
^
C:\Users\L.FULL\Documents\Arduino\iot-hub-SparkFun-ThingDev-client-app\app\message.ino:46:5:注意:建议的替代方案:
C:\Users\L.FULL\Documents\Arduino\iot-hub-SparkFun-ThingDev-client-app\app\message.ino:46:5: note: suggested alternative:
在 C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson/StaticJsonDocument.hpp:8:0 包含的文件中,
In file included from C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson/StaticJsonDocument.hpp:8:0,
from C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson.hpp:10,
from C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson.h:9,
from C:\Users\L.FULL\Documents\Arduino\iot-hub-SparkFun-ThingDev-client-app\app\message.ino:2:
C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson/Memory/StaticJsonBuffer.hpp:110:7:注意:'ArduinoJson::Internals::StaticJsonBuffer'
C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson/Memory/StaticJsonBuffer.hpp:110:7: note: 'ArduinoJson::Internals::StaticJsonBuffer'
class StaticJsonBuffer : public Internals::StaticJsonBufferBase {
class StaticJsonBuffer : public Internals::StaticJsonBufferBase {
^
消息:46:错误:'jsonBuffer' 未在此范围内声明
message:46: error: 'jsonBuffer' was not declared in this scope
StaticJsonBuffer<MESSAGE_MAX_LEN> jsonBuffer;
^
消息:74:错误:类 ArduinoJson::JsonObject"没有名为printTo"的成员
message:74: error: 'class ArduinoJson::JsonObject' has no member named 'printTo'
root.printTo(payload, MESSAGE_MAX_LEN);
^
C:\Users\L.FULL\Documents\Arduino\iot-hub-SparkFun-ThingDev-client-app\app\message.ino:在函数'void parseTwinMessage(char*)'中:
C:\Users\L.FULL\Documents\Arduino\iot-hub-SparkFun-ThingDev-client-app\app\message.ino: In function 'void parseTwinMessage(char*)':
消息:80:错误:'StaticJsonBuffer' 未在此范围内声明
message:80: error: 'StaticJsonBuffer' was not declared in this scope
StaticJsonBuffer<MESSAGE_MAX_LEN> jsonBuffer;
^
C:\Users\L.FULL\Documents\Arduino\iot-hub-SparkFun-ThingDev-client-app\app\message.ino:80:5:注意:建议的替代方案:
C:\Users\L.FULL\Documents\Arduino\iot-hub-SparkFun-ThingDev-client-app\app\message.ino:80:5: note: suggested alternative:
在 C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson/StaticJsonDocument.hpp:8:0 包含的文件中,
In file included from C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson/StaticJsonDocument.hpp:8:0,
from C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson.hpp:10,
from C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson.h:9,
from C:\Users\L.FULL\Documents\Arduino\iot-hub-SparkFun-ThingDev-client-app\app\message.ino:2:
C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson/Memory/StaticJsonBuffer.hpp:110:7:注意:'ArduinoJson::Internals::StaticJsonBuffer'
C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson/Memory/StaticJsonBuffer.hpp:110:7: note: 'ArduinoJson::Internals::StaticJsonBuffer'
class StaticJsonBuffer : public Internals::StaticJsonBufferBase {
class StaticJsonBuffer : public Internals::StaticJsonBufferBase {
^
消息:80:错误:'jsonBuffer' 未在此范围内声明
message:80: error: 'jsonBuffer' was not declared in this scope
StaticJsonBuffer<MESSAGE_MAX_LEN> jsonBuffer;
^
消息:82:错误:'class ArduinoJson::JsonObject' 没有名为 'success' 的成员
message:82: error: 'class ArduinoJson::JsonObject' has no member named 'success'
if (!root.success())
^
消息:88:错误:ArduinoJson::Internals::enable_if >::type"没有名为success"的成员
message:88: error: 'ArduinoJson::Internals::enable_if >::type' has no member named 'success'
if (root["desired"]["interval"].success())
^
退出状态 1'StaticJsonBuffer' 未在此范围内声明
exit status 1'StaticJsonBuffer' was not declared in this scope
此报告将包含更多信息在编译期间显示详细输出"在文件 -> 首选项中启用的选项.
This report would have more information with"Show verbose output during compilation"option enabled in File -> Preferences.
我已将 DEVICE_ID 从SparkFun ESP8266 Thing Dev"更改为SparkFun ESP8266 Thing",并使用模拟数据.
I have changed the DEVICE_ID from "SparkFun ESP8266 Thing Dev" to "SparkFun ESP8266 Thing", and am using simulated data.
对此的任何帮助将不胜感激!
Any help with this would be much appreciated!
推荐答案
此错误的原因是您安装的 ArduinoJson 版本 >= 6.将安装默认版本 6.2.3-beta 但从版本 6和更高的 JsonBuffer 替换为 JsonDocument.它也在错误消息中指出:
The reason for this error is that you install the ArduinoJson version >= 6. Default version 6.2.3-beta will be installed but from version 6 and higher JsonBuffer is replaced with JsonDocument. It is also indicate in the error message:
C:\Users\L.FULL\Documents\Arduino\iot-hub-SparkFun-ThingDev-client-app\app\message.ino:46:5:注意:建议的替代方案:
在包含的文件中C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson/StaticJsonDocument.hpp:8:0
In file included from C:\Users\L.FULL\Documents\Arduino\libraries\arduino_172002\src/ArduinoJson/StaticJsonDocument.hpp:8:0
要解决此问题,您可以回滚到以前的版本.5.13.2 版对我有用.
To solve this issue you can roll back to the previous version. Version 5.13.2 works for me.
参考 关于 ArduinoJson 存储库的问题 和 关于 iot-hub-feather-huzzah-client-app 存储库的问题.
这篇关于将 Sparkfun ESP8266 Thing 连接到 Azure IoT 中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!