Hello there,
I switched to Semi-Automatic Mode for my project because I need data logging to be running over night for days at a time, and for any reason if the Cloud disconnects my user code stops, while it trys to reconnect I’ve read up on the “blocking” that the Core currently does; So I figured Semi-Automatic Mode skip the Cloud and go straight to WiFi connection/user-code.
But after flashing my core with my firmware, the Core immediately goes into listening mode, I try and connect with the SmartConfig App (Spark App on iPhone) and the Core goes solid blue, flashes green once, and goes right back into listening mode, it repeats this small loop for as long as I got the SmartConfig App running.
I posted code below, am I going about this the wrong way? As always any insight or direction is greatly appreciated
SYSTEM_MODE(SEMI_AUTOMATIC);
unsigned long lastsync =0;
void setup()
{
Serial.begin(115200);
}
void loop()
{
if(!WiFi.ready())
{
WiFiSetup();
}
if(millis() - lastSync > ONE_DAY_MILLIS){ // THIS will request a time synchronizatoin from the SparkCloud
Spark.connect();
timout=millis();
if (millis()-timout >= 30000){ //instead of using if(Spark.connecting()) made a 30000ms time out
if (Spark.connected()){
Spark.syncTime();
lastSync = millis();
Spark.disconnect();
}
}
void WiFiSetup(){
WiFi.listen();
if (WiFi.listening()){
WiFi.connect();
timout=millis();
while(WiFi.connecting()){
if (millis()- timout>=30000){
Serial.print("Could not connect to Wifi");
break;
}
}
if(!WiFi.ready()){
Serial.print("Failed to connect to WiFi");
}
Serial.print("Connected!");
}