AWS IoT Device SDK C:
MQTT
MQTT 3.1.1 client library
|
Return to main page ↑ |
MQTT library types. More...
#include "iot_config.h"
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include "types/iot_platform_types.h"
#include "platform/iot_network.h"
Go to the source code of this file.
Data Structures | |
struct | IotMqttPublishInfo_t |
Information on a PUBLISH message. More... | |
struct | IotMqttCallbackParam_t |
Parameter to an MQTT callback function. More... | |
struct | IotMqttCallbackInfo_t |
MQTT callback function and context. More... | |
struct | IotMqttSubscription_t |
MQTT subscription. More... | |
struct | IotMqttConnectInfo_t |
MQTT connection details. More... | |
struct | IotMqttPacketInfo_t |
MQTT packet details. More... | |
struct | IotMqttSerializer_t |
Function pointers for MQTT packet serializer overrides. More... | |
struct | IotMqttNetworkInfo_t |
MQTT network connection details. More... | |
Macros | |
#define | IOT_MQTT_NETWORK_INFO_INITIALIZER { .createNetworkConnection = true } |
Initializer for IotMqttNetworkInfo_t. | |
#define | IOT_MQTT_SERIALIZER_INITIALIZER { 0 } |
Initializer for IotMqttSerializer_t. | |
#define | IOT_MQTT_CONNECT_INFO_INITIALIZER { .cleanSession = true } |
Initializer for IotMqttConnectInfo_t. | |
#define | IOT_MQTT_PUBLISH_INFO_INITIALIZER { .qos = IOT_MQTT_QOS_0 } |
Initializer for IotMqttPublishInfo_t. | |
#define | IOT_MQTT_SUBSCRIPTION_INITIALIZER { .qos = IOT_MQTT_QOS_0 } |
Initializer for IotMqttSubscription_t. | |
#define | IOT_MQTT_CALLBACK_INFO_INITIALIZER { 0 } |
Initializer for IotMqttCallbackInfo_t. | |
#define | IOT_MQTT_CONNECTION_INITIALIZER NULL |
Initializer for IotMqttConnection_t. | |
#define | IOT_MQTT_OPERATION_INITIALIZER NULL |
Initializer for IotMqttOperation_t. | |
#define | IOT_MQTT_PACKET_INFO_INITIALIZER { .pRemainingData = NULL, remainingLength = 0, packetIdentifier = 0, .type = 0 } |
Initializer for IotMqttPacketInfo_t. | |
#define | IOT_MQTT_FLAG_WAITABLE ( 0x00000001U ) |
Allows the use of IotMqtt_Wait for blocking until completion. More... | |
#define | IOT_MQTT_FLAG_CLEANUP_ONLY ( 0x00000001UL ) |
Causes IotMqtt_Disconnect to only free memory and not send an MQTT DISCONNECT packet. More... | |
Typedefs | |
typedef struct _mqttConnection * | IotMqttConnection_t |
Opaque handle of an MQTT connection. More... | |
typedef struct _mqttOperation * | IotMqttOperation_t |
Opaque handle that references an in-progress MQTT operation. More... | |
typedef uint8_t(* | IotMqttGetPacketType_t) (IotNetworkConnection_t pNetworkConnection, const IotNetworkInterface_t *pNetworkInterface) |
Get the MQTT packet type from a stream of bytes off the network. More... | |
typedef size_t(* | IotMqttGetRemainingLength_t) (IotNetworkConnection_t pNetworkConnection, const IotNetworkInterface_t *pNetworkInterface) |
Get the remaining length from a stream of bytes off the network. More... | |
typedef void(* | IotMqttFreePacket_t) (uint8_t *pPacket) |
Free a packet generated by the serializer. More... | |
typedef IotMqttError_t(* | IotMqttSerializeConnect_t) (const IotMqttConnectInfo_t *pConnectInfo, uint8_t **pConnectPacket, size_t *pPacketSize) |
CONNECT packet serializer function. More... | |
typedef IotMqttError_t(* | IotMqttSerializePingreq_t) (uint8_t **pPingreqPacket, size_t *pPacketSize) |
PINGREQ packet serializer function. More... | |
typedef IotMqttError_t(* | IotMqtt_SerializePublish_t) (const IotMqttPublishInfo_t *pPublishInfo, uint8_t **pPublishPacket, size_t *pPacketSize, uint16_t *pPacketIdentifier, uint8_t **pPacketIdentifierHigh) |
PUBLISH packet serializer function. More... | |
typedef IotMqttError_t(* | IotMqttSerializeSubscribe_t) (const IotMqttSubscription_t *pSubscriptionList, size_t subscriptionCount, uint8_t **pSubscribePacket, size_t *pPacketSize, uint16_t *pPacketIdentifier) |
SUBSCRIBE/UNSUBSCRIBE packet serializer function. More... | |
typedef IotMqttError_t(* | IotMqttSerializeDisconnect_t) (uint8_t **pDisconnectPacket, size_t *pPacketSize) |
DISCONNECT packet serializer function. More... | |
typedef IotMqttError_t(* | IotMqttDeserialize_t) (struct _mqttPacket *pMqttPacket) |
MQTT packet deserializer function. More... | |
typedef IotMqttError_t(* | IotMqttSerializePuback_t) (uint16_t packetIdentifier, uint8_t **pPubackPacket, size_t *pPacketSize) |
PUBACK packet serializer function. More... | |
typedef void(* | IotMqttPublishSetDup_t) (uint8_t *pPublishPacket, uint8_t *pPacketIdentifierHigh, uint16_t *pNewPacketIdentifier) |
Set the DUP bit in a QoS 1 PUBLISH packet. More... | |
typedef IotMqttError_t(* | IotMqttGetNextByte_t) (IotNetworkConnection_t pNetworkContext, uint8_t *pNextByte) |
Function pointer to read the next available byte on a network connection. More... | |
Enumerations | |
enum | IotMqttError_t { IOT_MQTT_SUCCESS = 0, IOT_MQTT_STATUS_PENDING = 1, IOT_MQTT_INIT_FAILED = 2, IOT_MQTT_BAD_PARAMETER = 3, IOT_MQTT_NO_MEMORY = 4, IOT_MQTT_NETWORK_ERROR = 5, IOT_MQTT_SCHEDULING_ERROR = 6, IOT_MQTT_BAD_RESPONSE = 7, IOT_MQTT_TIMEOUT = 8, IOT_MQTT_SERVER_REFUSED = 9, IOT_MQTT_RETRY_NO_RESPONSE = 10, IOT_MQTT_NOT_INITIALIZED = 11 } |
Return codes of MQTT functions. More... | |
enum | IotMqttOperationType_t { IOT_MQTT_CONNECT, IOT_MQTT_PUBLISH_TO_SERVER, IOT_MQTT_PUBACK, IOT_MQTT_SUBSCRIBE, IOT_MQTT_UNSUBSCRIBE, IOT_MQTT_PINGREQ, IOT_MQTT_DISCONNECT } |
Types of MQTT operations. More... | |
enum | IotMqttQos_t { IOT_MQTT_QOS_0 = 0, IOT_MQTT_QOS_1 = 1, IOT_MQTT_QOS_2 = 2 } |
Quality of service levels for MQTT PUBLISH messages. More... | |
enum | IotMqttDisconnectReason_t { IOT_MQTT_DISCONNECT_CALLED, IOT_MQTT_BAD_PACKET_RECEIVED, IOT_MQTT_KEEP_ALIVE_TIMEOUT } |
The reason that an MQTT connection (and its associated network connection) was disconnected. More... | |
MQTT library types.
#define IOT_MQTT_FLAG_WAITABLE ( 0x00000001U ) |
Allows the use of IotMqtt_Wait for blocking until completion.
This flag is always valid for IotMqtt_SubscribeAsync and IotMqtt_UnsubscribeAsync. If passed to IotMqtt_PublishAsync, the parameter pPublishInfo->qos must not be 0
.
An IotMqttOperation_t MUST be provided if this flag is set. Additionally, an IotMqttCallbackInfo_t MUST NOT be provided.
#define IOT_MQTT_FLAG_CLEANUP_ONLY ( 0x00000001UL ) |
Causes IotMqtt_Disconnect to only free memory and not send an MQTT DISCONNECT packet.
This flag is only valid for IotMqtt_Disconnect. It should be passed to IotMqtt_Disconnect if the network goes offline or is otherwise unusable.
typedef uint8_t( * IotMqttGetPacketType_t) (IotNetworkConnection_t pNetworkConnection, const IotNetworkInterface_t *pNetworkInterface) |
Get the MQTT packet type from a stream of bytes off the network.
[in] | pNetworkConnection | Reference to the network connection. |
[in] | pNetworkInterface | Function pointers used to interact with the network. |
typedef size_t( * IotMqttGetRemainingLength_t) (IotNetworkConnection_t pNetworkConnection, const IotNetworkInterface_t *pNetworkInterface) |
Get the remaining length from a stream of bytes off the network.
[in] | pNetworkConnection | Reference to the network connection. |
[in] | pNetworkInterface | Function pointers used to interact with the network. |
typedef void( * IotMqttFreePacket_t) (uint8_t *pPacket) |
Free a packet generated by the serializer.
This function pointer must be set if any other serializer override is set.
[in] | uint8_t* | The packet to free. |
typedef IotMqttError_t( * IotMqttSerializeConnect_t) (const IotMqttConnectInfo_t *pConnectInfo, uint8_t **pConnectPacket, size_t *pPacketSize) |
CONNECT packet serializer function.
[in] | IotMqttConnectInfo_t* | User-provided CONNECT information. |
[out] | uint8_t** | Where the CONNECT packet is written. |
[out] | size_t* | Size of the CONNECT packet. |
typedef IotMqttError_t( * IotMqttSerializePingreq_t) (uint8_t **pPingreqPacket, size_t *pPacketSize) |
PINGREQ packet serializer function.
[out] | uint8_t** | Where the PINGREQ packet is written. |
[out] | size_t* | Size of the PINGREQ packet. |
typedef IotMqttError_t( * IotMqtt_SerializePublish_t) (const IotMqttPublishInfo_t *pPublishInfo, uint8_t **pPublishPacket, size_t *pPacketSize, uint16_t *pPacketIdentifier, uint8_t **pPacketIdentifierHigh) |
PUBLISH packet serializer function.
[in] | IotMqttPublishInfo_t* | User-provided PUBLISH information. |
[out] | uint8_t** | Where the PUBLISH packet is written. |
[out] | size_t* | Size of the PUBLISH packet. |
[out] | uint16_t* | The packet identifier generated for this PUBLISH. |
[out] | uint8_t** | Where the high byte of the packet identifier is written. |
typedef IotMqttError_t( * IotMqttSerializeSubscribe_t) (const IotMqttSubscription_t *pSubscriptionList, size_t subscriptionCount, uint8_t **pSubscribePacket, size_t *pPacketSize, uint16_t *pPacketIdentifier) |
SUBSCRIBE/UNSUBSCRIBE packet serializer function.
[in] | IotMqttSubscription_t* | User-provided array of subscriptions. |
[in] | size_t | Number of elements in the subscription array. |
[out] | uint8_t** | Where the SUBSCRIBE packet is written. |
[out] | size_t* | Size of the SUBSCRIBE packet. |
[out] | uint16_t* | The packet identifier generated for this SUBSCRIBE. |
typedef IotMqttError_t( * IotMqttSerializeDisconnect_t) (uint8_t **pDisconnectPacket, size_t *pPacketSize) |
DISCONNECT packet serializer function.
[out] | uint8_t** | Where the DISCONNECT packet is written. |
[out] | size_t* | Size of the DISCONNECT packet. |
typedef IotMqttError_t( * IotMqttDeserialize_t) (struct _mqttPacket *pMqttPacket) |
MQTT packet deserializer function.
[in,out] | _mqttPacket* | Pointer to an MQTT packet structure |
typedef IotMqttError_t( * IotMqttSerializePuback_t) (uint16_t packetIdentifier, uint8_t **pPubackPacket, size_t *pPacketSize) |
PUBACK packet serializer function.
[in] | uint16_t | The packet identifier to place in PUBACK. |
[out] | uint8_t** | Where the PUBACK packet is written. |
[out] | size_t* | Size of the PUBACK packet. |
typedef void( * IotMqttPublishSetDup_t) (uint8_t *pPublishPacket, uint8_t *pPacketIdentifierHigh, uint16_t *pNewPacketIdentifier) |
Set the DUP
bit in a QoS 1
PUBLISH packet.
[in] | uint8_t* | Pointer to the PUBLISH packet to modify. |
[in] | uint8_t* | The high byte of any packet identifier to modify. |
[out] | uint16_t* | New packet identifier (AWS IoT MQTT mode only). |
typedef IotMqttError_t(* IotMqttGetNextByte_t) (IotNetworkConnection_t pNetworkContext, uint8_t *pNextByte) |
Function pointer to read the next available byte on a network connection.
[in] | pNetworkContext | reference to network connection like socket. |
[out] | pNextByte | Pointer to the byte read from the network. |