Azure SDK for Embedded C
az_iot_adu_client.h
Go to the documentation of this file.
1 // Copyright (c) Microsoft Corporation. All rights reserved.
2 // SPDX-License-Identifier: MIT
3 
19 #ifndef _az_IOT_ADU_H
20 #define _az_IOT_ADU_H
21 
22 #include <azure/core/az_json.h>
23 #include <azure/core/az_result.h>
24 #include <azure/core/az_span.h>
26 #include <azure/iot/internal/az_iot_adu_internal.h>
27 
28 #include <stdbool.h>
29 #include <stdint.h>
30 
31 #include <azure/core/_az_cfg_prefix.h>
32 
38 #define AZ_IOT_ADU_CLIENT_AGENT_MODEL_ID "dtmi:azure:iot:deviceUpdateContractModel;2"
39 
43 #define AZ_IOT_ADU_CLIENT_AGENT_VERSION "DU;agent/1.0.0"
44 
48 #define AZ_IOT_ADU_CLIENT_PROPERTIES_COMPONENT_NAME "deviceUpdate"
49 
53 #define AZ_IOT_ADU_CLIENT_AGENT_DEFAULT_COMPATIBILITY_PROPERTIES "manufacturer,model"
54 
58 typedef enum
59 {
65 
69 typedef enum
70 {
78 
82 typedef enum
83 {
89 
97 typedef struct
98 {
112 
118 typedef struct
119 {
123  az_span names[_az_IOT_ADU_CLIENT_MAX_DEVICE_CUSTOM_PROPERTIES];
127  az_span values[_az_IOT_ADU_CLIENT_MAX_DEVICE_CUSTOM_PROPERTIES];
131  int32_t count;
133 
144 typedef struct
145 {
177 
184 typedef struct
185 {
190  int32_t result_code;
201 
207 typedef struct
208 {
213  int32_t result_code;
232  az_iot_adu_client_step_result step_results[_az_IOT_ADU_CLIENT_MAX_INSTRUCTIONS_STEPS];
234 
239 typedef struct
240 {
255 
259 typedef struct
260 {
270 
276 typedef struct
277 {
298  az_iot_adu_client_file_url file_urls[_az_IOT_ADU_CLIENT_MAX_TOTAL_FILE_COUNT];
302  uint32_t file_urls_count;
304 
309 typedef struct
310 {
316 
321 typedef struct
322 {
337  az_span files[_az_IOT_ADU_CLIENT_MAX_FILE_COUNT_PER_STEP];
341  uint32_t files_count;
347 
351 typedef struct
352 {
357  steps[_az_IOT_ADU_CLIENT_MAX_INSTRUCTIONS_STEPS];
361  uint32_t steps_count;
363 
368 typedef struct
369 {
379 
386 typedef struct
387 {
400  int64_t size_in_bytes;
404  az_iot_adu_client_update_manifest_file_hash hashes[_az_IOT_ADU_CLIENT_MAX_FILE_HASH_COUNT];
408  uint32_t hashes_count;
410 
415 typedef struct
416 {
432  az_iot_adu_client_update_manifest_file files[_az_IOT_ADU_CLIENT_MAX_TOTAL_FILE_COUNT];
436  uint32_t files_count;
442 
447 typedef struct
448 {
454 
459 typedef struct
460 {
461  struct
462  {
464  } _internal;
466 
475 
484 
496 AZ_NODISCARD az_result
498 
509  az_iot_adu_client* client,
510  az_span component_name);
511 
538  az_iot_adu_client* client,
539  az_iot_adu_client_device_properties* device_properties,
540  az_iot_adu_client_agent_state agent_state,
541  az_iot_adu_client_workflow* workflow,
542  az_iot_adu_client_install_result* last_install_result,
543  az_json_writer* ref_json_writer);
544 
563  az_iot_adu_client* client,
564  az_json_reader* ref_json_reader,
565  az_iot_adu_client_update_request* update_request);
566 
580  az_iot_adu_client* client,
581  int32_t version,
583  az_json_writer* ref_json_writer);
584 
601  az_iot_adu_client* client,
602  az_json_reader* ref_json_reader,
603  az_iot_adu_client_update_manifest* update_manifest);
604 
605 #include <azure/core/_az_cfg_suffix.h>
606 
607 #endif // _az_IOT_ADU_H
az_iot_adu_client_install_result::result_code
int32_t result_code
Definition: az_iot_adu_client.h:213
az_iot_adu_client_update_manifest_file::id
az_span id
Definition: az_iot_adu_client.h:392
az_result.h
Definition of az_result and helper functions.
az_iot_adu_client_update_manifest_file_hash::hash_value
az_span hash_value
Definition: az_iot_adu_client.h:377
az_iot_adu_client_options_default
AZ_NODISCARD az_iot_adu_client_options az_iot_adu_client_options_default()
Gets the default Azure IoT ADU Client options.
az_json_reader
Returns the JSON tokens contained within a JSON buffer, one at a time.
Definition: az_json.h:664
az_iot_adu_client_update_manifest_instructions_step::handler
az_span handler
Definition: az_iot_adu_client.h:331
az_json_writer
Provides forward-only, non-cached writing of UTF-8 encoded JSON text into the provided buffer.
Definition: az_json.h:305
az_iot_adu_client_parse_service_properties
AZ_NODISCARD az_result az_iot_adu_client_parse_service_properties(az_iot_adu_client *client, az_json_reader *ref_json_reader, az_iot_adu_client_update_request *update_request)
Parses the json content from the ADU service writable properties into a pre-defined structure.
az_iot_adu_client_workflow::id
az_span id
Definition: az_iot_adu_client.h:249
az_iot_adu_client_options
User-defined options for the Azure IoT ADU client.
Definition: az_iot_adu_client.h:448
az_iot_adu_client_update_manifest::instructions
az_iot_adu_client_update_manifest_instructions instructions
Definition: az_iot_adu_client.h:428
az_iot_adu_client_parse_update_manifest
AZ_NODISCARD az_result az_iot_adu_client_parse_update_manifest(az_iot_adu_client *client, az_json_reader *ref_json_reader, az_iot_adu_client_update_manifest *update_manifest)
Parses the json content from the ADU service update manifest into a pre-defined structure.
az_iot_adu_client_update_manifest_instructions_step::handler_properties
az_iot_adu_client_update_manifest_instructions_step_handler_properties handler_properties
Definition: az_iot_adu_client.h:345
az_iot_adu_client_update_manifest_file::file_name
az_span file_name
Definition: az_iot_adu_client.h:396
az_iot_adu_client_update_manifest_instructions_step
Step in the instructions of an update manifest.
Definition: az_iot_adu_client.h:322
az_result
int32_t az_result
The type represents the various success and error conditions.
Definition: az_result.h:46
az_iot_adu_client_request_decision
az_iot_adu_client_request_decision
Decision codes to accept or reject a received update deployment.
Definition: az_iot_adu_client.h:59
az_iot_adu_client_update_manifest_file_hash::hash_type
az_span hash_type
Definition: az_iot_adu_client.h:373
az_iot_adu_client_update_manifest_instructions_step_handler_properties::installed_criteria
az_span installed_criteria
Definition: az_iot_adu_client.h:314
az_iot_adu_client_get_service_properties_response
AZ_NODISCARD az_result az_iot_adu_client_get_service_properties_response(az_iot_adu_client *client, int32_t version, az_iot_adu_client_request_decision status, az_json_writer *ref_json_writer)
Generates the payload necessary to respond to the service after receiving incoming properties.
az_iot_adu_client_file_url
A map of file ID to download url.
Definition: az_iot_adu_client.h:260
az_iot_adu_client_install_result::result_details
az_span result_details
Definition: az_iot_adu_client.h:222
az_iot_adu_client_step_result::extended_result_code
int32_t extended_result_code
Definition: az_iot_adu_client.h:195
az_iot_adu_client_update_manifest_instructions_step_handler_properties
User-defined properties for handling an update request.
Definition: az_iot_adu_client.h:310
az_iot_adu_client_device_properties::adu_version
az_span adu_version
Definition: az_iot_adu_client.h:163
az_iot_adu_client_device_properties::model
az_span model
Definition: az_iot_adu_client.h:153
az_iot_adu_client_workflow::action
az_iot_adu_client_service_action action
Definition: az_iot_adu_client.h:245
az_iot_adu_client_update_manifest::manifest_version
az_span manifest_version
Definition: az_iot_adu_client.h:420
AZ_IOT_ADU_CLIENT_AGENT_STATE_IDLE
@ AZ_IOT_ADU_CLIENT_AGENT_STATE_IDLE
ADU Agent State (Idle)
Definition: az_iot_adu_client.h:72
az_iot_adu_client_update_manifest_instructions_step::files_count
uint32_t files_count
Definition: az_iot_adu_client.h:341
az_iot_adu_client_device_properties::update_id
az_span update_id
Definition: az_iot_adu_client.h:175
az_iot_adu_update_id::provider
az_span provider
Definition: az_iot_adu_client.h:102
AZ_IOT_ADU_CLIENT_REQUEST_DECISION_ACCEPT
@ AZ_IOT_ADU_CLIENT_REQUEST_DECISION_ACCEPT
ADU Service Response (Accept)
Definition: az_iot_adu_client.h:61
az_iot_adu_client_is_component_device_update
AZ_NODISCARD bool az_iot_adu_client_is_component_device_update(az_iot_adu_client *client, az_span component_name)
Verifies if the Azure Plug-and-Play writable properties component is for ADU device update.
az_iot_adu_client_file_url::id
az_span id
Definition: az_iot_adu_client.h:264
az_iot_adu_client_device_properties::custom_properties
az_iot_adu_device_custom_properties * custom_properties
Definition: az_iot_adu_client.h:158
az_iot_adu_client_update_request
Structure that holds the parsed contents of the ADU request in the Plug and Play writable properties ...
Definition: az_iot_adu_client.h:277
az_iot_adu_client_step_result::result_details
az_span result_details
Definition: az_iot_adu_client.h:199
az_iot_adu_client_device_properties::delivery_optimization_agent_version
az_span delivery_optimization_agent_version
Definition: az_iot_adu_client.h:171
az_span.h
An az_span represents a contiguous byte buffer and is used for string manipulations,...
az_iot_adu_client_update_manifest_instructions
Instructions in the update manifest.
Definition: az_iot_adu_client.h:352
az_iot_adu_client_update_request::update_manifest_signature
az_span update_manifest_signature
Definition: az_iot_adu_client.h:293
az_iot_adu_client
Structure that holds the state of the Azure IoT ADU client.
Definition: az_iot_adu_client.h:460
az_iot_adu_client_file_url::url
az_span url
Definition: az_iot_adu_client.h:268
az_iot_adu_client_update_request::file_urls_count
uint32_t file_urls_count
Definition: az_iot_adu_client.h:302
az_iot_adu_client_update_manifest
Structure that holds the parsed contents of the update manifest sent by the ADU service.
Definition: az_iot_adu_client.h:416
AZ_IOT_ADU_CLIENT_REQUEST_DECISION_REJECT
@ AZ_IOT_ADU_CLIENT_REQUEST_DECISION_REJECT
ADU Service Response (Reject)
Definition: az_iot_adu_client.h:63
az_iot_adu_client_update_request::update_manifest
az_span update_manifest
Definition: az_iot_adu_client.h:289
az_iot_adu_client_device_properties
Holds the ADU agent device properties.
Definition: az_iot_adu_client.h:145
az_iot_adu_client_update_manifest::files_count
uint32_t files_count
Definition: az_iot_adu_client.h:436
az_iot_adu_client_device_properties::manufacturer
az_span manufacturer
Definition: az_iot_adu_client.h:149
AZ_IOT_ADU_CLIENT_SERVICE_ACTION_APPLY_DEPLOYMENT
@ AZ_IOT_ADU_CLIENT_SERVICE_ACTION_APPLY_DEPLOYMENT
ADU Service Action (Apply)
Definition: az_iot_adu_client.h:85
AZ_IOT_ADU_CLIENT_AGENT_STATE_FAILED
@ AZ_IOT_ADU_CLIENT_AGENT_STATE_FAILED
ADU Agent State (Failed)
Definition: az_iot_adu_client.h:76
az_iot_adu_client_device_properties_default
AZ_NODISCARD az_iot_adu_client_device_properties az_iot_adu_client_device_properties_default()
Gets the default az_iot_adu_client_device_properties.
az_iot_adu_client_init
AZ_NODISCARD az_result az_iot_adu_client_init(az_iot_adu_client *client, az_iot_adu_client_options *options)
Initializes an Azure IoT ADU Client.
az_iot_adu_client_workflow
A set of values that indicate which deployment the agent is currently working on.
Definition: az_iot_adu_client.h:240
az_json.h
This header defines the types and functions your application uses to read or write JSON objects.
az_iot_adu_client_update_manifest_instructions::steps_count
uint32_t steps_count
Definition: az_iot_adu_client.h:361
az_iot_adu_client_agent_state
az_iot_adu_client_agent_state
Agent states used to notify the ADU service of current state.
Definition: az_iot_adu_client.h:70
az_iot_adu_client_options::device_compatibility_properties
az_span device_compatibility_properties
Definition: az_iot_adu_client.h:452
az_iot_adu_client_update_manifest::create_date_time
az_span create_date_time
Definition: az_iot_adu_client.h:440
AZ_IOT_ADU_CLIENT_SERVICE_ACTION_CANCEL
@ AZ_IOT_ADU_CLIENT_SERVICE_ACTION_CANCEL
ADU Service Action (Cancel)
Definition: az_iot_adu_client.h:87
az_iot_adu_device_custom_properties
Holds any user-defined custom properties for the device.
Definition: az_iot_adu_client.h:119
az_iot_hub_client.h
Definition for the Azure IoT Hub client.
AZ_IOT_ADU_CLIENT_AGENT_STATE_DEPLOYMENT_IN_PROGRESS
@ AZ_IOT_ADU_CLIENT_AGENT_STATE_DEPLOYMENT_IN_PROGRESS
ADU Agent State (In Progress)
Definition: az_iot_adu_client.h:74
az_iot_adu_client_update_manifest::update_id
az_iot_adu_update_id update_id
Definition: az_iot_adu_client.h:424
az_iot_adu_client_install_result
The update result reported by the agent.
Definition: az_iot_adu_client.h:208
az_iot_adu_client_get_agent_state_payload
AZ_NODISCARD az_result az_iot_adu_client_get_agent_state_payload(az_iot_adu_client *client, az_iot_adu_client_device_properties *device_properties, az_iot_adu_client_agent_state agent_state, az_iot_adu_client_workflow *workflow, az_iot_adu_client_install_result *last_install_result, az_json_writer *ref_json_writer)
Generates the Azure Plug-and-Play (reported) properties payload with the state of the ADU agent.
az_iot_adu_update_id::name
az_span name
Definition: az_iot_adu_client.h:106
az_iot_adu_client_step_result
The update step result reported by the agent.
Definition: az_iot_adu_client.h:185
az_iot_adu_client_update_manifest_file_hash
Hash value for a given file.
Definition: az_iot_adu_client.h:369
az_iot_adu_device_custom_properties::count
int32_t count
Definition: az_iot_adu_client.h:131
az_iot_adu_client_step_result::result_code
int32_t result_code
Definition: az_iot_adu_client.h:190
az_iot_adu_client_update_manifest_file::size_in_bytes
int64_t size_in_bytes
Definition: az_iot_adu_client.h:400
az_iot_adu_client_install_result::extended_result_code
int32_t extended_result_code
Definition: az_iot_adu_client.h:218
az_iot_adu_client_install_result::step_results_count
int32_t step_results_count
Definition: az_iot_adu_client.h:226
az_iot_adu_client_service_action
az_iot_adu_client_service_action
Actions specified by the service for the agent to process.
Definition: az_iot_adu_client.h:83
az_iot_adu_client_update_request::workflow
az_iot_adu_client_workflow workflow
Definition: az_iot_adu_client.h:281
az_iot_adu_update_id
Identity of the update request.
Definition: az_iot_adu_client.h:98
az_span
Represents a "view" over a byte buffer that represents a contiguous region of memory....
Definition: az_span.h:33
az_iot_adu_client_update_manifest_file
Details of a file referenced in the update request.
Definition: az_iot_adu_client.h:387
az_iot_adu_client_workflow::retry_timestamp
az_span retry_timestamp
Definition: az_iot_adu_client.h:253
az_iot_adu_update_id::version
az_span version
Definition: az_iot_adu_client.h:110
az_iot_adu_client_update_manifest_file::hashes_count
uint32_t hashes_count
Definition: az_iot_adu_client.h:408