I am working on a project where I need the photon to periodically publish data and then go to sleep until the next publish. I am using the particle::Future return of Particle.publish to call a callback when the publish has completed, and once this callback has been called I delay for 5 seconds before entering sleep. I have the publish on a timeout so if the publish is not successful after some time the system will go to sleep again.
About 90% of the time the publish is successful and everything works fine but the other 10% of the time nothing will be published and it enters sleep. When it wakes up again it will publish the event that was supposed to be published last time, as well as the current event.
If I replace the
System.sleep call with
Particle.disconnect(); delay(sleepTime); Particle.connect();
everything works fine. I have tried sleeping with
SLEEP_NETWORK_STANDBY but both cause the same issue.