Reading the Photon docs I see that if I know I won’t have an Internet connection, I can put the Photon in manual mode which will allow my application to run without a connection. This is OK, but from what I’ve been able to gather if I’m in manual mode and call Spark.connect(), my application will halt until a connection is made:
After you call Spark.connect(), your loop will not be called again until the device finishes connecting to the Cloud
Will this call actually block forever or will it eventually timeout and return control to my application? I’m fine if it gives up connecting after X seconds and I can return to my code…but that is not how I’m reading things. Ideally I’d execute my application logic doing cool things locally and whenever I have a connection I’ll push up alarm states or data I’ve collected while offline.
I’ve read some other posts about a task to be completed to add threading so the cloud connection runs on a separate thread…that is ideal of course but I’m still curious if I can weave online/offline logic into my app without having to worry about execution halting due to a failure to connect.
If not…is there a way to configure the Photon to automatically enter into listen mode if it is not able to establish a connection to a known Wi-Fi network? The buttons on the Photon aren’t accessible in the enclosure I’m using, so when I take it places to demo it and use the local access point I end up having to unscrew things and open the enclosure. It would be great if I could achieve this behavior using auto mode, but if I have to use manual mode that would be ok as well. Looking at the docs I see WiFi.connect() and WiFi.listen() look promising but this part is worrisome
If there are credentials stored, this will try the available credentials until connection is successful.