Cellular.connect blocking: fix expected?

Tags: #<Tag:0x00007f038f972cc0>


I’m running my app using SYSTEM_MODE(SEMI_AUTOMATIC); and SYSTEM_THREAD(ENABLED);. I notice that when I call Cellular.connect() the next delay statement blocks for over 5 seconds. Is this planned to be fixed? I understand that connect() needs to do some work, so some time is going to be “stolen” by it, but I’d be shocked if that work actually took 5 seconds. I suspect it’s just delays waiting for the modem to do its thing and that could all be moved into a state machine or task that lets the app continue to run…


Let me ping someone that might be able to help, @ParticleD, or @mstanley are you able to assist?


Thanks! NB: this is on a Boron.


2G/3G or LTE?


delay() attempts to perform some background processing in order to keep the system responsive which is (apparently) backfiring in your case. I’m definitely curious what is causing the 5-second block and where that is coming from. In any case, I have a couple ideas to workaround in the meantime.

  1. Use HAL_Delay_Milliseconds() instead of delay() to not allow any background processing. Be careful with long delays as that can impact the overall system. Some events have to be run from the application thread and HAL_Delay_Milliseconds() won’t allow that.
  2. The background processing loop is only run by delay() from the main application thread. You can setup separate Timer() or Thread() instances to manage critical operations that can’t be blocked while leaving your main application thread to handle potentially blocking operations and processing the various event loops that delay() manages.


@joel thanks for the reply! Those are good suggestions. Using separate threads makes sense but cap rapidly complicate the app with locks and semaphores…

How could I did in to figure out where it’s blocking?

I’m using an LTE Boron.


Hey Tve,

Good questions indeed. I suspect it may actually be the Cellular.connect() blocking for that period of time. I do know there are some known caveats with LTE at the moment, and would like to hear @BDub’s insight on this. He may be able to provide additional feedback into Cellular.connect() and its implications to the delay going on here.