This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Simple Modem on/off test

I'm working on an application where I will need to initialize the modem, send/receive messages and then turn it down to low power until the next checkin.  I did a real simple loop in a thread that turned on and off the modem and it always ends up locking up in the reinitialization or power down of the modem.  I've tried several variants based on examples I've seen on the forum but nothing seems to work.  Right now I create a new thread and have a loop like this;

while( true )
{
err = k_msgq_get(&mm_msg_que, &recvEvent, K_SECONDS(CHECK_IN_TIMER_INTERVAL_SECONDS));
if ( (err == -EAGAIN) || (err == 0) )
{
printk( "Initializing Modem\n" );
if ( (err = lte_lc_init_and_connect() ) )
{
printk( "Unable to connect to Modem\n" );
k_sleep(5000);
continue;
}
lte_lc_psm_req(true);
printk( "Sending Check In Message\n" );

printk( "Pretending to connect to Cloud\n" );
k_sleep(5000);
dk_set_led_on(2);
k_sleep(5000);
dk_set_led_off(2);

lte_lc_psm_req(false);
printk( "Turning off Modem\n" );
if ( (err = lte_lc_offline() ) )
{
printk( "Failure turning off Modem: %d\n", err );
}
}
k_sleep(1000);
}

Is this the improper way to do it.  I'm thinking that it must be locking up on the blocking send().  This seems like such a simple task, I'm not sure what I'm missing.

  • I'm now just leaving CFUN=1 and continuing.  I've discovered that you can set the power saving mode (psm) and things still work.  I'm assuming that it allows the modem to go into power saving mode when not actively communicating.  I haven't tested this all out yet, but that is the track I'm proceeding on.

    I had the same problem with mbedtls and had to revert back to v1.0.0

  • Did you ever receive a solution for this?  We are at this same exact issue at this current moment.

  • The online/offline issue was what they claimed.  The cell phone providers will shutdown any LTE-M connection from a device that happens more than 30 times in one hour.  The other piece of advice I received is that you don't put the modem in and out of low power.  Once you set the PSM and eDRX parameters, the modem takes care of it itself.  So that is what I've been doing and it seems to work fine.  There is some issue that PSM seems to work only with some carriers, but I've come to rely on eDRX because my modem use frequency is too high for PSM to be of any use.  

    Or is it the mbedtls problem that you're talking about?  I've just reverted back to v1.0.0.  I've also upgraded my modem firmware to the latest 1.0.1.  As long as I don't send repeat CPSMS messages.  It works fine.  I've run it for several days and a time and it doesn't crash.

Related