本文介绍了将Sparkfun ESP8266事物连接到Azure IoT中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前正在尝试将Sparkfun ESP8266 Thing连接到我的Azure IoT中心.我已经成功设置了集线器,并正在按照有关如何将Thing连接到我的Azure IoT中心的教程进行操作: https://docs.microsoft.com/zh-CN/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较低内存,禁用,无,仅素描,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'

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'

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:错误:类ArduinoJson :: JsonObject"没有名为成功"的成员

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 \ 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事物连接到Azure IoT中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 06:55