Azure IoT middleware for FreeRTOS
azure_iot_provisioning_client.h
Go to the documentation of this file.
1 /* Copyright (c) Microsoft Corporation.
2  * Licensed under the MIT License. */
3 
15 #ifndef AZURE_IOT_PROVISIONING_CLIENT_H
16 #define AZURE_IOT_PROVISIONING_CLIENT_H
17 
18 #include "FreeRTOS.h"
19 
20 #include "azure_iot.h"
21 
22 #include "azure_iot_result.h"
23 #include "azure_iot_mqtt_port.h"
25 
26 /* Azure SDK for Embedded C includes */
27 #include "azure/iot/az_iot_common.h"
28 #include "azure/iot/az_iot_provisioning_client.h"
29 #include "azure/core/_az_cfg_prefix.h"
30 
34 #define azureiotprovisioningRESPONSE_MAX ( azureiotconfigTOPIC_MAX + azureiotconfigPROVISIONING_REQUEST_PAYLOAD_MAX )
35 
36 #define azureiotprovisioningNO_WAIT ( 0 )
37 #define azureiotprovisioningWAIT_FOREVER ( ( uint32_t ) 0xFFFFFFFF )
43 {
44  const uint8_t * pucUserAgent;
45  uint32_t ulUserAgentLength;
47 
52 {
53  struct
54  {
55  AzureIoTMQTT_t xMQTTContext;
56 
57  const uint8_t * pucRegistrationID;
58  uint32_t ulRegistrationIDLength;
59  const uint8_t * pucEndpoint;
60  uint32_t ulEndpointLength;
61  const uint8_t * pucIDScope;
62  uint32_t ulIDScopeLength;
63  const uint8_t * pucSymmetricKey;
64  uint32_t ulSymmetricKeyLength;
65  const uint8_t * pucRegistrationPayload;
66  uint32_t ulRegistrationPayloadLength;
67 
68  uint32_t ( * pxTokenRefresh )( struct AzureIoTProvisioningClient * pxAzureIoTProvisioningClient,
69  uint64_t ullExpiryTimeSecs,
70  const uint8_t * ucKey,
71  uint32_t ulKeyLen,
72  uint8_t * pucSASBuffer,
73  uint32_t ulSasBufferLen,
74  uint32_t * pulSaSLength );
75  AzureIoTGetHMACFunc_t xHMACFunction;
76  AzureIoTGetCurrentTimeFunc_t xGetTimeFunction;
77 
78  az_iot_provisioning_client xProvisioningClientCore;
79 
80  uint32_t ulWorkflowState;
81  uint32_t ulLastOperationResult;
82  uint64_t ullRetryAfter;
83 
84  uint8_t * pucScratchBuffer;
85  uint32_t ulScratchBufferLength;
86  uint8_t ucProvisioningLastResponse[ azureiotprovisioningRESPONSE_MAX ];
87  size_t xLastResponsePayloadLength;
88  uint16_t usLastResponseTopicLength;
89  az_iot_provisioning_client_register_response xRegisterResponse;
92 
100 
119  const uint8_t * pucEndpoint,
120  uint32_t ulEndpointLength,
121  const uint8_t * pucIDScope,
122  uint32_t ulIDScopeLength,
123  const uint8_t * pucRegistrationID,
124  uint32_t ulRegistrationIDLength,
125  AzureIoTProvisioningClientOptions_t * pxProvisioningClientOptions,
126  uint8_t * pucBuffer,
127  uint32_t ulBufferLength,
128  AzureIoTGetCurrentTimeFunc_t xGetTimeFunction,
129  const AzureIoTTransportInterface_t * pxTransportInterface );
130 
137 
150  const uint8_t * pucSymmetricKey,
151  uint32_t ulSymmetricKeyLength,
152  AzureIoTGetHMACFunc_t xHmacFunction );
153 
173  uint32_t ulTimeoutMilliseconds );
174 
186  uint8_t * pucHubHostname,
187  uint32_t * pulHostnameLength,
188  uint8_t * pucDeviceID,
189  uint32_t * pulDeviceIDLength );
190 
201  uint32_t * pulExtendedErrorCode );
202 
213  const uint8_t * pucPayload,
214  uint32_t ulPayloadLength );
215 
216 #include "azure/core/_az_cfg_suffix.h"
217 
218 #endif /* AZURE_IOT_PROVISIONING_CLIENT_H */
Azure IoT FreeRTOS middleware common APIs and structs.
uint32_t(* AzureIoTGetHMACFunc_t)(const uint8_t *pucKey, uint32_t ulKeyLength, const uint8_t *pucData, uint32_t ulDataLength, uint8_t *pucOutput, uint32_t ulOutputLength, uint32_t *pulBytesCopied)
The HMAC256 function used by the SDK to generate SAS keys.
Definition: azure_iot.h:62
uint64_t(* AzureIoTGetCurrentTimeFunc_t)(void)
The platform get time function to be used by the SDK for MQTT connections.
Definition: azure_iot.h:48
AzureIoTResult_t AzureIoTProvisioningClient_SetSymmetricKey(AzureIoTProvisioningClient_t *pxAzureProvClient, const uint8_t *pucSymmetricKey, uint32_t ulSymmetricKeyLength, AzureIoTGetHMACFunc_t xHmacFunction)
Set the symmetric key to use for authentication.
struct AzureIoTProvisioningClient AzureIoTProvisioningClient_t
The Azure IoT Device Provisioning client.
AzureIoTResult_t AzureIoTProvisioningClient_GetExtendedCode(AzureIoTProvisioningClient_t *pxAzureProvClient, uint32_t *pulExtendedErrorCode)
Get extended code for Provisioning failure.
AzureIoTResult_t AzureIoTProvisioningClient_Register(AzureIoTProvisioningClient_t *pxAzureProvClient, uint32_t ulTimeoutMilliseconds)
Begin the provisioning process.
void AzureIoTProvisioningClient_Deinit(AzureIoTProvisioningClient_t *pxAzureProvClient)
Deinitialize the Azure IoT Provisioning Client.
AzureIoTResult_t AzureIoTProvisioningClient_SetRegistrationPayload(AzureIoTProvisioningClient_t *pxAzureProvClient, const uint8_t *pucPayload, uint32_t ulPayloadLength)
Set registration payload.
AzureIoTResult_t AzureIoTProvisioningClient_Init(AzureIoTProvisioningClient_t *pxAzureProvClient, const uint8_t *pucEndpoint, uint32_t ulEndpointLength, const uint8_t *pucIDScope, uint32_t ulIDScopeLength, const uint8_t *pucRegistrationID, uint32_t ulRegistrationIDLength, AzureIoTProvisioningClientOptions_t *pxProvisioningClientOptions, uint8_t *pucBuffer, uint32_t ulBufferLength, AzureIoTGetCurrentTimeFunc_t xGetTimeFunction, const AzureIoTTransportInterface_t *pxTransportInterface)
Initialize the Azure IoT Provisioning Client.
AzureIoTResult_t AzureIoTProvisioningClient_GetDeviceAndHub(AzureIoTProvisioningClient_t *pxAzureProvClient, uint8_t *pucHubHostname, uint32_t *pulHostnameLength, uint8_t *pucDeviceID, uint32_t *pulDeviceIDLength)
After a registration has been completed, get the IoT Hub hostname and device ID.
struct AzureIoTProvisioningClientOptions AzureIoTProvisioningClientOptions_t
The options for the Azure IoT Device Provisioning client.
AzureIoTResult_t AzureIoTProvisioningClient_OptionsInit(AzureIoTProvisioningClientOptions_t *pxProvisioningClientOptions)
Initialize the Azure IoT Provisioning Options with default values.
#define azureiotprovisioningRESPONSE_MAX
The maximum size of the response buffer.
Definition: azure_iot_provisioning_client.h:34
Azure IoT FreeRTOS middleware result values.
enum AzureIoTResult AzureIoTResult_t
The results used by the middleware.
Transport interface definition to send and receive data over the network.
The Azure IoT Device Provisioning client.
Definition: azure_iot_provisioning_client.h:52
struct AzureIoTProvisioningClient::@8 _internal
Internal to the SDK.
The options for the Azure IoT Device Provisioning client.
Definition: azure_iot_provisioning_client.h:43
const uint8_t * pucUserAgent
Definition: azure_iot_provisioning_client.h:44
uint32_t ulUserAgentLength
Definition: azure_iot_provisioning_client.h:45
The transport layer interface.
Definition: azure_iot_transport_interface.h:159