Wait for OTA mode

Is there a way to put a spark core into a mode where it is only waiting to be flashed OTA? For instance, if I run code that contains an error causing the core to be unresponsive to OTA. Resetting just runs the same error again. The only other way is to do a factory reset, which is of course a lengthy process.
Thank you in advance

My favorite way to accomplish this is to do something as simple putting this in the top of my setup() function

while(millis() < 10000)  // Wait 10 seconds
{
    SPARK_WLAN_LOOP();
}

The spark will spend the first 10 seconds after reset just waiting for OTA/cloud communication. You could also trigger it with something like:

pinMode(D0, INPUT_PULLDOWN);
while(digitalRead(D0) == HIGH)
{
    SPARK_WLAN_LOOP();
}

Which would be triggered by placing a wire between D0 and 3.3V and then resetting your core

1 Like

I love it. Thank you

1 Like

This is a wonderful solution. I think I’ll include it with every program from now on!

I did have to change it from:
SPARK_WLAN_LOOP();
to
SPARK_WLAN_Loop();
to get it to work for me. I might be using a different version of the library.