nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches

◆ nrf_cloud_obj_shadow_delta_response_encode()

int nrf_cloud_obj_shadow_delta_response_encode ( struct nrf_cloud_obj *const  delta_state_obj,
bool  accept 
)

#include <include/net/nrf_cloud_codec.h>

Encode the response to the shadow delta update.

A delta update occurs when the shadow's "desired" and "reported" sections do not match. The JSON for a delta update contains the actual delta data in a "state" object, along with some additional information. Example: {"version":123,"timestamp":1695404679, "state":{"myData":{"myValue":1}}, ...}

The application must inspect the delta and either accept or reject the changes.

If accepting, the delta should be passed unmodified into this function as the input_obj parameter, with the accept flag set to true. Example input_obj: "myData":{"myValue":1}

If rejecting, the delta should be modified with the correct data and passed into this function as the delta_state_obj parameter, with the accept flag set to false. Example input_obj: "myData":{"myValue":3}

A value can be removed from the shadow by setting it to null. Example input_obj: "myData":{"myValue":null} On success, the delta_state_obj parameter can be sent to nRF Cloud using nrf_cloud_coap_shadow_state_update() for CoAP or nrf_cloud_obj_shadow_update() for MQTT.

Parameters
[in]delta_state_objThe contents of the "state" object received in a shadow delta.
[in]acceptFlag to indicate whether to accept (place in reported section) or reject (place in desired section).