Cloud module

Asset Tracker Template

tags
Asset Tracker Template

The Cloud module connects and manages communication with nRF Cloud over the Constrained Application Protocol (CoAP), using the nRF Cloud CoAP library in the nRF Connect SDK. It controls the cloud connection, sends data to nRF Cloud, and processes incoming data such as the 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 a Datagram Transport Layer Security (DTLS) connection ID for secure and low-power communication.
  • Managing backoff and retries when connecting to the cloud. For information about configuring the backoff behavior, see Configuration.
  • 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. The Main module triggers device shadow polling by sending CLOUD_SHADOW_GET_DESIRED or CLOUD_SHADOW_GET_DELTA messages.
  • Handling network events and transitioning between connection states, as described in State diagram.

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

The following sections cover the module's main messages, configuration options, and state machine. For implementation details, see the cloud.c, cloud.h, and Kconfig.cloud source files.