I am experimenting with System.sleep and made a foolish mistake. I put my photon to sleep right after it starts but I specified the sleep value in milliseconds. So, now my photo will sleep for 1000 days instead of 1 day. And, I can’t upload the fixed code because it goes to sleep right after it starts.
I was wondering how I can recover from this.
I did a factory reset. Then went to the Tinker app to reclaim my device. As soon as I reclaimed it, it went to sleep again. So, I am guessing that a factory reset doesn’t really do a complete factory reset.
I had a similar problem with OTA programming. I learned my lesson. Ever since then, whenever I use ‘sleep’ I use it in an ‘if’ statement, and use a spare pin as a control line that I can jumper to high to avoid going to sleep.
Basically something in the form of “if pinX != HIGH then sleep (xxxx)”
This was definitely necessary on the core, since going through factory restore all the time took quite a bit of effort with reconfiguring wifi creds on each restore.
On the Photon with safe mode, you don’t have to do this anymore. Just a quick reboot to safe mode and the device will come back on the cloud (even if your application firmware was crashy.)