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.

  • Sound like a memory leak. Try to check the heap...

  • I've eliminated the use of the lte_lc module and gone to directly using the at_cmd module.  I'm using the at_cmd_write_with_callback function as well as setting the notification handler to the same funciton that prints out what responses I get from the modem.  I appear to be battling 2 problems.  Sometimes the modem gets stuck and the last feeback message I see is "+CEREG: 2,"4311","049C6410",7".  So the program is in perpetual unregistered mode.   I've also turned on the Debug logging of the AT_CMD and on some other runs I will start getting "[00:28:05.921,997] <err> at_cmd: Failed to send AT command".  So it seems I'm doing something to the modem to lock it up.  Is there a way to programmatically to reset the modem without reseting the rest of the program?

  • Hi,

    There are some bugfixes in the latest bsdlib versions. If you are on the ncs v1.0.0 tag, then it will by default use bsdlib v0.3.3. You can change it to use the latest verision by modifying the west.yml file, and point nrfxlib to the latest revision/commit. (There is currently a active PR for this on master branch to move from v0.3.3 to v0.4.0).

    - name: nrfxlib
    path: nrfxlib
    revision: 35120d32233dc354c89d8c62eaa6267093c7e35b

    BUT, if you are seeing that you are not able to connect after exactly 30 times, then this is not a bug. This is the GSMA specified Radio Policy Manager (RPM) feature which is blocking the ATTACH command. RPM is used for protecting the network from excessive signalling loads in various scenarios. In this case default value 30 is used for PDP Context Activation Requests (TS.34_8.2.4_REQ_010, See page 43 in this pdf)

  • So how is this supposed to be done.  I'm trying to put together a system that periodically connects to the cloud sends update messages and then goes back into low power.  I tried doing the same thing but staying in CFUN=1 mode and just putting it in low power after each simulated send.  Then it starts giving me the "[01:10:12.218,963] <err> at_cmd: Failed to send AT command" error.  And I've even updated the nrfxlib per your instructions.  Is there any way to accomplish the goal I have?

  • I'm seeing issues with CFUN=1 hanging after disconnecting and reconnecting, sometimes the first reconnect, sometimes more. I tried to change the nrfxlib revision but this gave me cmake errors with mbedtls not being found. Have you found another way around this

Related