nRF9160: PDN

The PDN sample demonstrates how to create and configure a Packet Data Protocol (PDP) context, activate a Packet Data Network connection, and receive events on its state and connectivity using the PDN library.

Requirements

The sample supports the following development kit:

Hardware platforms

PCA

Board name

Build target

nRF9160 DK

PCA10090

nrf9160dk_nrf9160

nrf9160dk_nrf9160_ns

The sample is configured to compile and run as a non-secure application on nRF91’s Cortex-M33. Therefore, it automatically includes the Secure Partition Manager that prepares the required peripherals to be available for the application.

You can also configure it to use TF-M instead of Secure Partition Manager.

Overview

The sample first initializes the Modem library and registers to the Packet Domain Events notifications (using the AT+CGEREP=1 AT command) and notifications for unsolicited reporting of error codes sent by the network (using the AT+CNEC=16 AT command). Next, the sample initializes the PDN library and registers a callback for events pertaining to the default PDP context. This is done before changing the function mode to 1 (AT+CFUN=1) to receive the activation event for the default PDP context. The sample then creates a new PDP context and configures it to use the default APN, registers a callback for its events and activates the PDN connection. Finally, the sample prints the PDP context IDs and PDN IDs of both the default PDP context and the new PDP context that it has created.

Building and running

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

The sample is built as a non-secure firmware image for the nrf9160dk_nrf9160ns build target. Because of this, it automatically includes the Secure Partition Manager. You can also configure it to use TF-M instead of SPM.

See Building and programming an application for information about how to build and program the application.

Testing

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

  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, PuTTY). See How to connect with PuTTY for the required settings.

  3. Power on or reset your nRF9160 DK.

  4. Observe that the sample starts, creates and configures a PDP context, and then activates a PDN connection.

Sample output

The sample shows the following output, which may vary based on the network provider:

PDN sample started
Event: PDP context 0 activated
Created new PDP context 1
Default APN is telenor.iot
PDP context 1 configured: APN telenor.iot, Family IPV4V6
Event: PDP context 0 IPv6 up
Event: PDP context 1 activated
Event: PDP context 1 IPv6 up
PDP Context 0 (cid)      PDN ID 0
PDP Context 1 (cid)      PDN ID 0
Bye

Dependencies

This sample uses the following nRF Connect SDK libraries:

It uses the following sdk-nrfxlib library:

In addition, it uses the following sample: