【发布时间】:2019-04-18 23:28:03
【问题描述】:
我解决了这个问题。 我在库 Firebase.cpp => void FirebaseCall::analyzeError 中发现了错误 您应该更改此代码 之前
void FirebaseCall::analyzeError(char* method, int status, const std::string& path_with_auth) {
if (status != 200) {
error_ = FirebaseError(status,
std::string(method) + " " + path_with_auth +
": " + http_->errorToString(status));
}
}
之后
void FirebaseCall::analyzeError(char* method, int status, const std::string& path_with_auth) {
if (status != 200) {
error_ = FirebaseError(status,
std::string(method) + " " + path_with_auth +
": " + http_->errorToString(status));
} else {
error_ = FirebaseError();
}
}
一旦互联网连接断开,它就会重新连接。当我再次连接时,firebase 没有连接。因此,当问题再次连接时,它不会再次连接到 firebasis。我该怎么做?
boolean WiFiReturns() {
if (WiFi.localIP() == IPAddress(0, 0, 0, 0))
return 0;
switch (WiFi.status()) {
case WL_NO_SHIELD: return 0;
case WL_IDLE_STATUS: return 0;
case WL_NO_SSID_AVAIL: return 0;
case WL_SCAN_COMPLETED: return 1;
case WL_CONNECTED: return 1;
case WL_CONNECT_FAILED: return 0;
case WL_CONNECTION_LOST: return 0;
case WL_DISCONNECTED: return 0;
default: return 0;
}
}
void firebasereconnect() {
Serial.println("Trying to reconnect");
Firebase.begin(firebaseURl, authCode);
}
void loop() {
if (!WiFiReturns()) {
WiFi.isConnected();
digitalWrite(WIFILED, HIGH);
firebasereconnect();
} else {
digitalWrite(WIFILED, LOW);
}
}
【问题讨论】: