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

派派~ 发表于 2021-6-3 20:26

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

如题,找了好久找不出问题,不知道哪里写错了。。。
下面是部分错误:

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) ':

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 '

E:\��Ƭ�����\Arduino\ibraries\ArduinoJson\src/ArduinoJson/Variant/VariantRef.hpp:150:18:   required from 'ArduinoJson6180_00000::VariantRef::operator T() const '

E:\��Ƭ�����\Arduino\libraries\libraries\ArduinoJson\src/ArduinoJson/Object/MemberProxy.hpp:85:30:   required from 'ArduinoJson6180_00000::MemberProxy<TParent, TStringRef>::operator T() const '

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&) ':

E:\��Ƭ�����\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/ConverterImpl.hpp:24:32:   required from 'static T ArduinoJson6180_00000::Converter<T, Enable>::fromJson(ArduinoJson6180_00000::VariantConstRef) '

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 '

E:\��Ƭ�����\Arduino\libraries\ArduinoJson\src/ArduinoJson/Variant/VariantRef.hpp:150:18:   required from 'ArduinoJson6180_00000::VariantRef::operator T() const '

E:\��Ƭ�����\Arduino\libraries\ArduinoJson\src/ArduinoJson/Object/MemberProxy.hpp:85:30:   required from 'ArduinoJson6180_00000::MemberProxy<TParent, TStringRef>::operator T() const '

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();
}

奈何col 发表于 2021-6-3 22:18

blinker lib中已经自带了arduino Json,使用自带的即可

派派~ 发表于 2021-6-3 23:49

好的,谢谢大佬!
页: [1]
查看完整版本: 对Blinker获取的天气信息进行Json字符串解析后开发板编译错误