Hi, I am making a device to use at sea, with an intermittent internet connection. Can I write code that will keep running even when the spark cloud cannot be reached? I foresee using a notification service to send a notification to and IOS or Android mobile when connected, but likely will need to send a message to a local server if the cloud cannot be accessed. Can it be done, or will the sketch stop when the cloud access is interrupted?
Try searching the forum for something like âwithout wifiâ and you will find a lot of hits.
Dave O
You can use Spark.disconnect()
However, there seems to be major bugs with the WiFi firmware, where the network will fail after a period of time and a reset is required to fix.
Right now it seems to be a problem with the CC3000 radio going âmuteâ, weâre still trying to nail this down as it seems to happen in certain network environments more than others. But yes, disconnecting from the cloud, or #undefâing SPARK_WLAN_ENABLE should both do the trick.
Weâve also started talking about making a UDP cloud connection available instead of TCP, which would be much more resilient to dropped connections.
In my experience disconnecting from the Spark cloud (Spark.disconnect()
) will prevent the core from locking up (not executing user code) when the WiFi radio fails, but doesnât stop the WiFi failure itself. It just means any connections youâre using will stop, such as a TCP or UDP connection. Your code will continue to execute. So you can have a stable âmini arduinoâ, but a stable âmini arduino with WiFiâ isnât possible yet! (theyâre working on it though!)
Hi Guys,
Thanks for the replies. It doesnât sound like this will quite work, at least not now. I need a a reliable notification to go out from the core in response to an event. If the connection to the internet is not working, then it needs to go out wirelessly, locally. Bummer. Iâll still set it all up and see how it does.
Is there a way to reset the core via code? Maybe fine the shortest time that the core has to the wifi failure and making it reset at a shorter interval, thereby getting a close to stable wifi? Just thinkinâ.
See here @jimbol for how to reset the spark core with a watchdog timer: