Can't run loaded firmware without wifi

I would like to be able to program the core via wifi then take it away from the wifi coverage, power it, and run the same program again (that doesn’t need wifi).

Is this possible now? Is this in the backlog?

It seems like a bit of a showstopper for any application that doesn’t actively use wifi, or only uses it when available.

Thanks

I’d like to know this as well!

There have been several posts on this. With the current Cloud Based IDE, “no”, this is not possible. If you want to build it yourself, then yes. Maybe check out:

Dave O

There are a few new commands in the firmware that lets you control when you’re connected to the cloud or not. Although these let you disconnect, I think the setup function might still be blocked if you’re not online.

http://docs.spark.io/#/firmware/cloud-spark-disconnect-and-spark-connect

If you wanted everything to run while not online, you can disable cloud access entirely with something like:

#undef SPARK_WLAN_ENABLE

But we’re still working on making this easier! :slight_smile:

Okay so dissabling by default is possible. Say I do #undef SPARK_WLAN_ENABLE What about re-enabling during run time, to give me the option depending on my situation? Can I run spark.connect() in the setup loop and put a if(myButtonIsPressedOnStart){spark.disconnect()} ?

edit: if(!myButton){spark.connect} // forget the disconect it already is

In this way I could reset in order to get back on the cloud and hold my button on start-up to opperate without wifi. Seems simple would this work?

(Was just trying to show my project of away from home and relized no wifi no project, embarasing to say the least)

Just tested the afformentioned idea out

#undef SPARK_WLAN_ENABLE

Does nothing for my core, still connects.

So the #ifdef's are in there. Did you try to undefine this in the webIDE? I am not sure that it will work without a local build. This flag will completely remove the cloud connection calls from the build so that you cannot connect to the cloud.

If you just want to start with the cloud off and possibly connect and disconnect later, you want

#include "spark_disable_cloud.h"

I have code like this in a bunch of my apps. This allows me start and run with the cloud off with A0 tied low, then if I need to reflash, I pull the A0 pin high and the code loops forever waiting to flash or do other cloud stuff.

 	if (digitalRead(A0)==HIGH) {
 	    Spark.connect();
 	    while( Spark.connected==0) {}
 	    for(;;) { SPARK_WLAN_Loop(); }
 	}
3 Likes

I’m not sure I quite understand the purpose of the for loop that you have there

Is this code in your main loop?

Hi @inof8or

I use this code as a get-out-of-jail-free card when working with the cloud disabled. I put it in my loop() and when there is trouble and I want to re-flash my code, I tie pin A0 high. In the code, I first start to reconnect to the spark cloud, then wait for the cloud to tell me it is connected again via Spark.connected() (which it looks like the ()’ are missing above), and then loop forever doing SPARK_WLAN_Loop(). That way I never call the rest of my loop() code that is misbehaving.

Once it hits the for loop, it just waits forever with the cloud connected until I reflash it or hit the reset button.

1 Like

Interesting, with a bit of testing I got the spark working offline, but spark.connect(); Seems to not be working for me so I get stuck in the while loop while in the default left needing to do the factory reset. (hold-mode, click rst, yellow blinky, wait for white, release mode … for those accidentally getting into a bad loop testing this)

My other issue is that I am using all the IO on the spark, (actually I do still have the rx) so I really just need a one off connect or don’t connect in setup(). Elsewise the user driven I.O. conflicts. I think I have been getting buffer overflows with some of my latest experiments, in those cases the spark will go completely non-responsive to anything other then a reset.

In short fitting spark.connect(); in the set-up, is needed. Should I manually add “if(connected()){SPARK_WAN_LOOP();}” into the main loop in order to inter-change wifi on/off?

Nevermind, not sure how but the what I suggested actually works

This commit is kinda messy but it shows the example of a working wifi / no-wifi interchage
https://github.com/PaulBeaudet/ArduinoBraille/commit/a89c15f70f28afd8198d9a64d63c9023b4da7582

Wifi is disabled by holding the user buttons on startup. Reset for wifi

1 Like