Azure IoT middleware for FreeRTOS
|
Azure IoT MQTT is the MQTT interface that AzureIoT middleware depends upon. More...
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include "azure_iot_mqtt_port.h"
#include "azure_iot_transport_interface.h"
Go to the source code of this file.
Data Structures | |
struct | AzureIoTMQTTConnectInfo |
Connection info for the MQTT client. More... | |
struct | AzureIoTMQTTSubscribeInfo |
Subscription info for the MQTT client. More... | |
struct | AzureIoTMQTTPublishInfo |
Publish info for the MQTT client. More... | |
struct | AzureIoTMQTTDeserializedInfo |
MQTT packet deserialized info for the MQTT client. More... | |
struct | AzureIoTMQTTPacketInfo |
MQTT packet info for the MQTT client. More... | |
Macros | |
#define | azureiotmqttPACKET_TYPE_CONNECT ( ( uint8_t ) 0x10U ) |
CONNECT (client-to-server). | |
#define | azureiotmqttPACKET_TYPE_CONNACK ( ( uint8_t ) 0x20U ) |
CONNACK (server-to-client). | |
#define | azureiotmqttPACKET_TYPE_PUBLISH ( ( uint8_t ) 0x30U ) |
PUBLISH (bidirectional). | |
#define | azureiotmqttPACKET_TYPE_PUBACK ( ( uint8_t ) 0x40U ) |
PUBACK (bidirectional). | |
#define | azureiotmqttPACKET_TYPE_PUBREC ( ( uint8_t ) 0x50U ) |
PUBREC (bidirectional). | |
#define | azureiotmqttPACKET_TYPE_PUBREL ( ( uint8_t ) 0x62U ) |
PUBREL (bidirectional). | |
#define | azureiotmqttPACKET_TYPE_PUBCOMP ( ( uint8_t ) 0x70U ) |
PUBCOMP (bidirectional). | |
#define | azureiotmqttPACKET_TYPE_SUBSCRIBE ( ( uint8_t ) 0x82U ) |
SUBSCRIBE (client-to-server). | |
#define | azureiotmqttPACKET_TYPE_SUBACK ( ( uint8_t ) 0x90U ) |
SUBACK (server-to-client). | |
#define | azureiotmqttPACKET_TYPE_UNSUBSCRIBE ( ( uint8_t ) 0xA2U ) |
UNSUBSCRIBE (client-to-server). | |
#define | azureiotmqttPACKET_TYPE_UNSUBACK ( ( uint8_t ) 0xB0U ) |
UNSUBACK (server-to-client). | |
#define | azureiotmqttPACKET_TYPE_PINGREQ ( ( uint8_t ) 0xC0U ) |
PINGREQ (client-to-server). | |
#define | azureiotmqttPACKET_TYPE_PINGRESP ( ( uint8_t ) 0xD0U ) |
PINGRESP (server-to-client). | |
#define | azureiotmqttPACKET_TYPE_DISCONNECT ( ( uint8_t ) 0xE0U ) |
DISCONNECT (client-to-server). | |
#define | azureiotmqttGET_PACKET_TYPE(ucType) ( ( ucType ) & 0xF0U ) |
Get the packet type according to the MQTT spec. | |
Typedefs | |
typedef enum AzureIoTMQTTQoS | AzureIoTMQTTQoS_t |
Quality of service values. | |
typedef enum AzureIoTMQTTSubAckStatus | AzureIoTMQTTSubAckStatus_t |
MQTT suback ack status states. | |
typedef enum AzureIoTMQTTResult | AzureIoTMQTTResult_t |
Result values used for Azure IoT MQTT functions. | |
typedef struct AzureIoTMQTTConnectInfo | AzureIoTMQTTConnectInfo_t |
Connection info for the MQTT client. | |
typedef struct AzureIoTMQTTSubscribeInfo | AzureIoTMQTTSubscribeInfo_t |
Subscription info for the MQTT client. | |
typedef struct AzureIoTMQTTPublishInfo | AzureIoTMQTTPublishInfo_t |
Publish info for the MQTT client. | |
typedef struct AzureIoTMQTTDeserializedInfo | AzureIoTMQTTDeserializedInfo_t |
MQTT packet deserialized info for the MQTT client. | |
typedef struct AzureIoTMQTTPacketInfo | AzureIoTMQTTPacketInfo_t |
MQTT packet info for the MQTT client. | |
typedef AzureIoTMQTT_t * | AzureIoTMQTTHandle_t |
Typedef of the MQTT client which is defined by the MQTT port. | |
typedef uint32_t(* | AzureIoTMQTTGetCurrentTimeFunc_t) (void) |
The time function to be used for MQTT functionality. More... | |
typedef 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. | |
Enumerations | |
enum | AzureIoTMQTTQoS { eAzureIoTMQTTQoS0 = 0 , eAzureIoTMQTTQoS1 = 1 , eAzureIoTMQTTQoS2 = 2 } |
Quality of service values. More... | |
enum | AzureIoTMQTTSubAckStatus { eMQTTSubAckSuccessQos0 = 0x00 , eMQTTSubAckSuccessQos1 = 0x01 , eMQTTSubAckSuccessQos2 = 0x02 , eMQTTSubAckFailure = 0x80 } |
MQTT suback ack status states. More... | |
enum | AzureIoTMQTTResult { eAzureIoTMQTTSuccess = 0 , eAzureIoTMQTTBadParameter , eAzureIoTMQTTNoMemory , eAzureIoTMQTTSendFailed , eAzureIoTMQTTRecvFailed , eAzureIoTMQTTBadResponse , eAzureIoTMQTTServerRefused , eAzureIoTMQTTNoDataAvailable , eAzureIoTMQTTIllegalState , eAzureIoTMQTTStateCollision , eAzureIoTMQTTKeepAliveTimeout , eAzureIoTMQTTFailed } |
Result values used for Azure IoT MQTT functions. More... | |
Functions | |
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. More... | |
AzureIoTMQTTResult_t | AzureIoTMQTT_Connect (AzureIoTMQTTHandle_t xContext, const AzureIoTMQTTConnectInfo_t *pxConnectInfo, const AzureIoTMQTTPublishInfo_t *pxWillInfo, uint32_t ulMilliseconds, bool *pxSessionPresent) |
Establish an MQTT session. More... | |
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. More... | |
AzureIoTMQTTResult_t | AzureIoTMQTT_Publish (AzureIoTMQTTHandle_t xContext, const AzureIoTMQTTPublishInfo_t *pxPublishInfo, uint16_t usPacketId) |
Publishes a message to the given topic name. More... | |
AzureIoTMQTTResult_t | AzureIoTMQTT_Ping (AzureIoTMQTTHandle_t xContext) |
Sends a MQTT PINGREQ to broker. More... | |
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. More... | |
AzureIoTMQTTResult_t | AzureIoTMQTT_Disconnect (AzureIoTMQTTHandle_t xContext) |
Disconnect a MQTT session. More... | |
AzureIoTMQTTResult_t | AzureIoTMQTT_ProcessLoop (AzureIoTMQTTHandle_t xContext, uint32_t ulMilliseconds) |
Loop to receive packets from the transport interface. Handles keep alive. More... | |
uint16_t | AzureIoTMQTT_GetPacketId (AzureIoTMQTTHandle_t xContext) |
Get a packet ID. More... | |
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 subscription requests from the original subscribe packet. More... | |
Azure IoT MQTT is the MQTT interface that AzureIoT middleware depends upon.
typedef uint32_t( * AzureIoTMQTTGetCurrentTimeFunc_t) (void) |
The time function to be used for MQTT functionality.
enum AzureIoTMQTTQoS |
enum AzureIoTMQTTResult |
Result values used for Azure IoT MQTT functions.
AzureIoTMQTTResult_t AzureIoTMQTT_Connect | ( | AzureIoTMQTTHandle_t | xContext, |
const AzureIoTMQTTConnectInfo_t * | pxConnectInfo, | ||
const AzureIoTMQTTPublishInfo_t * | pxWillInfo, | ||
uint32_t | ulMilliseconds, | ||
bool * | pxSessionPresent | ||
) |
Establish an MQTT session.
This function will send MQTT CONNECT packet and receive a CONNACK packet. The send and receive from the network is done through the transport interface.
[in] | xContext | Initialized AzureIoTMQTT context. |
[in] | pxConnectInfo | MQTT CONNECT packet information. |
[in] | pxWillInfo | Last Will and Testament. Pass NULL if Last Will and Testament is not used. |
[in] | ulMilliseconds | Maximum time in milliseconds to wait for a CONNACK packet. |
[out] | pxSessionPresent | Whether a previous session was present. Only relevant if not establishing a clean session. |
AzureIoTMQTTResult_t AzureIoTMQTT_Disconnect | ( | AzureIoTMQTTHandle_t | xContext | ) |
Disconnect a MQTT session.
[in] | xContext | Initialized AzureIoTMQTT context. |
uint16_t AzureIoTMQTT_GetPacketId | ( | AzureIoTMQTTHandle_t | xContext | ) |
Get a packet ID.
[in] | xContext | Initialized AzureIoTMQTT context. |
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 subscription requests from the original subscribe packet.
Each return code in the SUBACK packet corresponds to a topic filter in the SUBSCRIBE Packet being acknowledged. The status codes can be one of the following:
[in] | pxSubackPacket | The SUBACK packet whose payload is to be parsed. |
[out] | ppucPayloadStart | This is populated with the starting address of the payload (or return codes for topic filters) in the SUBACK packet. |
[out] | pxPayloadSize | This is populated with the size of the payload in the SUBACK packet. It represents the number of topic filters whose SUBACK status is present in the packet. |
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.
[in] | xContext | The AzureIoTMQTT context to initialize. |
[in] | pxTransportInterface | The transport interface to use with the context. |
[in] | xGetTimeFunction | The time utility function to use with the context. |
[in] | xUserCallback | The user callback to use with the context to notify about incoming packet events. |
[in] | pucNetworkBuffer | Network buffer provided for the context. |
[in] | xNetworkBufferLength | Length of network buffer. |
AzureIoTMQTTResult_t AzureIoTMQTT_Ping | ( | AzureIoTMQTTHandle_t | xContext | ) |
Sends a MQTT PINGREQ to broker.
[in] | xContext | Initialized AzureIoTMQTT context. |
AzureIoTMQTTResult_t AzureIoTMQTT_ProcessLoop | ( | AzureIoTMQTTHandle_t | xContext, |
uint32_t | ulMilliseconds | ||
) |
Loop to receive packets from the transport interface. Handles keep alive.
[in] | xContext | Initialized AzureIoTMQTT context. |
[in] | ulMilliseconds | Minimum time in milliseconds that the process loop will run, unless an error occurs. |
AzureIoTMQTTResult_t AzureIoTMQTT_Publish | ( | AzureIoTMQTTHandle_t | xContext, |
const AzureIoTMQTTPublishInfo_t * | pxPublishInfo, | ||
uint16_t | usPacketId | ||
) |
Publishes a message to the given topic name.
[in] | xContext | Initialized AzureIoTMQTT context. |
[in] | pxPublishInfo | MQTT PUBLISH packet parameters. |
[in] | usPacketId | packet ID ( generated by AzureIoTMQTT_GetPacketId ). |
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.
[in] | xContext | Initialized AzureIoTMQTT context. |
[in] | pxSubscriptionList | List of MQTT subscription infos. |
[in] | xSubscriptionCount | The number of elements in pxSubscriptionList. |
[in] | usPacketId | Packet ID ( generated by AzureIoTMQTT_GetPacketId ). |
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.
[in] | xContext | Initialized AzureIoTMQTT context. |
[in] | pxSubscriptionList | List of MQTT subscription infos. |
[in] | xSubscriptionCount | The number of elements in pxSubscriptionList. |
[in] | usPacketId | packet ID ( generated by AzureIoTMQTT_GetPacketId ). |