gpt4 book ai didi

c++ - StaticJsonBuffer' was not declared in this scope, using Feather Huzzah (ESP8266) board using MSFT IOT Azure 教程

转载 作者:行者123 更新时间:2023-11-28 01:30:03 28 4
gpt4 key购买 nike

全部,

我正在使用我的 Adafruit Feather Huzzuh 进行一个项目。

我正在学习以下教程。

https://learn.microsoft.com/nl-nl/azure/iot-hub/iot-hub-arduino-huzzah-esp8266-get-started

顺便还在用Arduino IDE。

电路板和 DHT 传感器之前工作正常。

我相信所有包都已安装。

我使用的开源代码来自:

https://github.com/Azure-Samples/iot-hub-feather-huzzah-client-app.git

当我尝试编译主 app.ino 文件 ( https://github.com/Azure-Samples/iot-hub-feather-huzzah-client-app/blob/master/app/app.ino ) 时遇到编译器错误。

错误是:

Arduino: 1.8.5 (Windows 10), Board: "Adafruit Feather HUZZAH ESP8266, 80 MHz, Flash, 4M (3M SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

C:\Users\edwin\Dropbox\Projects\Arduino project\DHT_online_azure\app\message.ino: In function 'bool readMessage(int, char*)':

message:46: error: 'StaticJsonBuffer' was not declared in this scope

 StaticJsonBuffer<MESSAGE_MAX_LEN> jsonBuffer;

^

C:\Users\edwin\Dropbox\Projects\Arduino project\DHT_online_azure\app\message.ino:46:5: note: suggested alternative:

In file included from C:\Users\edwin\Dropbox\Projects\Arduino project\libraries\arduino_163901\src/ArduinoJson/StaticJsonDocument.hpp:8:0,

             from C:\Users\edwin\Dropbox\Projects\Arduino project\libraries\arduino_163901\src/ArduinoJson.hpp:10,

from C:\Users\edwin\Dropbox\Projects\Arduino project\libraries\arduino_163901\src/ArduinoJson.h:9,

from C:\Users\edwin\Dropbox\Projects\Arduino project\DHT_online_azure\app\message.ino:2:

C:\Users\edwin\Dropbox\Projects\Arduino project\libraries\arduino_163901\src/ArduinoJson/Memory/StaticJsonBuffer.hpp:110:7: note: 'ArduinoJson::Internals::StaticJsonBuffer'

class StaticJsonBuffer : public Internals::StaticJsonBufferBase {

   ^

message:46: error: 'jsonBuffer' was not declared in this scope

 StaticJsonBuffer<MESSAGE_MAX_LEN> jsonBuffer;

^

message:74: error: 'class ArduinoJson::JsonObject' has no member named 'printTo'

 root.printTo(payload, MESSAGE_MAX_LEN);

^

C:\Users\edwin\Dropbox\Projects\Arduino project\DHT_online_azure\app\message.ino: In function 'void parseTwinMessage(char*)':

message:80: error: 'StaticJsonBuffer' was not declared in this scope

 StaticJsonBuffer<MESSAGE_MAX_LEN> jsonBuffer;

^

C:\Users\edwin\Dropbox\Projects\Arduino project\DHT_online_azure\app\message.ino:80:5: note: suggested alternative:

In file included from C:\Users\edwin\Dropbox\Projects\Arduino project\libraries\arduino_163901\src/ArduinoJson/StaticJsonDocument.hpp:8:0,

             from C:\Users\edwin\Dropbox\Projects\Arduino project\libraries\arduino_163901\src/ArduinoJson.hpp:10,

from C:\Users\edwin\Dropbox\Projects\Arduino project\libraries\arduino_163901\src/ArduinoJson.h:9,

from C:\Users\edwin\Dropbox\Projects\Arduino project\DHT_online_azure\app\message.ino:2:

C:\Users\edwin\Dropbox\Projects\Arduino project\libraries\arduino_163901\src/ArduinoJson/Memory/StaticJsonBuffer.hpp:110:7: note: 'ArduinoJson::Internals::StaticJsonBuffer'

class StaticJsonBuffer : public Internals::StaticJsonBufferBase {

   ^

message:80: error: 'jsonBuffer' was not declared in this scope

 StaticJsonBuffer<MESSAGE_MAX_LEN> jsonBuffer;

^

message:82: error: 'class ArduinoJson::JsonObject' has no member named 'success'

 if (!root.success())

^

message:88: error: 'ArduinoJson::Internals::enable_if >::type' has no member named 'success'

 if (root["desired"]["interval"].success())

^

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.

ArduinoJson.h 文件包含在 message.ino 文件中。

MSFT 提供的开源代码是否损坏?

有人想解决这个问题吗?

编辑 2018-08-23

Rita Han 的回答 - MSFT 有效(将 json 库回滚到版本 5.x),我现在可以看到它连接到我的接入点的设备。我遇到了以下问题:

connected with NETGEAR33, channel 10 dhcp client start... ip:192.168.1.29,mask:255.255.255.0,gw:192.168.1.1 Connected to wifi NETGEAR33. Fetched NTP epoch time is: 28821. deviceId is not found Failed on IoTHubClient_CreateFromConnectionString.

我从设置下的 iothubowner 菜单中复制了“连接字符串 - 主键”:共享访问策略。

它以某种方式不接受我的共享访问 key 。我会谷歌一下来尝试解决这个问题。感谢您的帮助。

编辑 2018-08-03也解决了!!我在串行监视器中看到测量值。需要找到一种方法将其从 DH22 更改为 DH11...但我自己应该能够弄清楚。在我的 Adafruit IO 尝试中也看到并解决了这个问题。

最佳答案

此错误的原因是您安装的 ArduinoJson 版本 >= 6。将安装默认版本 6.2.3-beta,但从版本 6 和更高版本开始,JsonBuffer 被 JsonDocument 替换。它也在错误消息中指出:

C:\Users\edwin\Dropbox\Projects\Arduino project\DHT_online_azure\app\message.ino:80:5: note: suggested alternative:

In file included from C:\Users\edwin\Dropbox\Projects\Arduino project\libraries\arduino_163901\src/ArduinoJson/StaticJsonDocument.hpp:8:0,

要解决此问题,您可以回滚到以前的版本。版本 5.13.2 适合我。

关于c++ - StaticJsonBuffer' was not declared in this scope, using Feather Huzzah (ESP8266) board using MSFT IOT Azure 教程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51906646/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com