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

lte_lc_system_mode_set(); not sticking

I want to change between LTE-M and NB-IOT, however lte_lc_system_mode_set(); is not actually changing the mode.

I am doing something like this

//lte_lc_system_mode_set(LTE_LC_SYSTEM_MODE_LTEM);
lte_lc_init();
//lte_lc_system_mode_set(LTE_LC_SYSTEM_MODE_LTEM);
lte_lc_connect();
	if (err)
	{
        //lte_lc_system_mode_set(LTE_LC_SYSTEM_MODE_LTEM);
	}
lte_lc_offline();

I can't rely on PSM/eDRX hence I am switching the modem on/off when I have to send something.

The Kconfig is set to NB-IOT with fallback disabled.

When lte_lc_connect() is called it ignores the mode setting and uses NB-IOT.

What do I have to do?

  • Hi Daniel,
    note: the name "1.3.99" just indicates the master branch which is constantly updated. 
    (E.g. whats in the master branch today will be available in the tagged v1.4.0 release).

    I am glad that you got it working.

    Could you explain more in detail what you are seeing and what you are doing so that I could possibly replicate this on my side.
    To check if this is intended behavior or if this could be something that we need to investigate and fix in NCS.

    Best regards,
    martin L.

  • This is close to what I am doing:

    int reset_modem(void)
    {
        printk("Power off modem\r\n");
        lte_lc_power_off();
        k_msleep(10000);
        printk("BSD shutdown\r\n");
        bsdlib_shutdown();
        printk("BSD init\r\n");
        bsdlib_init();
        printk("LTE init\r\n");
        lte_lc_init(); // Don't think this does anything
        printk("LTE normal\r\n");
        lte_lc_normal();
        printk("Offline modem\r\n");
        lte_lc_offline();
    
        if (get_systemmode() == 1) // This actually doesn't work beyond the first 3 iterations
        {
            printk("\r\nSwitch to NB-IoT\r\n");
            lte_lc_system_mode_set(LTE_LC_SYSTEM_MODE_NBIOT);
        }
        else
        {
            printk("\r\nSwitch to LTE-M\r\n");
            lte_lc_system_mode_set(LTE_LC_SYSTEM_MODE_LTEM);
        }
    
        k_msleep(2000);
        return 0;
    }
    
    err = bsdlib_init();
    err = at_cmd_init();
    err = at_notif_init();
    err = lte_lc_init();
    
    while (1)
    {
        err = lte_lc_connect();
        if (err)
        {
            printk("LTE timeout\r\n");
            rsrp = 0;
            lte_lc_system_mode_set(OTHERMODE); // Comment this line if using reset_modem()
        }
    
        rsrp = app_http_start(); // Custom function for sending HTTP data
    
        lte_lc_offline();
    
        //reset_modem();
    }

    It works with the switching only the first 3 times. However, even with the timeout, it continues to be able to send data to our server.

  • Hi Daniel,
    Your code seems very "overkill" and should be cut down a good bit.

    When "resetting" the modem you only need to put it first in "offline mode" (then change the systemmode if needed) and then set it in "normal mode" afterwords.

    You should not need to run the bsdlibshutdown and lte_lc_init etc. more than once. 

Related