Hi there
I am using threading and manual mode. and version V0.7.0-rc.2 (I want to test the publish with_ack is working)
If I use the following code below in a loop and disconnect the antenna to test lack of service on an electron. the Device will try and connect a single time only, I then put the device to sleep, when coming out of sleep the unit never turns the modem back on. Yet it does the first time through. and it does when it is successful in connecting to the cellular service. I think its a bug.
Adding Cellular.on in the line preceding the Particle.connect() makes it all work. The documentation states that the Particle.connect() function turns on the modem.
Particle.connect();
if (waitFor(Particle.connected, BAIL_OUT_TIME)) {
SERIAL_PORT.printlnf("Connected: %s, connection process took %d seconds.", Time.timeStr().c_str(), Time.now() - timeStarted);
seconds_to_stay_online = STAY_ONLINE_TIME;
SERIAL_PORT.printlnf ("publish = %s",string_to_post.c_str() );
//Particle.publish("meter_log",string_to_post.c_str(),PRIVATE, WITH_ACK); //the with_ACK has a bug in it, if it is never acked, it blocks.
Particle.publish("meter_log",string_to_post.c_str(),PRIVATE, NO_ACK); //as we have implemented our own ack handler it doesn't really matter.
waiting_ack = true; //we can just use our own ack.
}
else {
SERIAL_PORT.printlnf("WARNING: connection failed at %s, timeout was %d seconds).\n", Time.timeStr().c_str(), Time.now() - timeStarted);
Particle.disconnect(); //disconnect from the cloud in case it remembers state and tries to reconnect when it comes back alive.
//what are we going to do here. for now we do nothing as we have spare capacity in our buffer, lets hope we connect
//next time around.
}
My Sleep function is
Particle.disconnect();
Cellular.off();
System.sleep(METER_INPUT, METER_EDGE, sleep_time-2);