MQTT API Reference
MQTT 3.1.1 client library
iot_mqtt_types.h File Reference

Types of the MQTT library. More...

#include "iot_config.h"
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include "types/iot_platform_types.h"
#include "types/iot_taskpool_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
 Information on a user-provided MQTT callback function. More...
 
struct  IotMqttSubscription_t
 Information on an MQTT subscription. More...
 
struct  IotMqttConnectInfo_t
 Information on a new MQTT connection. More...
 
struct  IotMqttSerializer_t
 Function pointers for MQTT packet serializer overrides. More...
 
struct  IotMqttNetworkInfo_t
 Infomation on the transport-layer network connection for the new MQTT connection. 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_FLAG_WAITABLE   ( 0x00000001 )
 Allows the use of IotMqtt_Wait for blocking until completion. More...
 
#define IOT_MQTT_FLAG_CLEANUP_ONLY   ( 0x00000001 )
 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...
 

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...
 

Detailed Description

Types of the MQTT library.

Macro Definition Documentation

◆ IOT_MQTT_FLAG_WAITABLE

#define IOT_MQTT_FLAG_WAITABLE   ( 0x00000001 )

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.

Note
If this flag is set, IotMqtt_Wait MUST be called to clean up resources.

◆ IOT_MQTT_FLAG_CLEANUP_ONLY

#define IOT_MQTT_FLAG_CLEANUP_ONLY   ( 0x00000001 )

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.