Closed nikrath closed 5 years ago
Your above code is error and can't compile due to return integer inside String returned function getFirstInt() and getSecondInt()
And you're not provide the WiFi connection in setup too.
The normal usage of Firebase Data object does not cause problems.
Use Firebase Data object as local variable is not recommend which may lead to unreleased memory used by WiFi core.
You can help me to address the root causes by do the following.
@mobizt Thanks for the response. I have updated the code in the original question, and added some additional information. I will state those here again:
I have a program that accepts performs the following operations:
Acts as UDP Server Operates in AP_STA WiFi mode Shows IP Address of devices connected to ESP32's AP Uploads certain data to firebase on regular interval of 10s
The flag variable (in CheckFlag function) should return the flag value stored on the Firebase Database in path "/flag". BUT Sometimes, the flag (in CheckFlag function) actually returns the value of the date variable stored on firebase database (which should be fetched by prevDate variable in Sync function). But instead prevDate returns 0 (i.e, it fails to fetch a value).
I'll give an example of the above statement. Yesterday, the value stored in my Firebase database at /date was 21, and at /flag was 0. The code looped and every 10 seconds, it showed the following output: prevDate = 21 flag = 0 It ran fine for around 8-9 hours. After that, it suddenly shows the following output: prevDate = 0 flag = 21
I guess prevDate was 0 because it couldn't fetch properly from online (in which case the function FirebaseGetInt returns 0). But what I don't get is why flag variable in code showed the value at /date instead of the value at /flag?
P.S Sorry I couldn't give the credentials of the Firebase Database, it belongs to the company I am currently interning at. But if required, please inform me so and I will create a new dummy database for your testing purpose.
Thanks
My library is rather give the exact what type of data store and read from database.
Please check your free heap and stack size that may lead to heap corruption problem because your application used large of memory for all time.
I have a program that accepts performs the following operations:
These functions are called one after the other in regular intervals of 10 seconds. The flag variable (in CheckFlag function) should return the flag value stored on the Firebase Database in path "/flag". BUT Sometimes, the flag (in CheckFlag function) actually returns the value of the date variable stored on firebase database (which should be fetched by prevDate variable in Sync function). But instead prevDate returns 0 (i.e, it fails to fetch a value).
I even tried to make FirebaseData firebaseData a local variable to these functions instead of a global one. I thought some kind of an overwrite issue might be causing this. But turning it into local variables led the ESP32 to crash for some reason.
Does someone know a fix for this? Thanks