16 #ifndef AZURE_IOT_HUB_CLIENT_H
17 #define AZURE_IOT_HUB_CLIENT_H
23 #include "azure_iot_mqtt_port.h"
27 #include "azure/az_core.h"
28 #include "azure/iot/az_iot_common.h"
29 #include "azure/iot/az_iot_hub_client.h"
30 #include "azure/core/_az_cfg_prefix.h"
35 #define azureiothubSUBSCRIBE_FEATURE_COUNT ( 3 )
40 #define azureiothubCREATE_COMPONENT( x ) ( AzureIoTHubClientComponent_t ) AZ_SPAN_LITERAL_FROM_STR( x )
56 eAzureIoTHubMessageQoS0 = 0,
78 eAzureIoTStatusUnknown = 0,
81 eAzureIoTStatusOk = 200,
82 eAzureIoTStatusAccepted = 202,
83 eAzureIoTStatusNoContent = 204,
86 eAzureIoTStatusBadRequest = 400,
87 eAzureIoTStatusUnauthorized = 401,
88 eAzureIoTStatusForbidden = 403,
89 eAzureIoTStatusNotFound = 404,
90 eAzureIoTStatusNotAllowed = 405,
91 eAzureIoTStatusNotConflict = 409,
92 eAzureIoTStatusPreconditionFailed = 412,
93 eAzureIoTStatusRequestTooLarge = 413,
94 eAzureIoTStatusUnsupportedType = 415,
95 eAzureIoTStatusThrottled = 429,
96 eAzureIoTStatusClientClosed = 499,
97 eAzureIoTStatusServerError = 500,
98 eAzureIoTStatusBadGateway = 502,
99 eAzureIoTStatusServiceUnavailable = 503,
100 eAzureIoTStatusTimeout = 504,
185 uint16_t usMqttSubPacketID;
188 void * pvPublishInfo );
190 void * pvCallbackContext;
238 AzureIoTMQTT_t xMQTTContext;
240 uint8_t * pucWorkingBuffer;
241 uint32_t ulWorkingBufferLength;
242 az_iot_hub_client xAzureIoTHubClientCore;
244 const uint8_t * pucHostname;
245 uint16_t ulHostnameLength;
246 const uint8_t * pucDeviceID;
247 uint16_t ulDeviceIDLength;
248 const uint8_t * pucSymmetricKey;
249 uint32_t ulSymmetricKeyLength;
252 uint64_t ullExpiryTimeSecs,
253 const uint8_t * ucKey,
255 uint8_t * pucSASBuffer,
256 uint32_t ulSasBufferLen,
257 uint32_t * pulSaSLength );
262 uint32_t ulCurrentPropertyRequestID;
298 const uint8_t * pucHostname,
299 uint16_t ulHostnameLength,
300 const uint8_t * pucDeviceID,
301 uint16_t ulDeviceIDLength,
304 uint32_t ulBufferLength,
327 const uint8_t * pucSymmetricKey,
328 uint32_t ulSymmetricKeyLength,
343 bool * pxOutSessionPresent,
344 uint32_t ulTimeoutMilliseconds );
369 const uint8_t * pucTelemetryData,
370 uint32_t ulTelemetryDataLength,
373 uint16_t * pusTelemetryPacketID );
386 uint32_t ulTimeoutMilliseconds );
399 void * prvCallbackContext,
400 uint32_t ulTimeoutMilliseconds );
421 void * prvCallbackContext,
422 uint32_t ulTimeoutMilliseconds );
445 const uint8_t * pucCommandPayload,
446 uint32_t ulCommandPayloadLength );
459 void * prvCallbackContext,
460 uint32_t ulTimeoutMilliseconds );
482 const uint8_t * pucReportedPayload,
483 uint32_t ulReportedPayloadLength,
484 uint32_t * pulRequestID );
500 #include "azure/core/_az_cfg_suffix.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
void(* AzureIoTHubClientCommandCallback_t)(AzureIoTHubClientCommandRequest_t *pxMessage, void *pvContext)
Command callback to be invoked when a command request is received in the call to AzureIoTHubClient_Pr...
Definition: azure_iot_hub_client.h:163
AzureIoTResult_t AzureIoTHubClient_Init(AzureIoTHubClient_t *pxAzureIoTHubClient, const uint8_t *pucHostname, uint16_t ulHostnameLength, const uint8_t *pucDeviceID, uint16_t ulDeviceIDLength, AzureIoTHubClientOptions_t *pxHubClientOptions, uint8_t *pucBuffer, uint32_t ulBufferLength, AzureIoTGetCurrentTimeFunc_t xGetTimeFunction, const AzureIoTTransportInterface_t *pxTransportInterface)
Initialize the Azure IoT Hub Client.
struct AzureIoTHubClientCloudToDeviceMessageRequest AzureIoTHubClientCloudToDeviceMessageRequest_t
IoT Hub Cloud Message Request struct.
enum AzureIoTHubMessageStatus AzureIoTHubMessageStatus_t
Status codes for Azure IoT Hub responses.
az_span AzureIoTHubClientComponent_t
Type for Azure IoT Plug and Play component. The list of component names can be set as an option for t...
Definition: azure_iot_hub_client.h:49
AzureIoTResult_t AzureIoTHubClient_SendPropertiesReported(AzureIoTHubClient_t *pxAzureIoTHubClient, const uint8_t *pucReportedPayload, uint32_t ulReportedPayloadLength, uint32_t *pulRequestID)
Send reported device properties to Azure IoT Hub.
void(* AzureIoTHubClientCloudToDeviceMessageCallback_t)(AzureIoTHubClientCloudToDeviceMessageRequest_t *pxMessage, void *pvContext)
Cloud message callback to be invoked when a cloud message is received in the call to AzureIoTHubClien...
Definition: azure_iot_hub_client.h:153
AzureIoTResult_t AzureIoTHubClient_UnsubscribeProperties(AzureIoTHubClient_t *pxAzureIoTHubClient)
Unsubscribe from device properties.
AzureIoTResult_t AzureIoTHubClient_SubscribeProperties(AzureIoTHubClient_t *pxAzureIoTHubClient, AzureIoTHubClientPropertiesCallback_t xPropertiesCallback, void *prvCallbackContext, uint32_t ulTimeoutMilliseconds)
Subscribe to device properties.
void(* AzureIoTHubClientPropertiesCallback_t)(AzureIoTHubClientPropertiesResponse_t *pxMessage, void *pvContext)
Properties callback to be invoked when a property message is received in the call to AzureIoTHubClien...
Definition: azure_iot_hub_client.h:172
void AzureIoTHubClient_Deinit(AzureIoTHubClient_t *pxAzureIoTHubClient)
Deinitialize the Azure IoT Hub Client.
AzureIoTResult_t AzureIoTHubClient_Connect(AzureIoTHubClient_t *pxAzureIoTHubClient, bool xCleanSession, bool *pxOutSessionPresent, uint32_t ulTimeoutMilliseconds)
Connect via MQTT to the IoT Hub endpoint.
AzureIoTResult_t AzureIoTHubClient_OptionsInit(AzureIoTHubClientOptions_t *pxHubClientOptions)
Initialize the Azure IoT Hub Options with default values.
AzureIoTResult_t AzureIoTHubClient_UnsubscribeCommand(AzureIoTHubClient_t *pxAzureIoTHubClient)
Unsubscribe from commands.
AzureIoTResult_t AzureIoTHubClient_ProcessLoop(AzureIoTHubClient_t *pxAzureIoTHubClient, uint32_t ulTimeoutMilliseconds)
Receive any incoming MQTT messages from and manage the MQTT connection to IoT Hub.
AzureIoTHubMessageType
Enumeration to dictate Azure IoT message types.
Definition: azure_iot_hub_client.h:64
@ eAzureIoTHubPropertiesWritablePropertyMessage
Definition: azure_iot_hub_client.h:69
@ eAzureIoTHubCommandMessage
Definition: azure_iot_hub_client.h:66
@ eAzureIoTHubCloudToDeviceMessage
Definition: azure_iot_hub_client.h:65
@ eAzureIoTHubPropertiesReportedResponseMessage
Definition: azure_iot_hub_client.h:68
@ eAzureIoTHubPropertiesRequestedMessage
Definition: azure_iot_hub_client.h:67
AzureIoTResult_t AzureIoTHubClient_Disconnect(AzureIoTHubClient_t *pxAzureIoTHubClient)
Disconnect from the IoT Hub endpoint.
struct AzureIoTHubClientReceiveContext AzureIoTHubClientReceiveContext_t
Receive context to be used internally for the processing of messages.
struct AzureIoTHubClientOptions AzureIoTHubClientOptions_t
Options list for the hub client.
AzureIoTResult_t AzureIoTHubClient_SubscribeCommand(AzureIoTHubClient_t *pxAzureIoTHubClient, AzureIoTHubClientCommandCallback_t xCommandCallback, void *prvCallbackContext, uint32_t ulTimeoutMilliseconds)
Subscribe to commands.
enum AzureIoTHubMessageQoS AzureIoTHubMessageQoS_t
MQTT quality of service values used for messages.
AzureIoTResult_t AzureIoTHubClient_SubscribeCloudToDeviceMessage(AzureIoTHubClient_t *pxAzureIoTHubClient, AzureIoTHubClientCloudToDeviceMessageCallback_t xCloudToDeviceMessageCallback, void *prvCallbackContext, uint32_t ulTimeoutMilliseconds)
Subscribe to cloud to device messages.
AzureIoTResult_t AzureIoTHubClient_SendCommandResponse(AzureIoTHubClient_t *pxAzureIoTHubClient, const AzureIoTHubClientCommandRequest_t *pxMessage, uint32_t ulStatus, const uint8_t *pucCommandPayload, uint32_t ulCommandPayloadLength)
Send a response to a received command message.
AzureIoTResult_t AzureIoTHubClient_UnsubscribeCloudToDeviceMessage(AzureIoTHubClient_t *pxAzureIoTHubClient)
Unsubscribe from cloud to device messages.
AzureIoTResult_t AzureIoTHubClient_SetSymmetricKey(AzureIoTHubClient_t *pxAzureIoTHubClient, const uint8_t *pucSymmetricKey, uint32_t ulSymmetricKeyLength, AzureIoTGetHMACFunc_t xHMACFunction)
Set the symmetric key to use for authentication.
AzureIoTResult_t AzureIoTHubClient_SendTelemetry(AzureIoTHubClient_t *pxAzureIoTHubClient, const uint8_t *pucTelemetryData, uint32_t ulTelemetryDataLength, AzureIoTMessageProperties_t *pxProperties, AzureIoTHubMessageQoS_t xQOS, uint16_t *pusTelemetryPacketID)
Send telemetry data to IoT Hub.
struct AzureIoTHubClientCommandRequest AzureIoTHubClientCommandRequest_t
IoT Hub Command Request struct.
enum AzureIoTHubMessageType AzureIoTHubMessageType_t
Enumeration to dictate Azure IoT message types.
AzureIoTHubMessageQoS
MQTT quality of service values used for messages.
Definition: azure_iot_hub_client.h:55
@ eAzureIoTHubMessageQoS1
Definition: azure_iot_hub_client.h:57
struct AzureIoTHubClientPropertiesResponse AzureIoTHubClientPropertiesResponse_t
IoT Hub Properties Response struct.
AzureIoTResult_t AzureIoTHubClient_RequestPropertiesAsync(AzureIoTHubClient_t *pxAzureIoTHubClient)
Request to get the device property document.
void(* AzureIoTTelemetryAckCallback_t)(uint16_t ulTelemetryPacketID)
Callback to send notification that puback was received for specific packet ID.
Definition: azure_iot_hub_client.h:206
AzureIoTHubMessageStatus
Status codes for Azure IoT Hub responses.
Definition: azure_iot_hub_client.h:76
#define azureiothubSUBSCRIBE_FEATURE_COUNT
Total number of features which could be subscribed to.
Definition: azure_iot_hub_client.h:35
Azure IoT FreeRTOS middleware message APIs and structs.
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.
Azure IoT Hub Client used to manage connections and features for Azure IoT Hub.
IoT Hub Cloud Message Request struct.
Definition: azure_iot_hub_client.h:107
uint32_t ulPayloadLength
Definition: azure_iot_hub_client.h:109
AzureIoTMessageProperties_t xProperties
Definition: azure_iot_hub_client.h:111
const void * pvMessagePayload
Definition: azure_iot_hub_client.h:108
IoT Hub Command Request struct.
Definition: azure_iot_hub_client.h:118
uint16_t usCommandNameLength
Definition: azure_iot_hub_client.h:129
uint16_t usComponentNameLength
Definition: azure_iot_hub_client.h:126
const void * pvMessagePayload
Definition: azure_iot_hub_client.h:119
uint16_t usRequestIDLength
Definition: azure_iot_hub_client.h:123
const uint8_t * pucComponentName
Definition: azure_iot_hub_client.h:125
const uint8_t * pucRequestID
Definition: azure_iot_hub_client.h:122
uint32_t ulPayloadLength
Definition: azure_iot_hub_client.h:120
const uint8_t * pucCommandName
Definition: azure_iot_hub_client.h:128
Definition: azure_iot_hub_client.h:235
struct AzureIoTHubClient::@4 _internal
Internal to the SDK.
Options list for the hub client.
Definition: azure_iot_hub_client.h:212
uint32_t ulUserAgentLength
Definition: azure_iot_hub_client.h:224
AzureIoTTelemetryAckCallback_t xTelemetryCallback
Definition: azure_iot_hub_client.h:226
const uint8_t * pucModuleID
Definition: azure_iot_hub_client.h:213
const uint8_t * pucModelID
Definition: azure_iot_hub_client.h:216
uint32_t ulModelIDLength
Definition: azure_iot_hub_client.h:218
uint32_t ulModuleIDLength
Definition: azure_iot_hub_client.h:214
AzureIoTHubClientComponent_t * pxComponentList
Definition: azure_iot_hub_client.h:220
uint32_t ulComponentListLength
Definition: azure_iot_hub_client.h:221
const uint8_t * pucUserAgent
Definition: azure_iot_hub_client.h:223
IoT Hub Properties Response struct.
Definition: azure_iot_hub_client.h:136
uint32_t ulRequestID
Definition: azure_iot_hub_client.h:142
uint32_t ulPayloadLength
Definition: azure_iot_hub_client.h:140
AzureIoTHubMessageStatus_t xMessageStatus
Definition: azure_iot_hub_client.h:144
const void * pvMessagePayload
Definition: azure_iot_hub_client.h:139
AzureIoTHubMessageType_t xMessageType
Definition: azure_iot_hub_client.h:137
Receive context to be used internally for the processing of messages.
Definition: azure_iot_hub_client.h:181
struct AzureIoTHubClientReceiveContext::@2 _internal
Internal to the SDK.
The bag of properties associated with a message.
Definition: azure_iot_message.h:31
The transport layer interface.
Definition: azure_iot_transport_interface.h:159