Particle.connect - v0.7.0-rc.2 - issue with waitFor timeout


#1

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);

#2

We need more context to this.
Where in your code are these snippets located?
The sleep you are using will - unlike deep sleep, which will start from a reset - continue with the code line after the sleep statement.

Also did your code work as expected with 0.6.2 or even 0.7.0-rc.1?


#3

I can PM the whole file if you want? it’s a bit of a mess as its all in the single file and I haven’t had time to clean up some of the duplication that seems to creep in.

Do you think that it is the cellular.off() in my sleep function. The particle.connect() is supposed to establish everything from the way I read it.

I can try older firmware versions, I was really wanting that with_ack (and the ability to do a monolithic build) that the V0.70 has.

Regards
Marshall