Is there any way to tell if an imp has successfully connected to WiFi? Preferably in the device code.
We run code on the device but don’t connect/turn WiFi on but every 10 minutes. Whenever the WiFi turns on and cannot connect successfully I believe the imp will just keep trying connect until our battery dies.
how about server.isconnected()
Blip a small LED for .5 seconds each time it successfully connects. You would then have a visual indicator of success.
How far does the code go after if tries to find WiFi. For example if it runs the code currently on the bug and then finds code where it needs to turn the WiFi but cannot find WiFi… does the code continue to run? or does it halt there and then restart the code back at the top?
The default behaviour is for the imp to execute code until it hits a line that requires a network connection (server.log, agent.send, etc).
It will try to connect for 1 minute, if it hasn’t connected after 1 minute, it will go back to sleep for 9 minutes, then begin the process again.
You can change this behaviour with server.setsendtimeoutpolicy.
@Smittytone is currently working on a document that will explain the process of writing good and reliable offline code in much greater depth and clarity than currently exists in our documentation!
Thank you for your feed back. We are running off a battery so if it spends 1 minute with the wifi radio on, it greatly decreases our battery life. Is there a way to change that 1 minute period to a lesser period?
If you use the server.setsendtimeoutpolicy to change the default behaviour you can!
Sorry about that last post I realized you had addressed it I just did not fully understand server.setsendtimeoutpolicy fully. Thank you again.
No problem - server.setsendtimeoutpolicy and writing offline code is one of the trickier concepts to understand in the Electric Imp world - we’re working on a Squirrel class to simplify things a bit + better documenation in general around that functionality.
Any ETA on when the new class/documentation will be released? I have figured it out with what you guys have offered currently but I am always intrigued to be up on the latest software.