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.

Parents
  • Hi,

    I don’t see anything immediately wrong with your code. Could you post the code that shows how you are sending the data as well ? I.e. the place where you think it’s locking up ?

    Also if you post the whole main.c and prj.conf, it will be easier to reproduce the issue.

    Also note that if you are disconnecting/connecting to the network every 1 second, you will likely use more power on that compared to just staying connected with eDRX and/or PSM enabled.

Reply
  • Hi,

    I don’t see anything immediately wrong with your code. Could you post the code that shows how you are sending the data as well ? I.e. the place where you think it’s locking up ?

    Also if you post the whole main.c and prj.conf, it will be easier to reproduce the issue.

    Also note that if you are disconnecting/connecting to the network every 1 second, you will likely use more power on that compared to just staying connected with eDRX and/or PSM enabled.

Children
No Data
Related