nRF9160: nRF CoAP Client

The nRF CoAP Client sample demonstrates how to receive data from a public CoAP server with an nRF9160 SiP.

Overview

The sample connects to a public CoAP test server, sends periodic GET request for a test resource that is available on the server, and prints the data that is received.

Requirements

  • The following development board:

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

Building and running

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

The sample is built as a non-secure firmware image for the nrf9160_pca10090ns board. Because of this, it automatically includes the nRF9160: Secure Partition Manager.

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

Testing

After programming the sample and all prerequisites to the board, test it by performing the following steps:

  1. Connect the USB cable and power on or reset your nRF9160 DK.

  2. Open a terminal emulator and observe that the kit prints the following information:

    The nRF CoAP client sample started
    
  3. Observe that the kit sends periodic CoAP GET requests after it gets LTE connection. The kit sends requests to the configured server (CONFIG_COAP_SERVER_HOSTNAME) for a configured resource (CONFIG_COAP_RESOURCE).

  4. Observe that the kit either prints the reponse data received from the server or indicates a time-out.

Dependencies

This sample uses the following libraries:

From nRF Connect SDK
  • drivers/lte_link_control

From nrfxlib
From Zephyr

In addition, it uses the following samples:

From nRF Connect SDK