mobizt / Firebase-ESP32

[DEPRECATED]🔥 Firebase RTDB Arduino Library for ESP32. The complete, fast, secured and reliable Firebase Arduino client library that supports CRUD (create, read, update, delete) and Stream operations.
MIT License
414 stars 119 forks source link

QUESTION Reinitialize firebase connection #273

Closed JoergTiedemann closed 1 year ago

JoergTiedemann commented 1 year ago

I use firebase ESP32 latest version on an ESP32 with emaill and passwort authentification and it works properly

If i got any firebase errors i.e. refresh of token not possible (because of networt error) or writing of json datasets not possible or some other internal errors i will to stop the firebase connection by calling

Firebase.reset(&fbconfig);
Firebase.end(fbdo);

After that I sign into firebase again. Before I set

FirebaseAuth fbauth; FirebaseConfig fbconfig;

to the initial values I've set after startup and then i call

Firebase.begin(&fbconfig, &fbauth);

to sign in again and this is successful and Firebase.ready() returns true

But if I after that want to write something into RTB database by calling Firebase.RTDB.setJSON(&fbdo, aktLogPath.c_str(), &parent))

which works normally, Firebase.RTDB.setJSON returns false and fbdo.errorReason() returns nothing It seems that the sign in is ok but something is not reinitialized What should I have to do after calling

Firebase.reset(&fbconfig);
Firebase.end(fbdo);

to connect to firebase and able to write into RTDB ?

mobizt commented 1 year ago

When you call Firebase.end, the FirebaseData object will stop working and will not use anymore as the name implied.

This causes FirebaseData object stays in pause state which can be resumed to work by calling fbdo.pauseFirebase(false).

It is different from Firebase.begin that use for initializing the authentication with is not related to FirebaseData object function.

You can call clear method instead of Firebase.end, i.e., fbdo.clear().