Cellular: Modem callbacks
The Modem callbacks sample demonstrates how to set up callbacks for Modem library initialization and shutdown calls, using the Modem library integration layer and how to set up a callback for changes to the modem functional mode using the LTE link control library.
The sample supports the following development kits:
When built for an
_ns build target, the sample is configured to compile and run as a non-secure application with Cortex-M Security Extensions enabled.
Therefore, it automatically includes Trusted Firmware-M that prepares the required peripherals and secure services to be available for the application.
The sample performs the following operations:
Registers callbacks during compile time for modem initialization, functional mode changes, and shutdown using the
Initializes the Modem library.
Shuts down the Modem library.
This triggers the callbacks for
To send modem traces over UART on an nRF91 Series DK, configuration must be added for the UART device in the devicetree and Kconfig. This is done by adding the modem trace UART snippet when building and programming.
Use the Cellular Monitor app for capturing and analyzing modem traces.
TF-M logging must use the same UART as the application. For more details, see shared TF-M logging.
This sample can be found under
samples/cellular/modem_callbacks in the nRF Connect SDK folder structure.
When built as firmware image for the
_ns build target, the sample has Cortex-M Security Extensions (CMSE) enabled and separates the firmware between Non-Secure Processing Environment (NSPE) and Secure Processing Environment (SPE).
Because of this, it automatically includes the Trusted Firmware-M (TF-M).
To read more about CMSE, see Processing environments.
To build the sample with Visual Studio Code, follow the steps listed on the How to build an application page in the nRF Connect for VS Code extension documentation. See Configuring and building an application for other building scenarios, Programming an application for programming steps, and Testing for general information about testing and debugging in the nRF Connect SDK.
After programming the sample to your development kit, complete the following steps to test it:
Connect the kit to the computer using a USB cable. The kit is assigned a COM port (Windows) or ttyACM device (Linux), which is visible in the Device Manager.
Connect to the kit with a terminal emulator (for example, nRF Connect Serial Terminal). See Testing and optimization for the required settings and steps.
Power on or reset your nRF91 Series DK.
Observe that the sample starts, initializes the modem, changes functional mode and shuts down the modem.
The sample shows the following output:
Modem callbacks sample started
Initializing modem library
> Initialized with value 0
Changing functional mode
> Functional mode has changed to 1
Shutting down modem library
> Functional mode has changed to 0
> Shutting down
This sample uses the following nRF Connect SDK libraries:
It uses the following sdk-nrfxlib library:
In addition, it uses the following secure firmware component: