The middleware IoT Hub Client property functions used for Azure IoT Plug and Play.
More...
|
AzureIoTResult_t | AzureIoTHubClientProperties_BuilderBeginComponent (AzureIoTHubClient_t *pxAzureIoTHubClient, AzureIoTJSONWriter_t *pxJSONWriter, const uint8_t *pucComponentName, uint16_t usComponentNameLength) |
| Append the necessary characters to a reported properties JSON payload belonging to a component. More...
|
|
AzureIoTResult_t | AzureIoTHubClientProperties_BuilderEndComponent (AzureIoTHubClient_t *pxAzureIoTHubClient, AzureIoTJSONWriter_t *pxJSONWriter) |
| Append the necessary characters to end a reported properties JSON payload belonging to a component. More...
|
|
AzureIoTResult_t | AzureIoTHubClientProperties_BuilderBeginResponseStatus (AzureIoTHubClient_t *pxAzureIoTHubClient, AzureIoTJSONWriter_t *pxJSONWriter, const uint8_t *pucPropertyName, uint16_t usPropertyNameLength, int32_t lAckCode, int32_t lAckVersion, const uint8_t *pucAckDescription, uint16_t usAckDescriptionLength) |
| Begin a property response to a writable property request from the service. More...
|
|
AzureIoTResult_t | AzureIoTHubClientProperties_BuilderEndResponseStatus (AzureIoTHubClient_t *pxAzureIoTHubClient, AzureIoTJSONWriter_t *pxJSONWriter) |
| End a properties response payload with confirmation status. More...
|
|
AzureIoTResult_t | AzureIoTHubClientProperties_GetPropertiesVersion (AzureIoTHubClient_t *pxAzureIoTHubClient, AzureIoTJSONReader_t *pxJSONReader, AzureIoTHubMessageType_t xResponseType, uint32_t *pulVersion) |
| Read the Azure IoT Plug and Play property version. More...
|
|
AzureIoTResult_t | AzureIoTHubClientProperties_GetNextComponentProperty (AzureIoTHubClient_t *pxAzureIoTHubClient, AzureIoTJSONReader_t *pxJSONReader, AzureIoTHubMessageType_t xResponseType, AzureIoTHubClientPropertyType_t xPropertyType, const uint8_t **ppucComponentName, uint32_t *pulComponentNameLength) |
| Iteratively read the Azure IoT Plug and Play component properties. More...
|
|
The middleware IoT Hub Client property functions used for Azure IoT Plug and Play.
- Note
- You MUST NOT use any symbols (macros, functions, structures, enums, etc.) prefixed with an underscore ('_') directly in your application code. These symbols are part of Azure SDK's internal implementation; we do not document these symbols and they are subject to change in future versions of the SDK which would break your code.
AzureIoTResult_t AzureIoTHubClientProperties_BuilderBeginResponseStatus |
( |
AzureIoTHubClient_t * |
pxAzureIoTHubClient, |
|
|
AzureIoTJSONWriter_t * |
pxJSONWriter, |
|
|
const uint8_t * |
pucPropertyName, |
|
|
uint16_t |
usPropertyNameLength, |
|
|
int32_t |
lAckCode, |
|
|
int32_t |
lAckVersion, |
|
|
const uint8_t * |
pucAckDescription, |
|
|
uint16_t |
usAckDescriptionLength |
|
) |
| |
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/en-us/azure/iot-pnp/concepts-convention#writable-properties
The payload will be of the form:
Without component
{
"<pucPropertyName>":{
"ac": <lAckCode>,
"av": <lAckVersion>,
"ad": "<pucAckDescription>",
"value": <user_value>
}
}
With component
{
"<pucComponentName>": {
"__t": "c",
"<pucPropertyName>": {
"ac": <lAckCode>,
"av": <lAckVersion>,
"ad": "<pucAckDescription>",
"value": <user_value>
}
}
}
To send a status for properties belonging to a component, first call the AzureIoTHubClientProperties_BuilderBeginComponent() 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.
AzureIoTResult_t AzureIoTHubClientProperties_BuilderEndResponseStatus(AzureIoTHubClient_t *pxAzureIoTHubClient, AzureIoTJSONWriter_t *pxJSONWriter)
End a properties response payload with confirmation status.
AzureIoTResult_t AzureIoTHubClientProperties_BuilderBeginResponseStatus(AzureIoTHubClient_t *pxAzureIoTHubClient, AzureIoTJSONWriter_t *pxJSONWriter, const uint8_t *pucPropertyName, uint16_t usPropertyNameLength, int32_t lAckCode, int32_t lAckVersion, const uint8_t *pucAckDescription, uint16_t usAckDescriptionLength)
Begin a property response to a writable property request from the service.
AzureIoTResult_t AzureIoTHubClientProperties_BuilderBeginComponent(AzureIoTHubClient_t *pxAzureIoTHubClient, AzureIoTJSONWriter_t *pxJSONWriter, const uint8_t *pucComponentName, uint16_t usComponentNameLength)
Append the necessary characters to a reported properties JSON payload belonging to a component.
AzureIoTResult_t AzureIoTHubClientProperties_BuilderEndComponent(AzureIoTHubClient_t *pxAzureIoTHubClient, AzureIoTJSONWriter_t *pxJSONWriter)
Append the necessary characters to end a reported properties JSON payload belonging to a component.
- Note
- This API only builds the metadata for the properties response. The application itself must specify the payload contents between calls to this API and AzureIoTHubClientProperties_BuilderEndResponseStatus() using
pxJSONWriter
to specify the JSON payload.
- Parameters
-
[in] | pxAzureIoTHubClient | The AzureIoTHubClient_t to use for this call. |
[in,out] | pxJSONWriter | The initialized AzureIoTJSONWriter_t to append data to. |
[in] | pucPropertyName | The name of the property to build a response payload for. |
[in] | usPropertyNameLength | The length of pucPropertyName . |
[in] | lAckCode | The HTTP-like status code to respond with. See AzureIoTHubMessageStatus_t for possible supported values. |
[in] | lAckVersion | 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] | pucAckDescription | An optional description detailing the context or any details about the acknowledgement. This can be NULL . |
[in] | usAckDescriptionLength | The length of pucAckDescription . |
- Precondition
pxAzureIoTHubClient
must not be NULL
.
-
pxJSONWriter
must not be NULL
.
-
pucPropertyName
must not be NULL
.
- Returns
- An AzureIoTResult_t value indicating the result of the operation.
- Return values
-
eAzureIoTSuccess | The JSON payload was prefixed successfully. |
Iteratively read the Azure IoT Plug and Play component properties.
- Note
- If you are creating a multi-component application, component names must first be registered via the
pxHubClientOptions->pxComponentList
and pxHubClientOptions->ulComponentListLength
in AzureIoTHubClient_Init().
Note that between calls, the uint8_t* pointed to by ppucComponentName
shall not be modified, only checked and compared. Internally, the pointer 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 pxJSONReader
will be set on a valid property name. After checking the property name, the reader can be advanced to the property value by calling AzureIoTJSONReader_NextToken(). 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 AzureIoTJSONReader_NextToken().
Below is a code snippet which you can use as a starting point:
&xHubClient, &jr, xResponseType, AZ_IOT_HUB_CLIENT_PROPERTY_WRITABLE, &pucComponentName, &pusComponentNameLength)))
{
{
}
else
{
}
}
AzureIoTResult_t AzureIoTHubClientProperties_GetNextComponentProperty(AzureIoTHubClient_t *pxAzureIoTHubClient, AzureIoTJSONReader_t *pxJSONReader, AzureIoTHubMessageType_t xResponseType, AzureIoTHubClientPropertyType_t xPropertyType, const uint8_t **ppucComponentName, uint32_t *pulComponentNameLength)
Iteratively read the Azure IoT Plug and Play component properties.
AzureIoTResult_t AzureIoTJSONReader_SkipChildren(AzureIoTJSONReader_t *pxReader)
Reads and skips over any nested JSON elements.
AzureIoTResult_t AzureIoTJSONReader_NextToken(AzureIoTJSONReader_t *pxReader)
Reads the next token in the JSON text and updates the reader state.
bool AzureIoTJSONReader_TokenIsTextEqual(AzureIoTJSONReader_t *pxReader, const uint8_t *pucExpectedText, uint32_t ulExpectedTextLength)
Determines whether the unescaped JSON token value that the AzureIoTJSONReader_t points to is equal to...
- Warning
- If you need to retrieve more than one
xPropertyType
, you should first complete the scan of all components for the first property type (until the API returns eAzureIoTErrorEndOfProperties). Then you must call AzureIoTJSONReader_Init() again after this call and before the next call to AzureIoTHubClientProperties_GetNextComponentProperty
with the different xPropertyType
.
- Parameters
-
[in] | pxAzureIoTHubClient | The AzureIoTHubClient_t to use for this call. |
[in,out] | pxJSONReader | The AzureIoTJSONReader_t to parse through. The ownership of iterating through this json reader is shared between the user and this API. |
[in] | xResponseType | The AzureIoTHubMessageType_t representing the message type associated with the payload. |
[in] | xPropertyType | The AzureIoTHubClientPropertyType_t to scan for. |
[out] | ppucComponentName | The output component name for the property returned. |
[out] | pulComponentNameLength | The length of the output ppucComponentName . |
- Precondition
pxAzureIoTHubClient
must not be NULL
.
-
pxJSONReader
must not be NULL
.
-
xResponseType
must be eAzureIoTHubPropertiesRequestedMessage or eAzureIoTHubPropertiesWritablePropertyMessage. If eAzureIoTHubClientReportedFromDevice is specified in xPropertyType
, then xResponseType
must be eAzureIoTHubPropertiesRequestedMessage.
-
ppucComponentName
must not be NULL
.
- Returns
- An AzureIoTResult_t value indicating the result of the operation.
- Return values
-
eAzureIoTSuccess | If the function returned a valid AzureIoTJSONReader_t pointing to the property name and the component name. |
eAzureIoTErrorFailed | If the json reader is passed in at an unexpected location. |
eAzureIoTErrorEndOfProperties | If there are no more properties left for the component. |