Sometimes my photon loses wifi connection or the internet ISP fails. I need my photon to keep working.
When internet fails I want it to store the data it is collecting.
When internet returns I want it to publish that data.
My problem so far is that when I turn the wifi router off (simulating internet failure), the photon blinks green but does not continue working… for example no Serial.print(“no internet”);
I tried MANUAL and SEMI_AUTOMATIC modes and neither work.
void onlinecheck()
{
Particle.connect();
if (Particle.connected()==false) //if no internet store backup
{
Serial.println("NO INTERNET!!!!!"); // <<<<< this is never printed, why????
for(int o=0;o<ARRAYSIZE;o++){
if(backup[o]=="x")
{
backup[o] = "content of string to be backed up";
Serial.print("backup: ");Serial.print(o);Serial.println(" saved!");
o=100;
}
}
}
if (Particle.connected()) { //if internet, send backups every delay until finished
Serial.println("");
Serial.println("INTERNET OK!!");
for(int o=ARRAYSIZE;o<0;o--){
if(backup[o]!="x"){
Particle.publish("measure", backup[o], PRIVATE);
backup[o]="x";
delay(1000);
Particle.process();
}
}
}
}
thanks