Azure IoT middleware for FreeRTOS
azure_iot_adu_client.h
Go to the documentation of this file.
1 
7 #ifndef AZURE_IOT_ADU_CLIENT_H
8 #define AZURE_IOT_ADU_CLIENT_H
9 
10 #include <stdint.h>
11 
12 #include "azure_iot_result.h"
13 #include "azure_iot_hub_client.h"
14 #include "azure_iot_json_reader.h"
15 #include <azure/iot/az_iot_adu_client.h>
16 
22 extern const uint8_t * AzureIoTADUModelID;
23 
27 extern const uint32_t AzureIoTADUModelIDLength;
28 
35 {
36  uint8_t * pucPropertyNames[ _az_IOT_ADU_CLIENT_MAX_DEVICE_CUSTOM_PROPERTIES ];
37  uint32_t ulPropertyNamesLengths[ _az_IOT_ADU_CLIENT_MAX_DEVICE_CUSTOM_PROPERTIES ];
38  uint8_t * pucPropertyValues[ _az_IOT_ADU_CLIENT_MAX_DEVICE_CUSTOM_PROPERTIES ];
39  uint32_t ulPropertyValuesLengths[ _az_IOT_ADU_CLIENT_MAX_DEVICE_CUSTOM_PROPERTIES ];
40  uint32_t ulPropertyCount;
41 
42  struct
43  {
44  az_iot_adu_device_custom_properties xCustomProperties;
45  } _internal;
47 
56 {
57  const uint8_t * ucManufacturer;
58  uint32_t ulManufacturerLength;
59 
60  const uint8_t * ucModel;
61  uint32_t ulModelLength;
62 
63  AzureIoTADUDeviceCustomProperties_t * pxCustomProperties;
64 
65  const uint8_t * ucCurrentUpdateId;
66  uint32_t ulCurrentUpdateIdLength;
67 
68  const uint8_t * ucDeliveryOptimizationAgentVersion;
69  uint32_t ulDeliveryOptimizationAgentVersionLength;
71 
76 typedef enum AzureIoTADUAction
77 {
78  eAzureIoTADUActionApplyDownload = 3,
79  eAzureIoTADUActionCancel = 255
81 
94 {
95  AzureIoTADUAction_t xAction;
96 
97  const uint8_t * pucID;
98  uint32_t ulIDLength;
99 
100  const uint8_t * pucRetryTimestamp;
101  uint32_t ulRetryTimestampLength;
103 
109 {
110  uint32_t ulResultCode;
111  uint32_t ulExtendedResultCode;
112 
113  const uint8_t * pucResultDetails;
114  uint32_t ulResultDetailsLength;
116 
122 {
123  int32_t lResultCode;
124  int32_t lExtendedResultCode;
125 
126  const uint8_t * pucResultDetails;
127  uint32_t ulResultDetailsLength;
128 
129  AzureIoTADUClientStepResult_t pxStepResults[ _az_IOT_ADU_CLIENT_MAX_INSTRUCTIONS_STEPS ];
130  uint32_t ulStepResultsCount;
132 
141 {
142  eAzureIoTADUAgentStateIdle = 0,
143  eAzureIoTADUAgentStateDeploymentInProgress = 6,
144  eAzureIoTADUAgentStateFailed = 255,
145  eAzureIoTADUAgentStateError,
147 
153 {
154  eAzureIoTADURequestDecisionAccept,
155  eAzureIoTADURequestDecisionReject
157 
163 {
164  uint8_t * pucId;
165  uint32_t ulIdLength;
166  uint8_t * pucUrl;
167  uint32_t ulUrlLength;
169 
176 typedef struct AzureIoTADUUpdateId
177 {
178  uint8_t * pucProvider;
179  uint32_t ulProviderLength;
180  uint8_t * pucName;
181  uint32_t ulNameLength;
182  uint8_t * pucVersion;
183  uint32_t ulVersionLength;
185 
191 {
192  uint8_t * pucFileName;
193  uint32_t ulFileNameLength;
195 
201 {
202  uint8_t * pucId;
203  uint32_t ulIdLength;
204  uint8_t * pucHash;
205  uint32_t ulHashLength;
207 
213 {
214  uint8_t * pucId;
215  uint32_t ulIdLength;
216  uint8_t * pucFileName;
217  uint32_t ulFileNameLength;
218  int64_t llSizeInBytes;
219  uint32_t ulHashesCount;
220  AzureIoTADUUpdateManifestFileHash_t pxHashes[ _az_IOT_ADU_CLIENT_MAX_FILE_HASH_COUNT ];
222 
228 {
229  uint8_t * pucHandler;
230  uint32_t ulHandlerLength;
231  uint8_t * pucInstalledCriteria;
232  uint32_t ulInstalledCriteriaLength;
233  uint32_t ulFilesCount;
234  AzureIoTADUUpdateManifestInstructionStepFile_t pxFiles[ _az_IOT_ADU_CLIENT_MAX_FILE_COUNT_PER_STEP ];
236 
241 {
242  uint32_t ulStepsCount;
243  AzureIoTADUInstructionStep_t pxSteps[ _az_IOT_ADU_CLIENT_MAX_INSTRUCTIONS_STEPS ];
245 
251 {
252  AzureIoTADUUpdateId_t xUpdateId;
253  AzureIoTADUInstructions_t xInstructions;
254  uint32_t ulFilesCount;
255  AzureIoTADUUpdateManifestFile_t pxFiles[ _az_IOT_ADU_CLIENT_MAX_TOTAL_FILE_COUNT ];
256  uint8_t * pucManifestVersion;
257  uint32_t ulManifestVersionLength;
258  uint8_t * pucCreateDateTime;
259  uint32_t ulCreateDateTimeLength;
261 
268 {
269  AzureIoTADUClientWorkflow_t xWorkflow;
270  uint8_t * pucUpdateManifest;
271  uint32_t ulUpdateManifestLength;
272  uint8_t * pucUpdateManifestSignature;
273  uint32_t ulUpdateManifestSignatureLength;
274  uint32_t ulFileUrlCount;
275  AzureIoTADUUpdateManifestFileUrl_t pxFileUrls[ _az_IOT_ADU_CLIENT_MAX_TOTAL_FILE_COUNT ];
276  AzureIoTADUUpdateManifest_t xUpdateManifest;
278 
283 {
284  const uint8_t * pucCompatibilityProperties;
285  uint32_t ulCompatibilityPropertiesLength;
286 }
288 
292 typedef struct AzureIoTADUClient
293 {
294  struct
295  {
296  az_iot_adu_client xADUClient;
299 
307 
316  AzureIoTADUClientOptions_t * pxADUClientOptions );
317 
325 
340  const uint8_t * pucComponentName,
341  uint32_t ulComponentNameLength );
342 
355  AzureIoTJSONReader_t * pxReader,
356  AzureIoTADUUpdateRequest_t * pxAduUpdateRequest );
357 
380  AzureIoTHubClient_t * pxAzureIoTHubClient,
381  AzureIoTADURequestDecision_t xRequestDecision,
382  uint32_t ulPropertyVersion,
383  uint8_t * pucWritablePropertyResponseBuffer,
384  uint32_t ulWritablePropertyResponseBufferSize,
385  uint32_t * pulRequestId );
386 
404  AzureIoTHubClient_t * pxAzureIoTHubClient,
405  AzureIoTADUClientDeviceProperties_t * pxDeviceProperties,
406  AzureIoTADUUpdateRequest_t * pxAduUpdateRequest,
407  AzureIoTADUAgentState_t xAgentState,
408  AzureIoTADUClientInstallResult_t * pxUpdateResults,
409  uint8_t * pucBuffer,
410  uint32_t ulBufferSize,
411  uint32_t * pulRequestId );
412 
413 
414 #endif /* AZURE_IOT_ADU_CLIENT_H */
struct AzureIoTADUInstructionStepFile AzureIoTADUUpdateManifestInstructionStepFile_t
The name of a file referenced in the update manifest.
enum AzureIoTADUAgentState AzureIoTADUAgentState_t
States of the ADU agent.
AzureIoTResult_t AzureIoTADUClient_DevicePropertiesInit(AzureIoTADUClientDeviceProperties_t *pxADUDeviceProperties)
Initialize the Azure IoT Device Properties with default values.
struct AzureIoTADUClientOptions AzureIoTADUClientOptions_t
User-defined options for the Azure IoT ADU client.
AzureIoTResult_t AzureIoTADUClient_SendAgentState(AzureIoTADUClient_t *pxAzureIoTADUClient, AzureIoTHubClient_t *pxAzureIoTHubClient, AzureIoTADUClientDeviceProperties_t *pxDeviceProperties, AzureIoTADUUpdateRequest_t *pxAduUpdateRequest, AzureIoTADUAgentState_t xAgentState, AzureIoTADUClientInstallResult_t *pxUpdateResults, uint8_t *pucBuffer, uint32_t ulBufferSize, uint32_t *pulRequestId)
Sends the current state of the Azure IoT ADU agent.
AzureIoTResult_t AzureIoTADUClient_OptionsInit(AzureIoTADUClientOptions_t *pxADUClientOptions)
Initialize the Azure IoT ADU Options with default values.
struct AzureIoTADUUpdateManifestFileHash AzureIoTADUUpdateManifestFileHash_t
Hash value of a given file.
AzureIoTResult_t AzureIoTADUClient_SendResponse(AzureIoTADUClient_t *pxAzureIoTADUClient, AzureIoTHubClient_t *pxAzureIoTHubClient, AzureIoTADURequestDecision_t xRequestDecision, uint32_t ulPropertyVersion, uint8_t *pucWritablePropertyResponseBuffer, uint32_t ulWritablePropertyResponseBufferSize, uint32_t *pulRequestId)
Updates the ADU Agent Client with ADU service device update properties.
struct AzureIoTADUUpdateRequest AzureIoTADUUpdateRequest_t
Structure that holds the parsed contents of the ADU request in the Plug and Play writable properties ...
struct AzureIoTADUUpdateId AzureIoTADUUpdateId_t
Identity of the update request.
const uint32_t AzureIoTADUModelIDLength
The length of AzureIoTADUModelID.
AzureIoTADUAction
Actions requested by the ADU Service.
Definition: azure_iot_adu_client.h:77
AzureIoTADURequestDecision
Decision values for accepting an update request or not.
Definition: azure_iot_adu_client.h:153
bool AzureIoTADUClient_IsADUComponent(AzureIoTADUClient_t *pxAzureIoTADUClient, const uint8_t *pucComponentName, uint32_t ulComponentNameLength)
Returns whether the component is the ADU component.
struct AzureIoTADUInstructions AzureIoTADUInstructions_t
Instructions in the update manifest.
struct AzureIoTADUClientDeviceProperties AzureIoTADUClientDeviceProperties_t
ADU Device Properties.
AzureIoTResult_t AzureIoTADUClient_ParseRequest(AzureIoTADUClient_t *pxAzureIoTADUClient, AzureIoTJSONReader_t *pxReader, AzureIoTADUUpdateRequest_t *pxAduUpdateRequest)
Parse the ADU update request into the requisite structure.
enum AzureIoTADUAction AzureIoTADUAction_t
Actions requested by the ADU Service.
struct AzureIoTADUUpdateManifestFileUrl AzureIoTADUUpdateManifestFileUrl_t
A map of file ID to download url.
AzureIoTResult_t AzureIoTADUClient_Init(AzureIoTADUClient_t *pxAzureIoTADUClient, AzureIoTADUClientOptions_t *pxADUClientOptions)
Initialize the Azure IoT ADU Client.
enum AzureIoTADURequestDecision AzureIoTADURequestDecision_t
Decision values for accepting an update request or not.
struct AzureIoTADUClientWorkflow AzureIoTADUClientWorkflow_t
ADU workflow struct.
struct AzureIoTADUDeviceCustomProperties AzureIoTADUDeviceCustomProperties_t
Holds any user-defined custom properties of the device.
struct AzureIoTADUClientStepResult AzureIoTADUClientStepResult_t
The update step result reported by the agent.
struct AzureIoTADUInstructionStep AzureIoTADUInstructionStep_t
A step in the instructions of an ADU update manifest.
struct AzureIoTADUClientInstallResult AzureIoTADUClientInstallResult_t
The update result reported by the agent.
struct AzureIoTADUUpdateManifest AzureIoTADUUpdateManifest_t
Structure that holds the parsed contents of the update manifest sent by the ADU service.
AzureIoTADUAgentState
States of the ADU agent.
Definition: azure_iot_adu_client.h:141
struct AzureIoTADUUpdateManifestFile AzureIoTADUUpdateManifestFile_t
Details of a file referenced in the update request.
struct AzureIoTADUClient AzureIoTADUClient_t
Azure IoT ADU Client (ADU agent) to handle stages of the ADU process.
const uint8_t * AzureIoTADUModelID
The DTMI specifying the capabilities for the Azure Device Update client.
The middleware IoT Hub Client used to connect a device to Azure IoT Hub.
The JSON reader used by the middleware for PnP properties.
Azure IoT FreeRTOS middleware result values.
enum AzureIoTResult AzureIoTResult_t
The results used by the middleware.
ADU Device Properties.
Definition: azure_iot_adu_client.h:56
Azure IoT ADU Client (ADU agent) to handle stages of the ADU process.
Definition: azure_iot_adu_client.h:293
struct AzureIoTADUClient::@1 _internal
The update result reported by the agent.
Definition: azure_iot_adu_client.h:122
User-defined options for the Azure IoT ADU client.
Definition: azure_iot_adu_client.h:283
The update step result reported by the agent.
Definition: azure_iot_adu_client.h:109
ADU workflow struct.
Definition: azure_iot_adu_client.h:94
Holds any user-defined custom properties of the device.
Definition: azure_iot_adu_client.h:35
The name of a file referenced in the update manifest.
Definition: azure_iot_adu_client.h:191
A step in the instructions of an ADU update manifest.
Definition: azure_iot_adu_client.h:228
Instructions in the update manifest.
Definition: azure_iot_adu_client.h:241
Identity of the update request.
Definition: azure_iot_adu_client.h:177
Hash value of a given file.
Definition: azure_iot_adu_client.h:201
Details of a file referenced in the update request.
Definition: azure_iot_adu_client.h:213
A map of file ID to download url.
Definition: azure_iot_adu_client.h:163
Structure that holds the parsed contents of the update manifest sent by the ADU service.
Definition: azure_iot_adu_client.h:251
Structure that holds the parsed contents of the ADU request in the Plug and Play writable properties ...
Definition: azure_iot_adu_client.h:268
Azure IoT Hub Client used to manage connections and features for Azure IoT Hub.
The struct to use for Azure IoT JSON reader functionality.
Definition: azure_iot_json_reader.h:50