I am turning of the Cellular modem on my electron to save power and also the unit will be in marginal reception areas so signal will cut out. I am storing readings in the eeeprom and then uploading them when I get a signal.
Problem is that Particle.connected() is returning true even when it is not connected. So my unit is publishing but the readings are not getting to the server.
How can I ensure that I have a connection to the cloud before I publish.
Any help is appreciated.
void sendReadings(){
if(Particle.connected()){
Particle.process();
mem_get();
while(reading.temp < 119 && Particle.connected()){
char lff[26];
sprintf(lff, "%d,%d,%d,%d", reading.temp, reading.humidity, pointer.readTime, (int)fuel.getSoC());
if(Particle.publish("Telemetry", lff)){
move_read_pointer();
print_to_serial("Published OK ");
print_to_serial((String)lff);
delay(1000);
mem_get();
} else {
print_to_serial("Could not publish");
break;
}
}
if(!Particle.connected()){
print_to_serial("Connection Lost during upload.");
}
} else {
print_to_serial("Could not connect");
}
}