-
I use both FirebaseClient and ESP8266HTTPClient at the same time the checkUpdateAvailable() function does not work as expected. Here is the summary of the code: ...
void checkUpdateAvailable() {
WiFiClientSecure clientOTA;
// clientOTA.setInsecure();
String updateUrl = String(UPDATE_URL) + String(CURRENT_VERSION);
HTTPClient httpOTA;
if (httpOTA.begin(clientOTA, OTA_URL)) {
int httpCode = httpOTA.GET();
if (httpCode > 0) {
if (httpCode == HTTP_CODE_OK) {
String payload = httpOTA.getString();
Serial.println(payload);
Serial.println("Update available");
}
} else {
Serial.printf("[HTTP] GET... failed, error: %s\n", httpOTA.errorToString(httpCode).c_str());
}
httpOTA.end();
}
}
void setup()
{
// ssl_client.setInsecure();
initializeApp(client, app, getAuth(dbSecret));
app.getApp<RealtimeDatabase>(Database);
Database.url(FIREBASE_REALTIME_URL);
Database.get(client, "/my-path", result, true);
}
void loop()
{
Database.loop();
if (condition_each_10_minutes) {
checkUpdateAvailable();
}
} After that, I change this line of code Database.get(client, "/my-path", result, true); to this Database.get(client, "/my-path", result, false); Then function checkUpdateAvailable() work as is, but can not listening events from firebase realtime database on update. Does anyone have any advice for me? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 8 replies
-
In ESP8266, you don't have enough memory to open two network connections at the same time. The memory used in If you use another Or you have to stop Firebase before doing OTA and resume it after. |
Beta Was this translation helpful? Give feedback.
In ESP8266, you don't have enough memory to open two network connections at the same time.
The memory used in
WiFiClientSecure
for your OTA library is large (> 16k by default).If you use another
WiFiClientSecure
used for Firebase, you have to set its buffer size smaller like this.FirebaseClient/examples/RealtimeDatabase/Async/Callback/Stream/Stream.ino
Line 99 in 937c388
Or you have to stop Firebase before doing OTA and resume it after.