30#ifndef CORE_MQTT_SERIALIZER_H
31#define CORE_MQTT_SERIALIZER_H
40#ifndef MQTT_DO_NOT_USE_CUSTOM_CONFIG
42 #include "core_mqtt_config.h"
57#define MQTT_PACKET_TYPE_CONNECT ( ( uint8_t ) 0x10U )
58#define MQTT_PACKET_TYPE_CONNACK ( ( uint8_t ) 0x20U )
59#define MQTT_PACKET_TYPE_PUBLISH ( ( uint8_t ) 0x30U )
60#define MQTT_PACKET_TYPE_PUBACK ( ( uint8_t ) 0x40U )
61#define MQTT_PACKET_TYPE_PUBREC ( ( uint8_t ) 0x50U )
62#define MQTT_PACKET_TYPE_PUBREL ( ( uint8_t ) 0x62U )
63#define MQTT_PACKET_TYPE_PUBCOMP ( ( uint8_t ) 0x70U )
64#define MQTT_PACKET_TYPE_SUBSCRIBE ( ( uint8_t ) 0x82U )
65#define MQTT_PACKET_TYPE_SUBACK ( ( uint8_t ) 0x90U )
66#define MQTT_PACKET_TYPE_UNSUBSCRIBE ( ( uint8_t ) 0xA2U )
67#define MQTT_PACKET_TYPE_UNSUBACK ( ( uint8_t ) 0xB0U )
68#define MQTT_PACKET_TYPE_PINGREQ ( ( uint8_t ) 0xC0U )
69#define MQTT_PACKET_TYPE_PINGRESP ( ( uint8_t ) 0xD0U )
70#define MQTT_PACKET_TYPE_DISCONNECT ( ( uint8_t ) 0xE0U )
77#define MQTT_PUBLISH_ACK_PACKET_SIZE ( 4UL )
80struct MQTTFixedBuffer;
81struct MQTTConnectInfo;
82struct MQTTSubscribeInfo;
83struct MQTTPublishInfo;
90typedef enum MQTTStatus
123typedef struct MQTTFixedBuffer
133typedef struct MQTTConnectInfo
180typedef struct MQTTSubscribeInfo
202typedef struct MQTTPublishInfo
244typedef struct MQTTPacketInfo
312 size_t * pRemainingLength,
313 size_t * pPacketSize );
368 size_t remainingLength,
425 size_t subscriptionCount,
426 size_t * pRemainingLength,
427 size_t * pPacketSize );
491 size_t subscriptionCount,
493 size_t remainingLength,
542 size_t subscriptionCount,
543 size_t * pRemainingLength,
544 size_t * pPacketSize );
608 size_t subscriptionCount,
610 size_t remainingLength,
662 size_t * pRemainingLength,
663 size_t * pPacketSize );
731 size_t remainingLength,
811 size_t remainingLength,
813 size_t * pHeaderSize );
1060 uint16_t * pPacketId,
1104 uint16_t * pPacketId,
1105 bool * pSessionPresent );
This represents the default values for the configuration macros for the MQTT library.
MQTTStatus_t MQTT_GetPingreqPacketSize(size_t *pPacketSize)
Get the size of an MQTT PINGREQ packet.
Definition: core_mqtt_serializer.c:2167
MQTTStatus_t MQTT_SerializeAck(const MQTTFixedBuffer_t *pFixedBuffer, uint8_t packetType, uint16_t packetId)
Serialize an MQTT PUBACK, PUBREC, PUBREL, or PUBCOMP into the given buffer.
Definition: core_mqtt_serializer.c:2049
MQTTStatus_t MQTT_SerializeSubscribe(const MQTTSubscribeInfo_t *pSubscriptionList, size_t subscriptionCount, uint16_t packetId, size_t remainingLength, const MQTTFixedBuffer_t *pFixedBuffer)
Serialize an MQTT SUBSCRIBE packet in the given buffer.
Definition: core_mqtt_serializer.c:1697
MQTTStatus_t MQTT_GetUnsubscribePacketSize(const MQTTSubscribeInfo_t *pSubscriptionList, size_t subscriptionCount, size_t *pRemainingLength, size_t *pPacketSize)
Get packet size and Remaining Length of an MQTT UNSUBSCRIBE packet.
Definition: core_mqtt_serializer.c:1751
MQTTStatus_t MQTT_DeserializePublish(const MQTTPacketInfo_t *pIncomingPacket, uint16_t *pPacketId, MQTTPublishInfo_t *pPublishInfo)
Deserialize an MQTT PUBLISH packet.
Definition: core_mqtt_serializer.c:2230
MQTTStatus_t MQTT_GetConnectPacketSize(const MQTTConnectInfo_t *pConnectInfo, const MQTTPublishInfo_t *pWillInfo, size_t *pRemainingLength, size_t *pPacketSize)
Get the size and Remaining Length of an MQTT CONNECT packet.
Definition: core_mqtt_serializer.c:1501
MQTTStatus_t MQTT_SerializePublishHeader(const MQTTPublishInfo_t *pPublishInfo, uint16_t packetId, size_t remainingLength, const MQTTFixedBuffer_t *pFixedBuffer, size_t *pHeaderSize)
Serialize an MQTT PUBLISH packet header in the given buffer.
Definition: core_mqtt_serializer.c:1966
MQTTStatus_t MQTT_SerializeDisconnect(const MQTTFixedBuffer_t *pFixedBuffer)
Serialize an MQTT DISCONNECT packet into the given buffer.
Definition: core_mqtt_serializer.c:2124
MQTTStatus_t MQTT_GetDisconnectPacketSize(size_t *pPacketSize)
Get the size of an MQTT DISCONNECT packet.
Definition: core_mqtt_serializer.c:2104
MQTTStatus_t MQTT_GetIncomingPacketTypeAndLength(TransportRecv_t readFunc, NetworkContext_t *pNetworkContext, MQTTPacketInfo_t *pIncomingPacket)
Extract the MQTT packet type and length from incoming packet.
Definition: core_mqtt_serializer.c:2344
MQTTStatus_t MQTT_GetPublishPacketSize(const MQTTPublishInfo_t *pPublishInfo, size_t *pRemainingLength, size_t *pPacketSize)
Get the packet size and remaining length of an MQTT PUBLISH packet.
Definition: core_mqtt_serializer.c:1840
MQTTStatus_t MQTT_SerializeConnect(const MQTTConnectInfo_t *pConnectInfo, const MQTTPublishInfo_t *pWillInfo, size_t remainingLength, const MQTTFixedBuffer_t *pFixedBuffer)
Serialize an MQTT CONNECT packet in the given fixed buffer pFixedBuffer.
Definition: core_mqtt_serializer.c:1601
MQTTStatus_t MQTT_SerializeUnsubscribe(const MQTTSubscribeInfo_t *pSubscriptionList, size_t subscriptionCount, uint16_t packetId, size_t remainingLength, const MQTTFixedBuffer_t *pFixedBuffer)
Serialize an MQTT UNSUBSCRIBE packet in the given buffer.
Definition: core_mqtt_serializer.c:1789
MQTTStatus_t MQTT_GetSubscribePacketSize(const MQTTSubscribeInfo_t *pSubscriptionList, size_t subscriptionCount, size_t *pRemainingLength, size_t *pPacketSize)
Get packet size and Remaining Length of an MQTT SUBSCRIBE packet.
Definition: core_mqtt_serializer.c:1659
MQTTStatus_t MQTT_SerializePublish(const MQTTPublishInfo_t *pPublishInfo, uint16_t packetId, size_t remainingLength, const MQTTFixedBuffer_t *pFixedBuffer)
Serialize an MQTT PUBLISH packet in the given buffer.
Definition: core_mqtt_serializer.c:1881
MQTTStatus_t MQTT_DeserializeAck(const MQTTPacketInfo_t *pIncomingPacket, uint16_t *pPacketId, bool *pSessionPresent)
Deserialize an MQTT CONNACK, SUBACK, UNSUBACK, PUBACK, PUBREC, PUBREL, PUBCOMP, or PINGRESP.
Definition: core_mqtt_serializer.c:2267
MQTTStatus_t MQTT_SerializePingreq(const MQTTFixedBuffer_t *pFixedBuffer)
Serialize an MQTT PINGREQ packet into the given buffer.
Definition: core_mqtt_serializer.c:2187
int32_t(* TransportRecv_t)(NetworkContext_t *pNetworkContext, void *pBuffer, size_t bytesToRecv)
Transport interface for receiving data on the network.
Definition: transport_interface.h:213
MQTTStatus_t
Return codes from MQTT functions.
Definition: core_mqtt_serializer.h:91
MQTTQoS_t
MQTT Quality of Service values.
Definition: core_mqtt_serializer.h:110
@ MQTTKeepAliveTimeout
Definition: core_mqtt_serializer.h:102
@ MQTTServerRefused
Definition: core_mqtt_serializer.h:98
@ MQTTSuccess
Definition: core_mqtt_serializer.h:92
@ MQTTNoDataAvailable
Definition: core_mqtt_serializer.h:99
@ MQTTIllegalState
Definition: core_mqtt_serializer.h:100
@ MQTTStateCollision
Definition: core_mqtt_serializer.h:101
@ MQTTRecvFailed
Definition: core_mqtt_serializer.h:96
@ MQTTBadParameter
Definition: core_mqtt_serializer.h:93
@ MQTTBadResponse
Definition: core_mqtt_serializer.h:97
@ MQTTNoMemory
Definition: core_mqtt_serializer.h:94
@ MQTTSendFailed
Definition: core_mqtt_serializer.h:95
@ MQTTQoS1
Definition: core_mqtt_serializer.h:112
@ MQTTQoS2
Definition: core_mqtt_serializer.h:113
@ MQTTQoS0
Definition: core_mqtt_serializer.h:111
struct NetworkContext NetworkContext_t
The NetworkContext is an incomplete type. An implementation of this interface must define struct Netw...
Definition: transport_interface.h:183
MQTT CONNECT packet parameters.
Definition: core_mqtt_serializer.h:134
const char * pClientIdentifier
MQTT client identifier. Must be unique per client.
Definition: core_mqtt_serializer.h:148
const char * pUserName
MQTT user name. Set to NULL if not used.
Definition: core_mqtt_serializer.h:158
bool cleanSession
Whether to establish a new, clean session or resume a previous session.
Definition: core_mqtt_serializer.h:138
uint16_t userNameLength
Length of MQTT user name. Set to 0 if not used.
Definition: core_mqtt_serializer.h:163
uint16_t keepAliveSeconds
MQTT keep alive period.
Definition: core_mqtt_serializer.h:143
uint16_t clientIdentifierLength
Length of the client identifier.
Definition: core_mqtt_serializer.h:153
uint16_t passwordLength
Length of MQTT password. Set to 0 if not used.
Definition: core_mqtt_serializer.h:173
const char * pPassword
MQTT password. Set to NULL if not used.
Definition: core_mqtt_serializer.h:168
Buffer passed to MQTT library.
Definition: core_mqtt_serializer.h:124
size_t size
Size of buffer.
Definition: core_mqtt_serializer.h:126
uint8_t * pBuffer
Pointer to buffer.
Definition: core_mqtt_serializer.h:125
MQTT incoming packet parameters.
Definition: core_mqtt_serializer.h:245
size_t remainingLength
Length of remaining serialized data.
Definition: core_mqtt_serializer.h:259
uint8_t type
Type of incoming MQTT packet.
Definition: core_mqtt_serializer.h:249
uint8_t * pRemainingData
Remaining serialized data in the MQTT packet.
Definition: core_mqtt_serializer.h:254
MQTT PUBLISH packet parameters.
Definition: core_mqtt_serializer.h:203
MQTTQoS_t qos
Quality of Service for message.
Definition: core_mqtt_serializer.h:207
bool retain
Whether this is a retained message.
Definition: core_mqtt_serializer.h:212
uint16_t topicNameLength
Length of topic name.
Definition: core_mqtt_serializer.h:227
size_t payloadLength
Message payload length.
Definition: core_mqtt_serializer.h:237
bool dup
Whether this is a duplicate publish message.
Definition: core_mqtt_serializer.h:217
const char * pTopicName
Topic name on which the message is published.
Definition: core_mqtt_serializer.h:222
const void * pPayload
Message payload.
Definition: core_mqtt_serializer.h:232
MQTT SUBSCRIBE packet parameters.
Definition: core_mqtt_serializer.h:181
MQTTQoS_t qos
Quality of Service for subscription.
Definition: core_mqtt_serializer.h:185
uint16_t topicFilterLength
Length of subscription topic filter.
Definition: core_mqtt_serializer.h:195
const char * pTopicFilter
Topic filter to subscribe to.
Definition: core_mqtt_serializer.h:190
Transport interface definitions to send and receive data over the network.