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.