B524 Module wont cellular connect after sleep

My B series module wont cellular connect after sleeping. My application runs as a FSM and wakes after a certain time to connect to the cellular network and cloud and publish its data. When it wakes up I call Cellular.on(), wait until modem is on, Particle.connect(), wait until connected, then go about the rest of the application. When initially flashing the device it will connect and run as it should do, but after it wakes up from sleep it gets stuck connecting(green flashing light) and gets caught in the connection timeout clause.
To get it to sleep I use the following config. (The previous application used a E310 module with SLEEP_MODE_DEEP and SLEEP_NETWORK_STANDBY flag and I’m trying to get the same functionality). The device can wake up on GPIO pins or by sleep timeout, which can vary from 0sec to 20 mins.
As an aside, am I setting the cellular flags correctly. Sleeping for less than 20 mins, have functionailty like NETWORK_STANDBY, and if greater than 20 mins turn network off completely(SLEEP_NETWORK_OFF in the E310).

SystemSleepConfiguration config;  

    //If sleep seconds greater than network off time(20 mins), turn off, else be on standby 
    config.network(NETWORK_INTERFACE_CELLULAR, SystemSleepNetworkFlag::INACTIVE_STANDBY); 

    if (sleepCellular && sleepSeconds >= MIN_NETWORK_OFF_SECONDS) {
      config.network(NETWORK_INTERFACE_CELLULAR, SystemSleepNetworkFlag::NONE);
    } else {
      log.trace("...with network standby");
    //In here will have to append sleep config by each pin and edge 
    for (auto &input : wakeOnInputs) {
      config.gpio(input->pin, input->edge); 
    auto sleepStart = Clock::beforeSleep();
    if (log.isTraceEnabled()) {

    //System.sleep takes in ms as time 
    config.duration(sleepSeconds * TIME_PER_SECOND); 
    //Going to sleep
    SystemSleepResult result = System.sleep(config); 

My log during power down for sleep is the following:

0000026723 [app.syncPublishConnected] TRACE: Attempting publish...
0000027042 [app.syncPublishConnected] INFO: Published connected event
0000027042 [app.state.ModemControl] TRACE: Sync SyncPublishConnected complete
0000144201 [app.state.ModemControl] INFO: Transition: syncing -> disconnecting
0000144241 [system] INFO: Cloud: disconnecting
0000144241 [system] INFO: Cloud: disconnected
0000144242 [app.state.ModemControl] INFO: Transition: disconnecting -> turningOff
0000144245 [system.nm] INFO: State changed: IP_CONFIGURED -> IFACE_UP
0000144246 [net.pppncp] ERROR: PPP error event data=5
0000157189 [mux] INFO: Stopping GSM07.10 muxer
0000157189 [mux] INFO: Gracefully stopping GSM07.10 muxer
0000157190 [mux] INFO: Closing all muxed channels
0000157190 [mux] INFO: Closing mux channel 1
0000157190 [mux] INFO: Closing mux channel 2
0000157191 [mux] INFO: Muxed channel 3 already closed
0000157191 [mux] INFO: Muxed channel 4 already closed
0000157192 [mux] INFO: GSM07.10 muxer thread exiting
0000157192 [mux] INFO: GSM07.10 muxer stopped
0000157194 [app.state.ModemControl] INFO: Transition: turningOff -> off
0000157195 [app.runner] TRACE: Ran all state machines, can sleep
0000157196 [app.runner] TRACE: Waking in 1041s for:
0000157196 [app.runner] TRACE: ModemControl.off
0000157196 [app.runner] TRACE: ...or if triggered by io.modeSwitchWKP
0000157197 [app.runner] TRACE: ...or if triggered by io.rain
0000157198 [app.runner] TRACE: ...or if triggered by io.flow
0000157198 [app.runner] TRACE: ...with network standby
0000157300 [system.nm] INFO: State changed: IFACE_UP -> IFACE_REQUEST_DOWN
0000157300 [system.nm] INFO: State changed: IFACE_REQUEST_DOWN -> IFACE_DOWN
0000157302 [system.nm] INFO: State changed: IFACE_DOWN -> DISABLED

Then when it wakes up it just tries to connect then times out. None of the logs from system.nm state changes happen.
Thanks in advance

It’s not immediately obvious to me why this is happening. The best way to debug this is to get the logs immediately at wake, however this is impossible to do using USB serial.

You’ll need to use the Serial1LogHandler and connect a USB to 3.3V serial adapter (FT232 or similar) to the TX pin, assuming you’re not already using it for something else.

The reason this works is that when the device goes to sleep, USB serial is disconnected and it takes between 2 and 10 seconds for it to reconnect at wake. If you use an external USB to serial adapter, the USB serial to that stays alive during sleep, and the UART serial wakes up immediately and you’ll catch the logs from early in the wake cycle.

Does it make a difference whether you’re in a network standby wake? If you’re in network standby you shouldn’t even go through blinking green. Without INACTIVE_STANDBY you go right into breathing cyan. With INACTIVE_STANDBY as you have it set, you should go right to blinking cyan.

You might want to set the code to explicitly test the three scenarios (no NETWORK_INTERFACE_CELLULAR, NETWORK_INTERFACE_CELLULAR only, and NETWORK_INTERFACE_CELLULAR with INACTIVE_STANDBY), and to see how it behaves.

0000272817 [app.runner] INFO: Woken by sleep timeout
0000272817 [app.state.ModemControl] INFO: Transition: off -> connecting
0000422818 [app.state.ModemControl] INFO: Transition: connecting -> connectFailed
0000422819 [app.state.ModemControl] TRACE: Cellular not connected, no signal info available
0000422820 [app.state.ModemControl] INFO: Giving up, connect failure, now 1 in a row
0000422820 [app.state.ModemControl] INFO: Transition: connectFailed -> turningOff
0000424819 [app.state.ModemControl] INFO: Transition: turningOff -> off
0000424821 [app.runner] TRACE: Ran all state machines, can sleep
0000424821 [app.runner] TRACE: Waking in 1045s for:
0000424822 [app.runner] TRACE: ModemControl.off
0000424822 [app.runner] TRACE: ...or if triggered by io.modeSwitchWKP
0000424822 [app.runner] TRACE: ...or if triggered by io.rain
0000424823 [app.runner] TRACE: ...or if triggered by io.flow
0000424823 [app.runner] TRACE: ...with network standby

Thats the log when it wakes. I see the difference is the system.nm FSM does nothing (no change from DISBALED to I FACE DOWN etc.) I have read that using ULP mode the network resumes from the last state it was in, which was cloud disconnected and cellular off.
Right so the INACTIVE_STANDBY flag does keep the modem powered but no connection? But since I’m calling cellular.off this flag would have no effect? I’ll have a play around with those different flags and try discern the correct one I need

Oh, wait. What is your intention of this line?

config.network(NETWORK_INTERFACE_CELLULAR, SystemSleepNetworkFlag::NONE);

This should leave the cellular modem on (no blinking green), with the cloud remaining connected so there is no blinking green phase, but the comment seems to indicate that you want the opposite behavior (cellular off). You should just not add a NETWORK_INTERFACE_CELLULAR at all if you want cellular to be turned off.

I think you’re getting an invalid combination of wake flags internally. Setting the NETWORK_INTERFACE_CELLULAR looks like it adds an additional item on the list of wake sources each time, and does not reset the one you have already added. That might also be an issue.

Right so if the module is sleeping for >20 mins (min network off time) I do not set any flags, but if the module sleeps for less than 20 mins I set the INACTIVE_STANDBY flag to keep the modem powered. I’ll try this

  • NETWORK_INTERFACE_CELLULAR means leave cellular on, cloud connected, wake on cellular

  • NETWORK_INTERFACE_CELLULAR, SystemSleepNetworkFlag::NONE means the same thing (cellular on, cloud connected)

  • NETWORK_INTERFACE_CELLULAR, SystemSleepNetworkFlag::INACTIVE_STANDBY means cellular on, cloud disconnected. This prevents aggressive reconnection for short sleep cycles but uses more power but will not wake on cloud requests.

  • No config.network(NETWORK_INTERFACE_CELLULAR) means disconnected from the cloud and turns cellular off.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.