|
AZ_NODISCARD az_result | az_iot_hub_client_properties_writer_begin_component (az_iot_hub_client const *client, az_json_writer *ref_json_writer, az_span component_name) |
| Append the necessary characters to a reported properties JSON payload belonging to a component. More...
|
|
AZ_NODISCARD az_result | az_iot_hub_client_properties_writer_end_component (az_iot_hub_client const *client, az_json_writer *ref_json_writer) |
| Append the necessary characters to end a reported properties JSON payload belonging to a component. More...
|
|
AZ_NODISCARD az_result | az_iot_hub_client_properties_writer_begin_response_status (az_iot_hub_client const *client, az_json_writer *ref_json_writer, az_span property_name, int32_t status_code, int32_t version, az_span description) |
| Begin a property response to a writable property request from the service. More...
|
|
AZ_NODISCARD az_result | az_iot_hub_client_properties_writer_end_response_status (az_iot_hub_client const *client, az_json_writer *ref_json_writer) |
| End a properties response payload with confirmation status. More...
|
|
AZ_NODISCARD az_result | az_iot_hub_client_properties_get_properties_version (az_iot_hub_client const *client, az_json_reader *ref_json_reader, az_iot_hub_client_properties_message_type message_type, int32_t *out_version) |
| Read the IoT Plug and Play property version. More...
|
|
AZ_NODISCARD az_result | az_iot_hub_client_properties_get_next_component_property (az_iot_hub_client const *client, az_json_reader *ref_json_reader, az_iot_hub_client_properties_message_type message_type, az_iot_hub_client_property_type property_type, az_span *out_component_name) |
| Iteratively read the IoT Plug and Play component properties. More...
|
|
Definition for the IoT Plug and Play properties writer and parsing routines.
Iteratively read the IoT Plug and Play component properties.
Note that between calls, the az_span pointed to by out_component_name
shall not be modified, only checked and compared. Internally, the az_span is only changed if the component name changes in the JSON document and is not necessarily set every invocation of the function.
On success, the ref_json_reader
will be set on a valid property name. After checking the property name, the reader can be advanced to the property value by calling az_json_reader_next_token(). Note that on the subsequent call to this API, it is expected that the json reader will be placed AFTER the read property name and value. That means that after reading the property value (including single values or complex objects), the user must call az_json_reader_next_token().
Below is a code snippet which you can use as a starting point:
- Warning
- If you need to retrieve more than one
property_type
, you should first complete the scan of all components for the first property type (until the API returns AZ_ERROR_IOT_END_OF_PROPERTIES). Then you must call az_json_reader_init() again after this call and before the next call to az_iot_hub_client_properties_get_next_component_property with the different property_type
.
- Parameters
-
- Precondition
client
must not be NULL
.
-
ref_json_reader
must not be NULL
.
-
out_component_name
must not be NULL
. It must point to an az_span instance.
-
message_type
must be AZ_IOT_HUB_CLIENT_PROPERTIES_MESSAGE_TYPE_WRITABLE_UPDATED
or AZ_IOT_HUB_CLIENT_PROPERTIES_MESSAGE_TYPE_GET_RESPONSE
.
-
property_type
must be AZ_IOT_HUB_CLIENT_PROPERTY_REPORTED_FROM_DEVICE
or AZ_IOT_HUB_CLIENT_PROPERTY_WRITABLE
.
-
If
AZ_IOT_HUB_CLIENT_PROPERTY_REPORTED_FROM_DEVICE
is specified in property_type
, then message_type
must be AZ_IOT_HUB_CLIENT_PROPERTIES_MESSAGE_TYPE_GET_RESPONSE
.
- Returns
- An az_result value indicating the result of the operation.
- Return values
-
Begin a property response to a writable property request from the service.
This API should be used in response to an incoming writable properties. More details can be found here:
https://docs.microsoft.com/azure/iot-pnp/concepts-convention#writable-properties
The payload will be of the form:
Without component
{
"<property_name>":{
"ac": <status_code>,
"av": <version>,
"ad": "<description>",
"value": <user_value>
}
}
With component
{
"<component_name>": {
"__t": "c",
"<property_name>": {
"ac": <status_code>,
"av": <version>,
"ad": "<description>",
"value": <user_value>
}
}
}
To send a status for properties belonging to a component, first call the az_iot_hub_client_properties_writer_begin_component() API to prefix the payload with the necessary identification. The API call flow would look like the following with the listed JSON payload being generated.
- Note
- This API only writes the metadata for the properties response. The application itself must specify the payload contents between calls to this API and az_iot_hub_client_properties_writer_end_response_status() using
ref_json_writer
to specify the JSON payload.
- Parameters
-
[in] | client | The az_iot_hub_client to use for this call. |
[in,out] | ref_json_writer | The initialized az_json_writer to append data to. |
[in] | property_name | The name of the property to write a response payload for. |
[in] | status_code | The HTTP-like status code to respond with. See az_iot_status for possible supported values. |
[in] | version | The version of the property the application is acknowledging. This can be retrieved from the service request by calling az_iot_hub_client_properties_get_properties_version. |
[in] | description | An optional description detailing the context or any details about the acknowledgement. This can be AZ_SPAN_EMPTY. |
- Precondition
client
must not be NULL
.
-
ref_json_writer
must not be NULL
.
-
property_name
must be a valid, non-empty az_span.
- Returns
- An az_result value indicating the result of the operation.
- Return values
-
AZ_OK | The JSON payload was prefixed successfully. |