Cloud module

Asset Tracker Template

tags
Asset Tracker Template

This module connects and manages communication with nRF Cloud over CoAP using nRF Cloud CoAP library in nRF Connect SDK. It controls the cloud connection, sends data to nRF Cloud, and processes incoming data such as device shadow document. The cloud module uses Zephyr’s state machine framework (SMF) and zbus for messaging with other modules.

The module performs the following tasks:

  • Establishing and maintaining a connection to nRF Cloud, using CoAP with DTLS connection ID for secure and low-power communication.
  • Managing backoff and retries when connecting to the cloud. See the Configurations section for more details on how to configure backoff behavior.
  • Publishing sensor data (temperature, pressure, battery, location, and so on) to nRF Cloud. Data reaches the cloud module through the Storage module batch interface on storage_chan and storage_data_chan.
  • Requesting and handling shadow updates. Polling the device shadow is triggered by the main module by sending CLOUD_SHADOW_GET_DESIRED or CLOUD_SHADOW_GET_DELTA messages.
  • Handling network events and transitioning between connection states as described in the State diagram section.

nRF Cloud over CoAP utilizes DTLS connection ID, which allows the device to quickly re-establish a secure connection with the cloud after a network disconnection without the need for a full DTLS handshake. The module uses the nRF Cloud CoAP library to handle the CoAP communication and DTLS connection management.

The following sections cover the module’s main messages, configurations, and state machine. Refer to the source files (cloud.c, cloud.h, and Kconfig.cloud) for implementation details.