13 #ifndef AZURE_IOT_MQTT_H
14 #define AZURE_IOT_MQTT_H
20 #include "azure_iot_mqtt_port.h"
24 #define azureiotmqttPACKET_TYPE_CONNECT ( ( uint8_t ) 0x10U )
25 #define azureiotmqttPACKET_TYPE_CONNACK ( ( uint8_t ) 0x20U )
26 #define azureiotmqttPACKET_TYPE_PUBLISH ( ( uint8_t ) 0x30U )
27 #define azureiotmqttPACKET_TYPE_PUBACK ( ( uint8_t ) 0x40U )
28 #define azureiotmqttPACKET_TYPE_PUBREC ( ( uint8_t ) 0x50U )
29 #define azureiotmqttPACKET_TYPE_PUBREL ( ( uint8_t ) 0x62U )
30 #define azureiotmqttPACKET_TYPE_PUBCOMP ( ( uint8_t ) 0x70U )
31 #define azureiotmqttPACKET_TYPE_SUBSCRIBE ( ( uint8_t ) 0x82U )
32 #define azureiotmqttPACKET_TYPE_SUBACK ( ( uint8_t ) 0x90U )
33 #define azureiotmqttPACKET_TYPE_UNSUBSCRIBE ( ( uint8_t ) 0xA2U )
34 #define azureiotmqttPACKET_TYPE_UNSUBACK ( ( uint8_t ) 0xB0U )
35 #define azureiotmqttPACKET_TYPE_PINGREQ ( ( uint8_t ) 0xC0U )
36 #define azureiotmqttPACKET_TYPE_PINGRESP ( ( uint8_t ) 0xD0U )
37 #define azureiotmqttPACKET_TYPE_DISCONNECT ( ( uint8_t ) 0xE0U )
39 #define azureiotmqttGET_PACKET_TYPE( ucType ) ( ( ucType ) & 0xF0U )
46 eAzureIoTMQTTQoS0 = 0,
56 eMQTTSubAckSuccessQos0 = 0x00,
67 eAzureIoTMQTTSuccess = 0,
263 uint8_t * pucNetworkBuffer,
264 size_t xNetworkBufferLength );
287 uint32_t ulMilliseconds,
288 bool * pxSessionPresent );
303 size_t xSubscriptionCount,
304 uint16_t usPacketId );
317 uint16_t usPacketId );
341 size_t xSubscriptionCount,
342 uint16_t usPacketId );
365 uint32_t ulMilliseconds );
401 uint8_t ** ppucPayloadStart,
402 size_t * pxPayloadSize );
AzureIoTMQTTResult_t AzureIoTMQTT_Ping(AzureIoTMQTTHandle_t xContext)
Sends a MQTT PINGREQ to broker.
enum AzureIoTMQTTResult AzureIoTMQTTResult_t
Result values used for Azure IoT MQTT functions.
AzureIoTMQTTSubAckStatus
MQTT suback ack status states.
Definition: azure_iot_mqtt.h:55
@ eMQTTSubAckFailure
Definition: azure_iot_mqtt.h:59
@ eMQTTSubAckSuccessQos1
Definition: azure_iot_mqtt.h:57
@ eMQTTSubAckSuccessQos2
Definition: azure_iot_mqtt.h:58
AzureIoTMQTTResult_t AzureIoTMQTT_GetSubAckStatusCodes(const AzureIoTMQTTPacketInfo_t *pxSubackPacket, uint8_t **ppucPayloadStart, size_t *pxPayloadSize)
Parses the payload of a MQTT SUBACK packet that contains status codes corresponding to topic filter s...
struct AzureIoTMQTTPublishInfo AzureIoTMQTTPublishInfo_t
Publish info for the MQTT client.
struct AzureIoTMQTTPacketInfo AzureIoTMQTTPacketInfo_t
MQTT packet info for the MQTT client.
enum AzureIoTMQTTSubAckStatus AzureIoTMQTTSubAckStatus_t
MQTT suback ack status states.
struct AzureIoTMQTTConnectInfo AzureIoTMQTTConnectInfo_t
Connection info for the MQTT client.
uint32_t(* AzureIoTMQTTGetCurrentTimeFunc_t)(void)
The time function to be used for MQTT functionality.
Definition: azure_iot_mqtt.h:232
AzureIoTMQTTResult
Result values used for Azure IoT MQTT functions.
Definition: azure_iot_mqtt.h:66
@ eAzureIoTMQTTIllegalState
Definition: azure_iot_mqtt.h:75
@ eAzureIoTMQTTNoDataAvailable
Definition: azure_iot_mqtt.h:74
@ eAzureIoTMQTTSendFailed
Definition: azure_iot_mqtt.h:70
@ eAzureIoTMQTTKeepAliveTimeout
Definition: azure_iot_mqtt.h:77
@ eAzureIoTMQTTBadResponse
Definition: azure_iot_mqtt.h:72
@ eAzureIoTMQTTFailed
Definition: azure_iot_mqtt.h:78
@ eAzureIoTMQTTStateCollision
Definition: azure_iot_mqtt.h:76
@ eAzureIoTMQTTServerRefused
Definition: azure_iot_mqtt.h:73
@ eAzureIoTMQTTNoMemory
Definition: azure_iot_mqtt.h:69
@ eAzureIoTMQTTRecvFailed
Definition: azure_iot_mqtt.h:71
@ eAzureIoTMQTTBadParameter
Definition: azure_iot_mqtt.h:68
AzureIoTMQTTResult_t AzureIoTMQTT_Subscribe(AzureIoTMQTTHandle_t xContext, const AzureIoTMQTTSubscribeInfo_t *pxSubscriptionList, size_t xSubscriptionCount, uint16_t usPacketId)
Sends MQTT SUBSCRIBE for the given list of topic filters to the broker.
AzureIoTMQTTQoS
Quality of service values.
Definition: azure_iot_mqtt.h:45
@ eAzureIoTMQTTQoS2
Definition: azure_iot_mqtt.h:48
@ eAzureIoTMQTTQoS1
Definition: azure_iot_mqtt.h:47
AzureIoTMQTTResult_t AzureIoTMQTT_Publish(AzureIoTMQTTHandle_t xContext, const AzureIoTMQTTPublishInfo_t *pxPublishInfo, uint16_t usPacketId)
Publishes a message to the given topic name.
struct AzureIoTMQTTDeserializedInfo AzureIoTMQTTDeserializedInfo_t
MQTT packet deserialized info for the MQTT client.
AzureIoTMQTTResult_t AzureIoTMQTT_Init(AzureIoTMQTTHandle_t xContext, const AzureIoTTransportInterface_t *pxTransportInterface, AzureIoTMQTTGetCurrentTimeFunc_t xGetTimeFunction, AzureIoTMQTTEventCallback_t xUserCallback, uint8_t *pucNetworkBuffer, size_t xNetworkBufferLength)
Initialize an AzureIoTMQTT context.
enum AzureIoTMQTTQoS AzureIoTMQTTQoS_t
Quality of service values.
uint16_t AzureIoTMQTT_GetPacketId(AzureIoTMQTTHandle_t xContext)
Get a packet ID.
AzureIoTMQTTResult_t AzureIoTMQTT_Connect(AzureIoTMQTTHandle_t xContext, const AzureIoTMQTTConnectInfo_t *pxConnectInfo, const AzureIoTMQTTPublishInfo_t *pxWillInfo, uint32_t ulMilliseconds, bool *pxSessionPresent)
Establish an MQTT session.
AzureIoTMQTTResult_t AzureIoTMQTT_Disconnect(AzureIoTMQTTHandle_t xContext)
Disconnect a MQTT session.
AzureIoTMQTTResult_t AzureIoTMQTT_Unsubscribe(AzureIoTMQTTHandle_t xContext, const AzureIoTMQTTSubscribeInfo_t *pxSubscriptionList, size_t xSubscriptionCount, uint16_t usPacketId)
Sends MQTT UNSUBSCRIBE for the given list of topic filters to the broker.
AzureIoTMQTTResult_t AzureIoTMQTT_ProcessLoop(AzureIoTMQTTHandle_t xContext, uint32_t ulMilliseconds)
Loop to receive packets from the transport interface. Handles keep alive.
AzureIoTMQTT_t * AzureIoTMQTTHandle_t
Typedef of the MQTT client which is defined by the MQTT port.
Definition: azure_iot_mqtt.h:225
struct AzureIoTMQTTSubscribeInfo AzureIoTMQTTSubscribeInfo_t
Subscription info for the MQTT client.
void(* AzureIoTMQTTEventCallback_t)(AzureIoTMQTTHandle_t pContext, struct AzureIoTMQTTPacketInfo *pxPacketInfo, struct AzureIoTMQTTDeserializedInfo *pxDeserializedInfo)
The callback function which will be invoked on receipt of an MQTT message.
Definition: azure_iot_mqtt.h:237
Transport interface definition to send and receive data over the network.
Connection info for the MQTT client.
Definition: azure_iot_mqtt.h:85
bool xCleanSession
Whether to establish a new, clean session or resume a previous session.
Definition: azure_iot_mqtt.h:89
uint16_t usUserNameLength
Length of MQTT user name. Set to 0 if not used. or set pcUserName to NULL.
Definition: azure_iot_mqtt.h:115
uint16_t usClientIdentifierLength
Length of the client identifier.
Definition: azure_iot_mqtt.h:104
const uint8_t * pcPassword
MQTT password. Set to NULL if not used.
Definition: azure_iot_mqtt.h:120
const uint8_t * pcUserName
MQTT user name. Set to NULL if not used.
Definition: azure_iot_mqtt.h:109
uint16_t usPasswordLength
Length of MQTT password. Set to 0 if not used or set pcPassword to NULL.
Definition: azure_iot_mqtt.h:126
uint16_t usKeepAliveSeconds
MQTT keep alive period, in seconds.
Definition: azure_iot_mqtt.h:94
const uint8_t * pcClientIdentifier
MQTT client identifier. Must be unique per client.
Definition: azure_iot_mqtt.h:99
MQTT packet deserialized info for the MQTT client.
Definition: azure_iot_mqtt.h:195
uint16_t usPacketIdentifier
Packet ID of deserialized packet.
Definition: azure_iot_mqtt.h:196
AzureIoTMQTTResult_t xDeserializationResult
Return code of deserialization.
Definition: azure_iot_mqtt.h:198
AzureIoTMQTTPublishInfo_t * pxPublishInfo
Pointer to deserialized publish info.
Definition: azure_iot_mqtt.h:197
MQTT packet info for the MQTT client.
Definition: azure_iot_mqtt.h:205
uint8_t * pucRemainingData
Remaining serialized data in the MQTT packet.
Definition: azure_iot_mqtt.h:214
uint8_t ucType
Type of incoming MQTT packet.
Definition: azure_iot_mqtt.h:209
size_t xRemainingLength
Length of remaining serialized data.
Definition: azure_iot_mqtt.h:219
Publish info for the MQTT client.
Definition: azure_iot_mqtt.h:154
const void * pvPayload
Message payload.
Definition: azure_iot_mqtt.h:183
bool xDup
Whether this is a duplicate publish message.
Definition: azure_iot_mqtt.h:168
AzureIoTMQTTQoS_t xQOS
Quality of Service for message.
Definition: azure_iot_mqtt.h:158
const uint8_t * pcTopicName
Topic name on which the message is published.
Definition: azure_iot_mqtt.h:173
uint16_t usTopicNameLength
Length of topic name.
Definition: azure_iot_mqtt.h:178
size_t xPayloadLength
Message payload length.
Definition: azure_iot_mqtt.h:188
bool xRetain
Whether this is a retained message.
Definition: azure_iot_mqtt.h:163
Subscription info for the MQTT client.
Definition: azure_iot_mqtt.h:133
const uint8_t * pcTopicFilter
Topic filter to subscribe to.
Definition: azure_iot_mqtt.h:142
AzureIoTMQTTQoS_t xQoS
Quality of Service for subscription.
Definition: azure_iot_mqtt.h:137
uint16_t usTopicFilterLength
Length of subscription topic filter.
Definition: azure_iot_mqtt.h:147
The transport layer interface.
Definition: azure_iot_transport_interface.h:159