AWS IoT Device SDK C: MQTT
MQTT 3.1.1 client library
Return to main page ↑
iot_mqtt_protocol.h File Reference

This file contains MQTT 3.1.1 specific defines. This is a common header to be included for building a single threaded light-weight MQTT client as well as stateful CSDK MQTT library. More...

Go to the source code of this file.

Macros

#define MQTT_PACKET_TYPE_CONNECT   ( ( uint8_t ) 0x10U )
 CONNECT (client-to-server).
 
#define MQTT_PACKET_TYPE_CONNACK   ( ( uint8_t ) 0x20U )
 CONNACK (server-to-client).
 
#define MQTT_PACKET_TYPE_PUBLISH   ( ( uint8_t ) 0x30U )
 PUBLISH (bidirectional).
 
#define MQTT_PACKET_TYPE_PUBACK   ( ( uint8_t ) 0x40U )
 PUBACK (server-to-client).
 
#define MQTT_PACKET_TYPE_SUBSCRIBE   ( ( uint8_t ) 0x82U )
 SUBSCRIBE (client-to-server).
 
#define MQTT_PACKET_TYPE_SUBACK   ( ( uint8_t ) 0x90U )
 SUBACK (server-to-client).
 
#define MQTT_PACKET_TYPE_UNSUBSCRIBE   ( ( uint8_t ) 0xa2U )
 UNSUBSCRIBE (client-to-server).
 
#define MQTT_PACKET_TYPE_UNSUBACK   ( ( uint8_t ) 0xb0U )
 UNSUBACK (server-to-client).
 
#define MQTT_PACKET_TYPE_PINGREQ   ( ( uint8_t ) 0xc0U )
 PINGREQ (client-to-server).
 
#define MQTT_PACKET_TYPE_PINGRESP   ( ( uint8_t ) 0xd0U )
 PINGRESP (server-to-client).
 
#define MQTT_PACKET_TYPE_DISCONNECT   ( ( uint8_t ) 0xe0U )
 DISCONNECT (client-to-server).
 
#define MQTT_CONNECT_FLAG_CLEAN   ( 1 )
 Clean session.
 
#define MQTT_CONNECT_FLAG_WILL   ( 2 )
 Will present.
 
#define MQTT_CONNECT_FLAG_WILL_QOS1   ( 3 )
 Will QoS1.
 
#define MQTT_CONNECT_FLAG_WILL_QOS2   ( 4 )
 Will QoS2.
 
#define MQTT_CONNECT_FLAG_WILL_RETAIN   ( 5 )
 Will retain.
 
#define MQTT_CONNECT_FLAG_PASSWORD   ( 6 )
 Password present.
 
#define MQTT_CONNECT_FLAG_USERNAME   ( 7 )
 Username present.
 
#define MQTT_PUBLISH_FLAG_RETAIN   ( 0 )
 Message retain flag.
 
#define MQTT_PUBLISH_FLAG_QOS1   ( 1 )
 Publish QoS 1.
 
#define MQTT_PUBLISH_FLAG_QOS2   ( 2 )
 Publish QoS 2.
 
#define MQTT_PUBLISH_FLAG_DUP   ( 3 )
 Duplicate message.
 
#define MQTT_REMAINING_LENGTH_INVALID   ( ( size_t ) 268435456 )
 A value that represents an invalid remaining length. More...
 
#define MQTT_PACKET_CONNECT_MAX_SIZE   ( 327700UL )
 The maximum possible size of a CONNECT packet. More...
 
#define MQTT_MIN_PUBLISH_REMAINING_LENGTH_QOS0   ( 3U )
 The minimum remaining length for a QoS 0 PUBLISH. More...
 
#define MQTT_MAX_REMAINING_LENGTH   ( 268435455UL )
 Per the MQTT 3.1.1 spec, the largest "Remaining Length" of an MQTT packet is this value.
 
#define MQTT_VERSION_3_1_1   ( ( uint8_t ) 4U )
 The constant specifying MQTT version 3.1.1. Placed in the CONNECT packet.
 
#define MQTT_PACKET_CONNACK_REMAINING_LENGTH   ( ( uint8_t ) 2U )
 A CONNACK packet always has a "Remaining length" of 2.
 
#define MQTT_PACKET_CONNACK_SESSION_PRESENT_MASK   ( ( uint8_t ) 0x01U )
 The "Session Present" bit is always the lowest bit.
 
#define MQTT_PACKET_PUBACK_SIZE   ( 4U )
 A PUBACK packet is always 4 bytes in size.
 
#define MQTT_PACKET_PUBACK_REMAINING_LENGTH   ( ( uint8_t ) 2 )
 A PUBACK packet always has a "Remaining length" of 2.
 
#define MQTT_PACKET_SUBACK_MINIMUM_SIZE   ( 5U )
 The size of the smallest valid SUBACK packet.
 
#define MQTT_PACKET_UNSUBACK_REMAINING_LENGTH   ( ( uint8_t ) 2 )
 An UNSUBACK packet always has a "Remaining length" of 2.
 
#define MQTT_PACKET_PINGREQ_SIZE   ( 2U )
 A PINGREQ packet is always 2 bytes in size.
 
#define MQTT_PACKET_PINGRESP_REMAINING_LENGTH   ( 0U )
 A PINGRESP packet always has a "Remaining length" of 0.
 
#define MQTT_PACKET_DISCONNECT_SIZE   ( 2U )
 A DISCONNECT packet is always 2 bytes in size.
 

Detailed Description

This file contains MQTT 3.1.1 specific defines. This is a common header to be included for building a single threaded light-weight MQTT client as well as stateful CSDK MQTT library.

Macro Definition Documentation

◆ MQTT_REMAINING_LENGTH_INVALID

#define MQTT_REMAINING_LENGTH_INVALID   ( ( size_t ) 268435456 )

A value that represents an invalid remaining length.

This value is greater than what is allowed by the MQTT specification.

◆ MQTT_PACKET_CONNECT_MAX_SIZE

#define MQTT_PACKET_CONNECT_MAX_SIZE   ( 327700UL )

The maximum possible size of a CONNECT packet.

All strings in a CONNECT packet are constrained to 2-byte lengths, giving a maximum length smaller than the max "Remaining Length" constant above.

◆ MQTT_MIN_PUBLISH_REMAINING_LENGTH_QOS0

#define MQTT_MIN_PUBLISH_REMAINING_LENGTH_QOS0   ( 3U )

The minimum remaining length for a QoS 0 PUBLISH.

Includes two bytes for topic name length and one byte for topic name.