Using modem/nrf_modem_lib.h and modem/lte_lc.h

Hello dear Nordic support staff,

I'm working on some legacy code (NCS 1.8.0 in case it's relevant) and see this in the inclusion list of one of the files:

#include <modem/nrf_modem_lib.h>
#include <modem/lte_lc.h>

Functions from both libraries are used to set up the modem and create a connection. I'm new to network code on the nrf9160, but looking at samples and documentation, it seems like using only one of the libraries is enough, where you choose lte_lc if you want more granular control.

E.g, the udp sample uses only lte_lc.h, while the http_update sample uses only nrf_modem_lib.h. I also see that the modem_shell sample uses both. Why?

Parents
  • To illustrate the difference, here are the steps that the udp, modem_shell and http_update samples use to connect. I have reduced the code to only what seems like relevant function calls, and added comments

    // Sample UDP
    
    lte_lc_init();
    // [Configure low power settings]
    lte_lc_connect_async(lte_handler);
    // [Wait for lte_handler to give a semaphore before continuing]
    // [Do actual network stuff using net/socket.h]

    // Sample HTTP Update
    nrf_modem_lib_init(NORMAL_MODE);
    fota_download_init(fota_dl_handler);
    // [optional cert provisioning]
    lte_lc_init_and_connect();
    fota_download_start();

    // Sample Modem Shell
    nrf_modem_lib_init(NORMAL_MODE);
    at_cmd_init();
    at_notif_init();
    at_monitor_init();
    lte_lc_init();

    I just don't see when it is necessary to initialize the modem with one library or the other. Upon closer inspection it seems http_update also uses the lc_lte library in common/include/update.c.

Reply
  • To illustrate the difference, here are the steps that the udp, modem_shell and http_update samples use to connect. I have reduced the code to only what seems like relevant function calls, and added comments

    // Sample UDP
    
    lte_lc_init();
    // [Configure low power settings]
    lte_lc_connect_async(lte_handler);
    // [Wait for lte_handler to give a semaphore before continuing]
    // [Do actual network stuff using net/socket.h]

    // Sample HTTP Update
    nrf_modem_lib_init(NORMAL_MODE);
    fota_download_init(fota_dl_handler);
    // [optional cert provisioning]
    lte_lc_init_and_connect();
    fota_download_start();

    // Sample Modem Shell
    nrf_modem_lib_init(NORMAL_MODE);
    at_cmd_init();
    at_notif_init();
    at_monitor_init();
    lte_lc_init();

    I just don't see when it is necessary to initialize the modem with one library or the other. Upon closer inspection it seems http_update also uses the lc_lte library in common/include/update.c.

Children
No Data
Related