为啥我在连接 Firebase 时会在 Arduino 中遇到这个问题?

Posted

技术标签:

【中文标题】为啥我在连接 Firebase 时会在 Arduino 中遇到这个问题?【英文标题】:Why am I facing this Problem in Arduino when connecting Firebase?为什么我在连接 Firebase 时会在 Arduino 中遇到这个问题? 【发布时间】:2021-08-09 23:14:58 【问题描述】:
Arduino: 1.8.13 (Windows 10), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (balanced), Use pgm_read macros for IRAM/PROGMEM, 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200"

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseObject.cpp: In member function 'bool FirebaseObject::isNullString(const String&) const':

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseObject.cpp:71:57: warning: 'const char* ArduinoJson::Internals::JsonVariantCasts<TImpl>::asString() const [with TImpl = ArduinoJson::JsonVariant]' is deprecated: use as<char*>() instead [-Wdeprecated-declarations]

   71 |   return variant.is<const char *>() && variant.asString() == NULL;

      |                                                         ^

In file included from c:\users\jordan\documents\arduino\libraries\arduinojson\src\arduinojson\JsonVariantBase.hpp:7,

                 from c:\users\jordan\documents\arduino\libraries\arduinojson\src\arduinojson\JsonVariant.hpp:13,

                 from c:\users\jordan\documents\arduino\libraries\arduinojson\src\arduinojson\jsonbuffer.hpp:12,

                 from C:\Users\Jordan\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Deserialization/JsonParser.hpp:7,

                 from C:\Users\Jordan\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/JsonBufferBase.hpp:7,

                 from C:\Users\Jordan\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/DynamicJsonBuffer.hpp:7,

                 from C:\Users\Jordan\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.hpp:9,

                 from C:\Users\Jordan\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.h:9,

                 from C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseObject.h:24,

                 from C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseObject.cpp:17:

c:\users\jordan\documents\arduino\libraries\arduinojson\src\arduinojson\JsonVariantCasts.hpp:28:28: note: declared here

   28 |   FORCE_INLINE const char *asString() const 

      |                            ^~~~~~~~

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseObject.cpp: In member function 'ArduinoJson::JsonVariant FirebaseObject::getJsonVariant(const String&) const':

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseObject.cpp:91:26: warning: 'ArduinoJson::JsonObject& ArduinoJson::Internals::JsonVariantCasts<TImpl>::asObject() const [with TImpl = ArduinoJson::JsonVariant]' is deprecated: use as<JsonObject>() instead [-Wdeprecated-declarations]

   91 |     json = json.asObject().get<JsonVariant>(start);

      |                          ^

In file included from c:\users\jordan\documents\arduino\libraries\arduinojson\src\arduinojson\JsonVariantBase.hpp:7,

                 from c:\users\jordan\documents\arduino\libraries\arduinojson\src\arduinojson\JsonVariant.hpp:13,

                 from c:\users\jordan\documents\arduino\libraries\arduinojson\src\arduinojson\jsonbuffer.hpp:12,

                 from C:\Users\Jordan\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/Deserialization/JsonParser.hpp:7,

                 from C:\Users\Jordan\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/JsonBufferBase.hpp:7,

                 from C:\Users\Jordan\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson/DynamicJsonBuffer.hpp:7,

                 from C:\Users\Jordan\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.hpp:9,

                 from C:\Users\Jordan\Documents\Arduino\libraries\ArduinoJson\src/ArduinoJson.h:9,

                 from C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseObject.h:24,

                 from C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseObject.cpp:17:

c:\users\jordan\documents\arduino\libraries\arduinojson\src\arduinojson\JsonVariantCasts.hpp:23:28: note: declared here

   23 |   FORCE_INLINE JsonObject &asObject() const 

      |                            ^~~~~~~~

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\Firebase.cpp: In member function 'int FirebaseRequest::sendRequest(const string&, const string&, char*, const string&, const string&)':

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\Firebase.cpp:78:1: warning: no return statement in function returning non-void [-Wreturn-type]

   78 | 

      | ^

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\Firebase.cpp: In member function 'void FirebaseStream::startStreaming(const string&, const string&, const string&)':

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\Firebase.cpp:91:16: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

   91 |   analyzeError("STREAM", status, path_with_auth);

      |                ^~~~~~~~

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp: In member function 'String FirebaseArduino::push(const String&, const ArduinoJson::JsonVariant&)':

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp:65:54: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

   65 |   int status = req_.get()->sendRequest(host_, auth_, "POST", path.c_str(), buf);

      |                                                      ^~~~~~

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp: In member function 'void FirebaseArduino::set(const String&, const ArduinoJson::JsonVariant&)':

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp:94:41: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

   94 |   req_.get()->sendRequest(host_, auth_, "PUT", path.c_str(), buf);

      |                                         ^~~~~

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp: In member function 'void FirebaseArduino::getRequest(const String&)':

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp:101:41: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

  101 |   req_.get()->sendRequest(host_, auth_, "GET", path.c_str());

      |                                         ^~~~~

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp: In member function 'virtual void FirebaseArduino::remove(const String&)':

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp:147:41: warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

  147 |   req_.get()->sendRequest(host_, auth_, "DELETE", path.c_str());

      |                                         ^~~~~~~~

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp: In member function 'virtual const String& FirebaseArduino::error()':

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseArduino.cpp:201:32: warning: returning reference to temporary [-Wreturn-local-addr]

  201 |   return error_.message().c_str();

      |          ~~~~~~~~~~~~~~~~~~~~~~^~

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient_Esp8266.cpp: In member function 'virtual void FirebaseHttpClientEsp8266::begin(const string&)':

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient_Esp8266.cpp:47:50: error: no matching function for call to 'begin(const char*, const char [60])'

   47 |     http_.begin(url.c_str(), kFirebaseFingerprint);

      |                                                  ^

In file included from C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient_Esp8266.cpp:9:

C:\Users\Jordan\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.0\libraries\ESP8266HTTPClient\src/ESP8266HTTPClient.h:166:10: note: candidate: 'bool HTTPClient::begin(String, uint16_t, String)' (near match)

  166 |     bool begin(String host, uint16_t port, String uri = "/")  __attribute__ ((error("obsolete API, use ::begin(WiFiClient, host, port, uri)")));

      |          ^~~~~

C:\Users\Jordan\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.0\libraries\ESP8266HTTPClient\src/ESP8266HTTPClient.h:166:10: note:   conversion of argument 2 would be ill-formed:

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient_Esp8266.cpp:47:30: error: invalid conversion from 'const char*' to 'uint16_t' aka 'short unsigned int' [-fpermissive]

   47 |     http_.begin(url.c_str(), kFirebaseFingerprint);

      |                              ^~~~~~~~~~~~~~~~~~~~

      |                              |

      |                              const char*

In file included from C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient_Esp8266.cpp:9:

C:\Users\Jordan\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.0\libraries\ESP8266HTTPClient\src/ESP8266HTTPClient.h:167:10: note: candidate: 'bool HTTPClient::begin(String, const uint8_t*)' (near match)

  167 |     bool begin(String url, const uint8_t httpsFingerprint[20])  __attribute__ ((error("obsolete API, use ::begin(WiFiClientSecure, ...)")));

      |          ^~~~~

C:\Users\Jordan\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.0\libraries\ESP8266HTTPClient\src/ESP8266HTTPClient.h:167:10: note:   conversion of argument 2 would be ill-formed:

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient_Esp8266.cpp:47:30: error: invalid conversion from 'const char*' to 'const uint8_t*' aka 'const unsigned char*' [-fpermissive]

   47 |     http_.begin(url.c_str(), kFirebaseFingerprint);

      |                              ^~~~~~~~~~~~~~~~~~~~

      |                              |

      |                              const char*

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient_Esp8266.cpp: In member function 'virtual void FirebaseHttpClientEsp8266::begin(const string&, const string&)':

C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient_Esp8266.cpp:51:60: error: invalid conversion from 'const char*' to 'const uint8_t*' aka 'const unsigned char*' [-fpermissive]

   51 |     http_.begin(host.c_str(), kFirebasePort, path.c_str(), kFirebaseFingerprint);

      |                                                            ^~~~~~~~~~~~~~~~~~~~

      |                                                            |

      |                                                            const char*

In file included from C:\Users\Jordan\Documents\Arduino\libraries\firebase-arduino-master\src\FirebaseHttpClient_Esp8266.cpp:9:

C:\Users\Jordan\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\3.0.0\libraries\ESP8266HTTPClient\src/ESP8266HTTPClient.h:168:70: note:   initializing argument 4 of 'bool HTTPClient::begin(String, uint16_t, String, const uint8_t*)'

  168 |     bool begin(String host, uint16_t port, String uri, const uint8_t httpsFingerprint[20])  __attribute__ ((error("obsolete API, use ::begin(WiFiClientSecure, ...)")));

      |                                                        ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~

exit status 1

Error compiling for board NodeMCU 1.0 (ESP-12E Module).



This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

【问题讨论】:

【参考方案1】:

当我遇到同样的问题时,我在 board manager 上回滚到 2.7.4,这导致它编译没有问题。我猜在 FireBase 库之前更新了板软件。我在this page 上找到了这个解决方案。

【讨论】:

关于您使用的链接,最好链接到存储库中的实际问题,而不是参与摘要,其中可能不包含有关此问题的信息在未来的某个时间点(即当该用户的其他更新的参与将其从该列表中推出时)。【参考方案2】:

我在将代码从旧笔记本电脑转移到新笔记本电脑时发现了错误。

你猜怎么着?我最近在新笔记本电脑中下载的 Arduino 库版本与旧笔记本电脑中的版本不匹配! 这就是弹出错误消息的原因。

【讨论】:

【参考方案3】:

使用 platformio,更改 platformio.ini(为我工作),用于最新的 2.x 版本:

平台 = espressif8266@^2

Solution from this page

【讨论】:

您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center。

以上是关于为啥我在连接 Firebase 时会在 Arduino 中遇到这个问题?的主要内容,如果未能解决你的问题,请参考以下文章

为啥我的 UIView 在滚动时会在 UIScrollView 内移动?

为啥我在尝试访问 spark master webUI 时会重置连接?

为啥调用firebase函数时会出现FCM错误

为啥下一个 js 在我构建时会在第一次加载时加载所有页面

为啥我在尝试从 Angular 2 应用程序连接和查询 Firebase 数据库时收到此错误消息?

为啥在使用 kotlin 将数据添加到 firebase 实时数据库时会得到重复值?