Thank you @peekay123 for your detailed explanation.
Is great to have some authorized help. Honestly most of the code that I use
in Particle is the result of experimentation since I had issues that I cannot figure out how to
solve.
I’m not using `SYSTEM_THREAD(ENABLED) and adding a 2 seconds delay only to prevent this:
OTA systematically crashes Photon - Easy to reproduce
What I trying to archieve with my code is the following:
A sensor is read every 10 seconds
The value is accumulated in one variable
Every hour, the accumulated value is divided by the number of reads effectively done
A webhook is hit with the resultant data
…
When sending the data to the webhook, if Particle.Publish() timeout, the system enter in
offline mode. It tries to reconnect, but it keeps reading and saving the data.
If still in emergency mode when a new hours begins, it saves the data to a local array
after checking if are memory available. If not if rotates the array and delete old values.
When the system connects again it dumps the array to the webhook.