mqtt_common.h File Reference

Definitions common to MQTT client and server. More...

#include "core/net.h"

Go to the source code of this file.

Macros

#define MQTT_PORT   1883
 
#define MQTT_TLS_PORT   8883
 
#define MQTT_PROTOCOL_NAME_3_1   "MQIsdp"
 
#define MQTT_PROTOCOL_NAME_3_1_1   "MQTT"
 
#define MQTT_MIN_HEADER_SIZE   2
 
#define MQTT_MAX_HEADER_SIZE   5
 

Enumerations

enum  MqttVersion { MQTT_VERSION_3_1 = 3, MQTT_VERSION_3_1_1 = 4 }
 MQTT protocol level. More...
 
enum  MqttTransportProtocol { MQTT_TRANSPORT_PROTOCOL_TCP = 1, MQTT_TRANSPORT_PROTOCOL_TLS = 2, MQTT_TRANSPORT_PROTOCOL_WS = 3, MQTT_TRANSPORT_PROTOCOL_WSS = 4 }
 Transport protocol. More...
 
enum  MqttQosLevel { MQTT_QOS_LEVEL_0 = 0, MQTT_QOS_LEVEL_1 = 1, MQTT_QOS_LEVEL_2 = 2 }
 Quality of service level. More...
 
enum  MqttPacketType {
  MQTT_PACKET_TYPE_INVALID = 0, MQTT_PACKET_TYPE_CONNECT = 1, MQTT_PACKET_TYPE_CONNACK = 2, MQTT_PACKET_TYPE_PUBLISH = 3,
  MQTT_PACKET_TYPE_PUBACK = 4, MQTT_PACKET_TYPE_PUBREC = 5, MQTT_PACKET_TYPE_PUBREL = 6, MQTT_PACKET_TYPE_PUBCOMP = 7,
  MQTT_PACKET_TYPE_SUBSCRIBE = 8, MQTT_PACKET_TYPE_SUBACK = 9, MQTT_PACKET_TYPE_UNSUBSCRIBE = 10, MQTT_PACKET_TYPE_UNSUBACK = 11,
  MQTT_PACKET_TYPE_PINGREQ = 12, MQTT_PACKET_TYPE_PINGRESP = 13, MQTT_PACKET_TYPE_DISCONNECT = 14
}
 MQTT control packet type. More...
 
enum  MqttConnectFlags {
  MQTT_CONNECT_FLAG_CLEAN_SESSION = 0x02, MQTT_CONNECT_FLAG_WILL = 0x04, MQTT_CONNECT_FLAG_WILL_QOS_0 = 0x00, MQTT_CONNECT_FLAG_WILL_QOS_1 = 0x08,
  MQTT_CONNECT_FLAG_WILL_QOS_2 = 0x10, MQTT_CONNECT_FLAG_WILL_RETAIN = 0x20, MQTT_CONNECT_FLAG_PASSWORD = 0x40, MQTT_CONNECT_FLAG_USERNAME = 0x80
}
 Connect flags. More...
 
enum  MqttConnectAckFlags { MQTT_CONNECT_ACK_FLAG_SESSION_PRESENT = 0x01 }
 Connect Acknowledge flags. More...
 
enum  MqttConnectRetCode {
  MQTT_CONNECT_RET_CODE_ACCEPTED = 0, MQTT_CONNECT_RET_CODE_UNACCEPTABLE_VERSION = 1, MQTT_CONNECT_RET_CODE_ID_REJECTED = 2, MQTT_CONNECT_RET_CODE_SERVER_UNAVAILABLE = 3,
  MQTT_CONNECT_RET_CODE_BAD_USER_NAME = 4, MQTT_CONNECT_RET_CODE_NOT_AUTHORIZED = 5
}
 Connect return codes. More...
 

Variables

typedef __packed_struct
 Fixed header. More...
 
uint8_t qos
 
uint8_t dup
 
uint8_t type
 
uint8_t length []
 
 MqttPacketHeader
 
uint8_t data []
 
 MqttString
 

Detailed Description

Definitions common to MQTT client and server.

License

SPDX-License-Identifier: GPL-2.0-or-later

Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.

This file is part of CycloneTCP Open.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.4

Definition in file mqtt_common.h.

Macro Definition Documentation

◆ MQTT_MAX_HEADER_SIZE

#define MQTT_MAX_HEADER_SIZE   5

Definition at line 50 of file mqtt_common.h.

◆ MQTT_MIN_HEADER_SIZE

#define MQTT_MIN_HEADER_SIZE   2

Definition at line 48 of file mqtt_common.h.

◆ MQTT_PORT

#define MQTT_PORT   1883

Definition at line 38 of file mqtt_common.h.

◆ MQTT_PROTOCOL_NAME_3_1

#define MQTT_PROTOCOL_NAME_3_1   "MQIsdp"

Definition at line 43 of file mqtt_common.h.

◆ MQTT_PROTOCOL_NAME_3_1_1

#define MQTT_PROTOCOL_NAME_3_1_1   "MQTT"

Definition at line 45 of file mqtt_common.h.

◆ MQTT_TLS_PORT

#define MQTT_TLS_PORT   8883

Definition at line 40 of file mqtt_common.h.

Enumeration Type Documentation

◆ MqttConnectAckFlags

Connect Acknowledge flags.

Enumerator
MQTT_CONNECT_ACK_FLAG_SESSION_PRESENT 

Definition at line 139 of file mqtt_common.h.

◆ MqttConnectFlags

Connect flags.

Enumerator
MQTT_CONNECT_FLAG_CLEAN_SESSION 
MQTT_CONNECT_FLAG_WILL 
MQTT_CONNECT_FLAG_WILL_QOS_0 
MQTT_CONNECT_FLAG_WILL_QOS_1 
MQTT_CONNECT_FLAG_WILL_QOS_2 
MQTT_CONNECT_FLAG_WILL_RETAIN 
MQTT_CONNECT_FLAG_PASSWORD 
MQTT_CONNECT_FLAG_USERNAME 

Definition at line 122 of file mqtt_common.h.

◆ MqttConnectRetCode

Connect return codes.

Enumerator
MQTT_CONNECT_RET_CODE_ACCEPTED 
MQTT_CONNECT_RET_CODE_UNACCEPTABLE_VERSION 
MQTT_CONNECT_RET_CODE_ID_REJECTED 
MQTT_CONNECT_RET_CODE_SERVER_UNAVAILABLE 
MQTT_CONNECT_RET_CODE_BAD_USER_NAME 
MQTT_CONNECT_RET_CODE_NOT_AUTHORIZED 

Definition at line 149 of file mqtt_common.h.

◆ MqttPacketType

MQTT control packet type.

Enumerator
MQTT_PACKET_TYPE_INVALID 

Invalid packet.

MQTT_PACKET_TYPE_CONNECT 

Client request to connect to server.

MQTT_PACKET_TYPE_CONNACK 

Connect acknowledgment.

MQTT_PACKET_TYPE_PUBLISH 

Publish message.

MQTT_PACKET_TYPE_PUBACK 

Publish acknowledgment.

MQTT_PACKET_TYPE_PUBREC 

Publish received (assured delivery part 1)

MQTT_PACKET_TYPE_PUBREL 

Publish release (assured delivery part 2)

MQTT_PACKET_TYPE_PUBCOMP 

Publish complete (assured delivery part 3)

MQTT_PACKET_TYPE_SUBSCRIBE 

Client subscribe request.

MQTT_PACKET_TYPE_SUBACK 

Subscribe acknowledgment.

MQTT_PACKET_TYPE_UNSUBSCRIBE 

Unsubscribe request.

MQTT_PACKET_TYPE_UNSUBACK 

Unsubscribe acknowledgment.

MQTT_PACKET_TYPE_PINGREQ 

Ping request.

MQTT_PACKET_TYPE_PINGRESP 

Ping response.

MQTT_PACKET_TYPE_DISCONNECT 

Client is disconnecting.

Definition at line 98 of file mqtt_common.h.

◆ MqttQosLevel

Quality of service level.

Enumerator
MQTT_QOS_LEVEL_0 

At most once delivery.

MQTT_QOS_LEVEL_1 

At least once delivery.

MQTT_QOS_LEVEL_2 

Exactly once delivery.

Definition at line 86 of file mqtt_common.h.

◆ MqttTransportProtocol

Transport protocol.

Enumerator
MQTT_TRANSPORT_PROTOCOL_TCP 
MQTT_TRANSPORT_PROTOCOL_TLS 

TCP protocol.

MQTT_TRANSPORT_PROTOCOL_WS 

TLS protocol.

MQTT_TRANSPORT_PROTOCOL_WSS 

WebSocket protocol.

Definition at line 73 of file mqtt_common.h.

◆ MqttVersion

MQTT protocol level.

Enumerator
MQTT_VERSION_3_1 

MQTT version 3.1.

MQTT_VERSION_3_1_1 

MQTT version 3.1.1.

Definition at line 62 of file mqtt_common.h.

Variable Documentation

◆ __packed_struct

typedef __packed_struct
Initial value:
{
uint8_t retain : 1

Fixed header.

UTF-8 encoded string.

Definition at line 172 of file mqtt_common.h.

◆ data

uint8_t data[]

Definition at line 196 of file mqtt_common.h.

◆ dup

uint8_t dup

Definition at line 182 of file mqtt_common.h.

◆ length

uint8_t length[]

Definition at line 185 of file mqtt_common.h.

◆ MqttPacketHeader

MqttPacketHeader

Definition at line 186 of file mqtt_common.h.

◆ MqttString

MqttString

Definition at line 197 of file mqtt_common.h.

◆ qos

uint8_t qos

Definition at line 181 of file mqtt_common.h.

◆ type

uint8_t type

Definition at line 183 of file mqtt_common.h.