Has anyone got any code that would allow manual mode to test for cloud connectivity for say the first 30 seconds if the user wants to re-flash the core, if no connection to go back to manual mode.
I just want to use manual mode but re-flash new programs to the core without having to connect by USB. Any ideas? I think it will be fairly easy just call spark.process() after a few delays, but I don’t want to try it out. Any suggestions?
I use a pin that pull high or low to run or go into a re-flash-me loop. I test that pin at the top of loop() and if it is high I connect to the cloud and call SPARK_WLAN_Loop(); forever.
I usually reset the core and while holding reset, I move the jumper, and then release reset. Once you are looping forever (or flashing) you can move the jumper back.
I like the PIN idea which I saw in the documentation, but I want something more software based.
Basically if the cloud is available, then connect to it so that I can re-flash the core ~10-30 seconds on startup, after which I want it to switch to manual mode and not worry at all about the cloud until the next power on. Don’t think it should be really difficult, just can’t get my brain around it. I read some of the other threads about Spark.disconnect(), but they seem to get complex, when this should not be very difficult.
I'm not sure what you've read, but by using SparkIntervalTimer it's not that big a deal - unless your main program is too big to allow for this additional lib.
For 0.4.0 we’re making a safe mode where you can push the mode button at startup to have the system boot in automatic mode and connect to the cloud without needing a factory reset.
Sometimes though, if user firmware is really borked on the core, since it’s entwined with the system code, safe mode may not be able to help. So there will also be a factory restore - factory reset without clearing wifi credentials - which can also quickly get you back to a working state. Exite!
That sounds good @mdma . For the moment, I think this code will solve my problem of wanting to use manual mode but being able to flash the core for an update without using a USB cable.
// must have wifi working for startup, since automatic mode blocks until wifi is connected
// Can use cell phone hotspot as long as it is setup earlier with another cell phone.
void setup() {
delay(2000); //give some time to reflash the core
delay(2000);
delay(2000);
delay(2000);
delay(2000);
delay(2000);
delay(2000);
delay(2000);
delay(2000);
delay(2000);
Spark.disconnect(); // basically puts you in manual mode, so should ignore any poor wifi reception issues
}
void loop() {
}