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?

  • In lte_lc.c:

    enum lte_lc_system_mode current_network_mode = sys_mode_preferred;

    where sys_mode_preferred is declared const.

    So basically, lte_lc_system_mode_set() does not work with lte_lc_connect().

    Is this on purpose? It would be fairly easy to get the current system mode and use that instead of the const.

  • Hi Daniel,
    You cannot change the mode when the modem is active. (lte_lc_connect())
    The mode selection needs to be selected when the modem is offline. 
    So if you select the mode after you have set the modem in offline mode (lte_lc_offline) then you are good.



    Best regards,

    Martin L.

  • Not working for me.

    I actually have it in a while loop:

    while (1)
    {
        lte_lc_init();
        err = lte_lc_connect();
        //Send some stuff
        lte_lc_offline();
        if (err)
        {
            lte_lc_system_mode_set(LTE_LC_SYSTEM_MODE_LTEM);
        }
    }

    Something like this. Not changing the mode - again, the lte_lc.c I have (sdk 1.3.0) defines the mode as a static constant from the Kconfig......

  • Please use our samples as reference, that implementation will not work. 
    e.g. lte_lc_init() should only be needed to be done once.

    Applications usually have it's own "modem_configure" function where this is set.

    You need to wait a bit after you have set the modem in offline mode. (it needs to de-attach from the network)

  • I got it to work with the 1.3.99 SDK - was a bug in 1.3.0 (I messed up and checked out the wrong repo when installing manually).

    I should add some funny things:

    With 1.3.99 I can shutdown the BSDlib (can't remember the command now) and poweroff the modem, which gives a connection timeout when trying to re-init/connect. However, if I just ignore the timeout error, I can still send data to my server thus not needing to power cycle the whole board.

    Isn't it funny that a connection is actually established even though a timeout error is returned?

    Anywho, I am not doing it like that now, just found it interesting Slight smile

    And I should add that my implementation actually does work - even though it is perhaps not intended to?

Related