对Blinker获取的天气信息进行Json字符串解析后开发板编译错误-Arduino中文社区 - Powered by Discuz!

Arduino中文社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1484|回复: 2

[已解答] 对Blinker获取的天气信息进行Json字符串解析后开发板编译错误

[复制链接]
发表于 2021-6-3 20:26 | 显示全部楼层 |阅读模式
如题,找了好久找不出问题,不知道哪里写错了。。。
下面是部分错误:

E:\��Ƭ�����\Arduino\libraries\ArduinoJson\src/ArduinoJson.hpp:71:30: error: 'NestingLimit' is already declared in this scope
using ARDUINOJSON_NAMESPACE::NestingLimit;
                              ^
In file included from E:\��Ƭ�����\Arduino\libraries\ArduinoJson\src/ArduinoJson.hpp:30:0,

                 from E:\��Ƭ�����\Arduino\libraries\ArduinoJson\src/ArduinoJson.h:9,

                 from C:\Users\Administrator\Desktop\weathertry\weathertry.ino:5:

E:\��Ƭ�����\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/ConverterImpl.hpp: In instantiation of 'static T ArduinoJson6180_00000::Converter<T, Enable>::fromJson(ArduinoJson6180_00000::VariantConstRef) [with T = ArduinoJson6111_00000::ObjectRef; Enable = void]':

E:\��Ƭ�����\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/VariantRef.hpp:107:40:   required from 'typename ArduinoJson6180_00000::enable_if<((! ArduinoJson6180_00000::is_same<T, char*>::value) && (! ArduinoJson6180_00000::is_same<T, char>::value)), T>::type ArduinoJson6180_00000::VariantRef::as() const [with T = ArduinoJson6111_00000::ObjectRef; typename ArduinoJson6180_00000::enable_if<((! ArduinoJson6180_00000::is_same<T, char*>::value) && (! ArduinoJson6180_00000::is_same<T, char>::value)), T>::type = ArduinoJson6111_00000::ObjectRef]'

E:\��Ƭ�����\Arduino\ibraries\ArduinoJson\src/ArduinoJson/Variant/VariantRef.hpp:150:18:   required from 'ArduinoJson6180_00000::VariantRef:perator T() const [with T = ArduinoJson6111_00000::ObjectRef]'

E:\��Ƭ�����\Arduino\libraries\libraries\ArduinoJson\src/ArduinoJson/Object/MemberProxy.hpp:85:30:   required from 'ArduinoJson6180_00000::MemberProxy<TParent, TStringRef>:perator T() const [with T = ArduinoJson6111_00000::ObjectRef; TObject = ArduinoJson6180_00000::JsonDocument&; TStringRef = const char*]'

C:\Users\Administrator\Desktop\weathertry\weathertry.ino:33:33:   required from here

E:\��Ƭ�����\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/ConverterImpl.hpp:24:32: error: no matching function for call to 'convertFromJson(ArduinoJson6180_00000::VariantConstRef&, ArduinoJson6111_00000::ObjectRef&)'

     convertFromJson(src, result);  // Error here? See https://arduinojson.org/v6/unsupported-as/
                                ^
E:\��Ƭ�����\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/ConverterImpl.hpp:24:32: note: candidate is:

E:\��Ƭ�����\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/ConverterImpl.hpp:147:62: note: template<class T> typename ArduinoJson6180_00000::enable_if<ArduinoJson6180_00000::IsWriteableString< <template-parameter-1-1> >::value>::type ArduinoJson6180_00000::convertFromJson(ArduinoJson6180_00000::VariantConstRef, T&)

inline typename enable_if<IsWriteableString<T>::value>::type convertFromJson(

                                                              ^

E:\��Ƭ�����\Arduinolibraries\ArduinoJson\src/ArduinoJson/Variant/ConverterImpl.hpp:147:62: note:   template argument deduction/substitution failed:

E:\��Ƭ�����\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/ConverterImpl.hpp: In substitution of 'template<class T> typename ArduinoJson6180_00000::enable_if<ArduinoJson6180_00000::IsWriteableString< <template-parameter-1-1> >::value>::type ArduinoJson6180_00000::convertFromJson(ArduinoJson6180_00000::VariantConstRef, T&) [with T = ArduinoJson6111_00000::ObjectRef]':

E:\��Ƭ�����\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/ConverterImpl.hpp:24:32:   required from 'static T ArduinoJson6180_00000::Converter<T, Enable>::fromJson(ArduinoJson6180_00000::VariantConstRef) [with T = ArduinoJson6111_00000::ObjectRef; Enable = void]'

E:\��Ƭ�����\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/VariantRef.hpp:107:40:   required from 'typename ArduinoJson6180_00000::enable_if<((! ArduinoJson6180_00000::is_same<T, char*>::value) && (! ArduinoJson6180_00000::is_same<T, char>::value)), T>::type ArduinoJson6180_00000::VariantRef::as() const [with T = ArduinoJson6111_00000::ObjectRef; typename ArduinoJson6180_00000::enable_if<((! ArduinoJson6180_00000::is_same<T, char*>::value) && (! ArduinoJson6180_00000::is_same<T, char>::value)), T>::type = ArduinoJson6111_00000::ObjectRef]'

E:\��Ƭ�����\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/VariantRef.hpp:150:18:   required from 'ArduinoJson6180_00000::VariantRef:perator T() const [with T = ArduinoJson6111_00000::ObjectRef]'

E:\��Ƭ�����\Arduino\libraries\ArduinoJson\src/ArduinoJson/Object/MemberProxy.hpp:85:30:   required from 'ArduinoJson6180_00000::MemberProxy<TParent, TStringRef>:perator T() const [with T = ArduinoJson6111_00000::ObjectRef; TObject = ArduinoJson6180_00000::JsonDocument&; TStringRef = const char*]'

C:\Users\Administrator\Desktop\weathertry\weathertry.ino:33:33:   required from here

E:\��Ƭ�����\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/ConverterImpl.hpp:147:62: error: no type named 'type' in 'struct ArduinoJson6180_00000::enable_if<false, void>'

使用 0.3.8  版本的库 Blinker
使用 1.0  版本的库 ESP8266WiFi
使用 1.2  版本的库 ESP8266mDNS
使用 1.2  版本的库 ESP8266HTTPClient
使用 1.0  版本的库 EEPROM
使用 1.0  版本的库 Ticke
使用 1.3  版本的库 ESP8266httpUpdate
使用 6.18.0  版本的库 ArduinoJson
使用 1.0  版本的库 Hash
exit status 1

为开发板 NodeMCU 1.0 (ESP-12E Module) 编译时出错。

下面是完整的程序:
#define BLINKER_WIFI
#define BLINKER_APCONFIG

#include <Blinker.h>
#include <ArduinoJson.h>

char auth[] = "xxxxxxxxxx";

/*-----ArduinoJson处理后的数据------*/
String B_city;//城市
String B_weather;//天气
String B_temp;//温度
String B_humi;//湿度
String B_wind;//风向
String B_power;//风力


void weatherData(const String & data)
{
    BLINKER_LOG("weather: ",data);
StaticJsonDocument<256> doc;

DeserializationError error = deserializeJson(doc, data);

if (error) {
Serial.print(F("deserializeJson() failed: "));
Serial.println(error.f_str());
return;
}

int message = doc["message"]; // 1000

JsonObject detail = doc["detail"];
const char* detail_city = detail["city"]; // "xx市"
const char* detail_province = detail["province"]; // "xx"
const char* detail_weather = detail["weather"]; // "阴"
const char* detail_temp = detail["temp"]; // "3x"
const char* detail_humi = detail["humi"]; // "x4"
const char* detail_wind = detail["wind"]; // "东"
const char* detail_power = detail["power"]; // "≤3"
const char* detail_updateTime = detail["updateTime"]; // "2021-06-03 xx:xx:xx"
/*----生成并处理出普通字符串-----*/
B_city = detail_city;
B_weather = detail_weather;
B_temp = detail_temp;
B_humi = detail_humi;
B_wind = detail_wind;
B_power = detail_power;
}

void dataRead(const String & data)
{
    BLINKER_LOG("Blinker readString: ", data);

    Blinker.vibrate();

    uint32_t BlinkerTime = millis();
    digitalWrite(LED_BUILTIN,!digitalRead(LED_BUILTIN));

    Blinker.print("millis", BlinkerTime);

    Blinker.weather();
    Serial.println(B_city);
    Blinker.delay(60000);
}

void setup()
{
    Serial.begin(115200);
    BLINKER_DEBUG.stream(Serial);

    pinMode(LED_BUILTIN, OUTPUT);
    digitalWrite(LED_BUILTIN, HIGH);

    Blinker.begin(auth);
    Blinker.attachData(dataRead);
}

void loop()
{
    Blinker.run();
}

发表于 2021-6-3 22:18 | 显示全部楼层
blinker lib中已经自带了arduino Json,使用自带的即可
 楼主| 发表于 2021-6-3 23:49 | 显示全部楼层
好的,谢谢大佬!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|Archiver|手机版|Arduino中文社区

GMT+8, 2024-11-28 12:44 , Processed in 0.161449 second(s), 15 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表