Cloud wrapper API
The cloud wrapper API is a generic API used for controlling the connection to a supported nRF Connect SDK client library through Integration layers.
It exposes generic functions such as send
, connect
, and disconnect
, hiding the functionality that is specific to a single client library implementation.
Integration layers
The Integration layers table lists the nRF Connect SDK client libraries that are supported by the cloud wrapper API and the associated integration layers.
Each integration layer interacts with a specific client library and contains the code required to properly set up and maintain a connection to the designated cloud service.
Based on the Kconfig options listed in the table, the corresponding integration layer + client library combination is linked in.
For example, if CONFIG_AWS_IOT
is enabled, CMake links in the asset_tracker_v2/src/cloud/aws_iot_integration.c
file that integrates the AWS IoT library.
This takes place in the asset_tracker_v2/src/cloud/CMakeLists.txt
file.
Note
The various integration layers all share a common header file asset_tracker_v2/src/cloud/cloud_wrapper.h
that exposes generic functions to send and receive data from the integration layer.
Client library |
Integration layer |
Kconfig option |
---|---|---|
|
||
|
||
|
Data addressing
Each integration layer routes data to specific endpoints based on the content of the data and the cloud wapper API call. The Data routing tables list the endpoints that are used in each cloud service implementation.
AWS IoT topics
Device-to-Cloud
Data |
Topic |
---|---|
A-GPS requests |
|
P-GPS requests |
|
Neighbor cell measurements |
|
Button presses |
|
Sensor/device data |
|
Device configuration |
|
Buffered sensor/device data |
|
Cloud-to-Device
Data |
Topic |
---|---|
A-GPS response |
|
P-GPS response |
|
Device configuration updates |
|
|
|
|
Azure IoT Hub topics
For simplicity, the following table omits certain metavalues present in topics and property bags used in Azure IoT Hub. For more information on MQTT topics and property bags in Azure IoT Hub, refer to the Azure IoT Hub MQTT protocol support documentation.
Device-to-Cloud
Data |
Topic |
Property bag |
---|---|---|
A-GPS requests |
|
|
P-GPS requests |
|
|
Neighbor cell measurements |
|
|
Button presses |
|
NA |
Sensor/device data |
|
NA |
Device configuration |
|
NA |
Buffered sensor/device data |
|
|
Cloud-to-Device
Data |
Topic |
Property bag |
---|---|---|
A-GPS response |
|
|
P-GPS response |
|
|
Device configuration updates |
|
NA |
nRF Cloud topics
For more information on topics used in the nRF Cloud connection, refer to the nRF Cloud MQTT API documentation.
Device-to-Cloud
Data |
AWS IoT topic |
---|---|
A-GPS requests |
|
P-GPS requests |
|
Neighbor cell measurements |
|
Button presses |
|
Sensor/device data |
|
Device configuration |
|
Buffered sensor/device data |
|
Cloud-to-Device
Data |
AWS IoT topic |
---|---|
A-GPS response |
|
P-GPS response |
|
Device configuration updates |
|
|
|
|
Dependencies
This module uses the following nRF Connect SDK libraries and drivers:
API documentation
asset_tracker_v2/src/cloud/cloud_wrapper.h
asset_tracker_v2/src/cloud/nrf_cloud_integration.c
asset_tracker_v2/src/cloud/aws_iot_integration.c
asset_tracker_v2/src/cloud/azure_iot_hub_integration.c
- group cloud_wrapper
A Library that exposes generic functionality of cloud integration layers.
Typedefs
-
typedef void (*cloud_wrap_evt_handler_t)(const struct cloud_wrap_event *evt)
Cloud wrapper library asynchronous event handler.
- Param evt
[in] Pointer to the event structure.
Enums
-
enum cloud_wrap_event_type
Event types notified by the cloud wrapper API.
Values:
-
enumerator CLOUD_WRAP_EVT_CONNECTING
Cloud integration layer is connecting.
-
enumerator CLOUD_WRAP_EVT_CONNECTED
Cloud integration layer is connected.
-
enumerator CLOUD_WRAP_EVT_DISCONNECTED
Cloud integration layer is disconnected.
-
enumerator CLOUD_WRAP_EVT_DATA_RECEIVED
Data received from cloud integration layer. Payload is of type cloud_wrap_event_data.
-
enumerator CLOUD_WRAP_EVT_USER_ASSOCIATION_REQUEST
User association request received from cloud.
-
enumerator CLOUD_WRAP_EVT_USER_ASSOCIATED
User association completed.
-
enumerator CLOUD_WRAP_EVT_AGPS_DATA_RECEIVED
A-GPS data received from the cloud integration layer. Payload is of type cloud_wrap_event_data.
-
enumerator CLOUD_WRAP_EVT_PGPS_DATA_RECEIVED
P-GPS data received from the cloud integration layer. Payload is of type cloud_wrap_event_data.
-
enumerator CLOUD_WRAP_EVT_FOTA_DONE
Cloud integration layer has successfully performed a FOTA update. Device should now be rebooted.
-
enumerator CLOUD_WRAP_EVT_FOTA_START
The cloud integration layer has started a FOTA update.
-
enumerator CLOUD_WRAP_EVT_FOTA_ERASE_PENDING
An image erase is pending.
-
enumerator CLOUD_WRAP_EVT_FOTA_ERASE_DONE
Image erase done.
-
enumerator CLOUD_WRAP_EVT_FOTA_ERROR
An error occurred during FOTA.
-
enumerator CLOUD_WRAP_EVT_ERROR
An irrecoverable error has occurred in the integration layer. Error details are attached in the event structure.
-
enumerator CLOUD_WRAP_EVT_CONNECTING
Functions
-
int cloud_wrap_init(cloud_wrap_evt_handler_t event_handler)
Setup and initialize the configured cloud integration layer.
- Returns
0 on success, or a negative error code on failure.
-
int cloud_wrap_connect(void)
Connect to cloud.
- Returns
0 on success, or a negative error code on failure.
-
int cloud_wrap_disconnect(void)
Disconnect from cloud.
- Returns
0 on success, or a negative error code on failure.
-
int cloud_wrap_state_get(void)
Request device state from cloud. The device state contains the device configuration.
- Returns
0 on success, or a negative error code on failure.
-
int cloud_wrap_state_send(char *buf, size_t len)
Send device state data to cloud.
- Parameters
buf – [in] Pointer to buffer containing data to be sent.
len – [in] Length of buffer.
- Returns
0 on success, or a negative error code on failure.
-
int cloud_wrap_data_send(char *buf, size_t len)
Send data to cloud.
- Parameters
buf – [in] Pointer to buffer containing data to be sent.
len – [in] Length of buffer.
- Returns
0 on success, or a negative error code on failure.
-
int cloud_wrap_batch_send(char *buf, size_t len)
Send batched data to cloud.
- Parameters
buf – [in] Pointer to buffer containing data to be sent.
len – [in] Length of buffer.
- Returns
0 on success, or a negative error code on failure.
-
int cloud_wrap_ui_send(char *buf, size_t len)
Send UI data to cloud.
- Parameters
buf – [in] Pointer to buffer containing data to be sent.
len – [in] Length of buffer.
- Returns
0 on success, or a negative error code on failure.
-
int cloud_wrap_neighbor_cells_send(char *buf, size_t len)
Send neighbor cell data to cloud.
- Parameters
buf – [in] Pointer to buffer containing data to be sent.
len – [in] Length of buffer.
- Returns
0 on success, or a negative error code on failure.
-
int cloud_wrap_agps_request_send(char *buf, size_t len)
Send A-GPS request to cloud.
- Parameters
buf – [in] Pointer to buffer containing data to be sent.
len – [in] Length of buffer.
- Returns
0 on success, or a negative error code on failure.
-
int cloud_wrap_pgps_request_send(char *buf, size_t len)
Send P-GPS request to cloud.
- Parameters
buf – [in] Pointer to buffer containing data to be sent.
len – [in] Length of buffer.
- Returns
0 on success, or a negative error code on failure.
-
int cloud_wrap_memfault_data_send(char *buf, size_t len)
Send Memfault data to cloud.
- Parameters
buf – [in] Pointer to buffer containing data to be sent.
len – [in] Length of buffer.
- Returns
0 on success, or a negative error code on failure.
-
struct cloud_wrap_event_data
- #include <cloud_wrapper.h>
Structure used to referance application data that is sent and received from the cloud wrapper library.
-
struct cloud_wrap_event
- #include <cloud_wrapper.h>
Cloud wrapper API event.
Public Members
-
struct cloud_wrap_event_data data
Structured that contains data received from the cloud integration layer.
-
int err
Error code signifying the cause of error.
-
struct cloud_wrap_event_data data
-
typedef void (*cloud_wrap_evt_handler_t)(const struct cloud_wrap_event *evt)