Cellular: AT monitor

The AT monitor sample demonstrates how to use the AT monitor library and define AT monitors to receive AT notifications from the Modem library.

Requirements

The sample supports the following development kits:

Hardware platforms

PCA

Board name

Board target

nRF9161 DK

PCA10153

nrf9161dk

nrf9161dk/nrf9161/ns

nRF9160 DK

PCA10090

nrf9160dk

nrf9160dk/nrf9160/ns

nRF9151 DK

PCA10171

nrf9151dk

nrf9151dk/nrf9151/ns

When built for a board target with the */ns variant, 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.

Overview

The sample defines two AT monitors, one for network status notifications (+CEREG) and one for received signal quality parameters notifications (+CESQ) through the AT_MONITOR() macro. The sample then subscribes to both notifications and switches the modem to function mode one to register to the network. While the device is registering to the network, the sample uses one of the AT monitors to determine if the registration is complete and monitors the signal quality using the other monitor. Once the device registers with the network, the sample reads the modem PSM mode status, enables it, and reads the PSM mode status again.

Sending traces over UART on an nRF91 Series DK

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.

Building and running

This sample can be found under samples/cellular/at_monitor in the nRF Connect SDK folder structure.

When built as firmware image for a board target with the */ns variant, 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, follow the instructions in Configuring and building an application for your preferred building environment. See also Programming an application for programming steps and Testing and optimization for general information about testing and debugging in the nRF Connect SDK.

Note

When building repository applications in the SDK repositories, building with sysbuild is enabled by default. If you work with out-of-tree freestanding applications, you need to manually pass the --sysbuild parameter to every build command or configure west to always use it.

Testing

After programming the sample to your development kit, complete the following steps to test it:

  1. 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.

  2. Connect to the kit with a terminal emulator (for example, nRF Connect Serial Terminal). See Testing and optimization for the required settings and steps.

  3. Power on or reset your nRF91 Series DK.

  4. Observe that the sample starts and connects to the LTE network, while displaying both the network registration status and signal quality during the process.

  5. Observe that the sample displays the PSM status twice on the terminal, once when it is disabled, and once when it is enabled.

  6. Observe that the sample completes with a message on the terminal.

Sample Output

The sample shows the following output:

AT Monitor sample started
Subscribing to notifications
Connecting to network
Resuming link quality monitor for AT notifications
Waiting for network
Link quality: -61 dBm
Network registration status: searching
Link quality: -59 dBm
Network registration status: home
Network connection ready
Pausing link quality monitor for AT notifications
Reading PSM info...
  PSM: disabled
Enabling PSM
Reading PSM info...
  PSM: enabled
Periodic TAU string: 00000110
Active time string: 00100001
Modem response:
+CEREG: 1,1
OK
Shutting down modem
Network registration status: no network
Bye

Dependencies

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: