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.
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!)
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: