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

StaticJsonBuffer' was not declared in this scope, using Feather Huzzah (ESP8266) board using MSFT IOT Azure tutorial

全部,

我正在用我的 Adafruit Feather Huzzuh 做一个项目。

我正在学习以下教程。

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

顺便还在用ArduinoIDE

电路板和 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 菜单中复制了 "Connection string - primary key":共享访问策略。

它以某种方式不接受我的共享访问密钥。我会 google 尝试解决这个问题。感谢帮助。

编辑 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 适合我。