30#ifndef CORE_MQTT_SERIALIZER_H
31#define CORE_MQTT_SERIALIZER_H
46#ifndef MQTT_DO_NOT_USE_CUSTOM_CONFIG
48 #include "core_mqtt_config.h"
63#define MQTT_PACKET_TYPE_CONNECT ( ( uint8_t ) 0x10U )
64#define MQTT_PACKET_TYPE_CONNACK ( ( uint8_t ) 0x20U )
65#define MQTT_PACKET_TYPE_PUBLISH ( ( uint8_t ) 0x30U )
66#define MQTT_PACKET_TYPE_PUBACK ( ( uint8_t ) 0x40U )
67#define MQTT_PACKET_TYPE_PUBREC ( ( uint8_t ) 0x50U )
68#define MQTT_PACKET_TYPE_PUBREL ( ( uint8_t ) 0x62U )
69#define MQTT_PACKET_TYPE_PUBCOMP ( ( uint8_t ) 0x70U )
70#define MQTT_PACKET_TYPE_SUBSCRIBE ( ( uint8_t ) 0x82U )
71#define MQTT_PACKET_TYPE_SUBACK ( ( uint8_t ) 0x90U )
72#define MQTT_PACKET_TYPE_UNSUBSCRIBE ( ( uint8_t ) 0xA2U )
73#define MQTT_PACKET_TYPE_UNSUBACK ( ( uint8_t ) 0xB0U )
74#define MQTT_PACKET_TYPE_PINGREQ ( ( uint8_t ) 0xC0U )
75#define MQTT_PACKET_TYPE_PINGRESP ( ( uint8_t ) 0xD0U )
76#define MQTT_PACKET_TYPE_DISCONNECT ( ( uint8_t ) 0xE0U )
83#define MQTT_PUBLISH_ACK_PACKET_SIZE ( 4UL )
86struct MQTTFixedBuffer;
87struct MQTTConnectInfo;
88struct MQTTSubscribeInfo;
89struct MQTTPublishInfo;
96typedef enum MQTTStatus
129typedef struct MQTTFixedBuffer
139typedef struct MQTTConnectInfo
186typedef struct MQTTSubscribeInfo
208typedef struct MQTTPublishInfo
250typedef struct MQTTPacketInfo
318 size_t * pRemainingLength,
319 size_t * pPacketSize );
374 size_t remainingLength,
431 size_t subscriptionCount,
432 size_t * pRemainingLength,
433 size_t * pPacketSize );
497 size_t subscriptionCount,
499 size_t remainingLength,
548 size_t subscriptionCount,
549 size_t * pRemainingLength,
550 size_t * pPacketSize );
614 size_t subscriptionCount,
616 size_t remainingLength,
668 size_t * pRemainingLength,
669 size_t * pPacketSize );
737 size_t remainingLength,
817 size_t remainingLength,
819 size_t * pHeaderSize );
1066 uint16_t * pPacketId,
1110 uint16_t * pPacketId,
1111 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:2174
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:2056
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:1704
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:1758
MQTTStatus_t MQTT_DeserializePublish(const MQTTPacketInfo_t *pIncomingPacket, uint16_t *pPacketId, MQTTPublishInfo_t *pPublishInfo)
Deserialize an MQTT PUBLISH packet.
Definition: core_mqtt_serializer.c:2237
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:1508
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:1973
MQTTStatus_t MQTT_SerializeDisconnect(const MQTTFixedBuffer_t *pFixedBuffer)
Serialize an MQTT DISCONNECT packet into the given buffer.
Definition: core_mqtt_serializer.c:2131
MQTTStatus_t MQTT_GetDisconnectPacketSize(size_t *pPacketSize)
Get the size of an MQTT DISCONNECT packet.
Definition: core_mqtt_serializer.c:2111
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:2351
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:1847
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:1608
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:1796
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:1666
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:1888
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:2274
MQTTStatus_t MQTT_SerializePingreq(const MQTTFixedBuffer_t *pFixedBuffer)
Serialize an MQTT PINGREQ packet into the given buffer.
Definition: core_mqtt_serializer.c:2194
int32_t(* TransportRecv_t)(NetworkContext_t *pNetworkContext, void *pBuffer, size_t bytesToRecv)
Transport interface for receiving data on the network.
Definition: transport_interface.h:219
MQTTStatus_t
Return codes from MQTT functions.
Definition: core_mqtt_serializer.h:97
MQTTQoS_t
MQTT Quality of Service values.
Definition: core_mqtt_serializer.h:116
@ MQTTKeepAliveTimeout
Definition: core_mqtt_serializer.h:108
@ MQTTServerRefused
Definition: core_mqtt_serializer.h:104
@ MQTTSuccess
Definition: core_mqtt_serializer.h:98
@ MQTTNoDataAvailable
Definition: core_mqtt_serializer.h:105
@ MQTTIllegalState
Definition: core_mqtt_serializer.h:106
@ MQTTStateCollision
Definition: core_mqtt_serializer.h:107
@ MQTTRecvFailed
Definition: core_mqtt_serializer.h:102
@ MQTTBadParameter
Definition: core_mqtt_serializer.h:99
@ MQTTBadResponse
Definition: core_mqtt_serializer.h:103
@ MQTTNoMemory
Definition: core_mqtt_serializer.h:100
@ MQTTSendFailed
Definition: core_mqtt_serializer.h:101
@ MQTTQoS1
Definition: core_mqtt_serializer.h:118
@ MQTTQoS2
Definition: core_mqtt_serializer.h:119
@ MQTTQoS0
Definition: core_mqtt_serializer.h:117
struct NetworkContext NetworkContext_t
The NetworkContext is an incomplete type. An implementation of this interface must define struct Netw...
Definition: transport_interface.h:189
MQTT CONNECT packet parameters.
Definition: core_mqtt_serializer.h:140
const char * pClientIdentifier
MQTT client identifier. Must be unique per client.
Definition: core_mqtt_serializer.h:154
const char * pUserName
MQTT user name. Set to NULL if not used.
Definition: core_mqtt_serializer.h:164
bool cleanSession
Whether to establish a new, clean session or resume a previous session.
Definition: core_mqtt_serializer.h:144
uint16_t userNameLength
Length of MQTT user name. Set to 0 if not used.
Definition: core_mqtt_serializer.h:169
uint16_t keepAliveSeconds
MQTT keep alive period.
Definition: core_mqtt_serializer.h:149
uint16_t clientIdentifierLength
Length of the client identifier.
Definition: core_mqtt_serializer.h:159
uint16_t passwordLength
Length of MQTT password. Set to 0 if not used.
Definition: core_mqtt_serializer.h:179
const char * pPassword
MQTT password. Set to NULL if not used.
Definition: core_mqtt_serializer.h:174
Buffer passed to MQTT library.
Definition: core_mqtt_serializer.h:130
size_t size
Size of buffer.
Definition: core_mqtt_serializer.h:132
uint8_t * pBuffer
Pointer to buffer.
Definition: core_mqtt_serializer.h:131
MQTT incoming packet parameters.
Definition: core_mqtt_serializer.h:251
size_t remainingLength
Length of remaining serialized data.
Definition: core_mqtt_serializer.h:265
uint8_t type
Type of incoming MQTT packet.
Definition: core_mqtt_serializer.h:255
uint8_t * pRemainingData
Remaining serialized data in the MQTT packet.
Definition: core_mqtt_serializer.h:260
MQTT PUBLISH packet parameters.
Definition: core_mqtt_serializer.h:209
MQTTQoS_t qos
Quality of Service for message.
Definition: core_mqtt_serializer.h:213
bool retain
Whether this is a retained message.
Definition: core_mqtt_serializer.h:218
uint16_t topicNameLength
Length of topic name.
Definition: core_mqtt_serializer.h:233
size_t payloadLength
Message payload length.
Definition: core_mqtt_serializer.h:243
bool dup
Whether this is a duplicate publish message.
Definition: core_mqtt_serializer.h:223
const char * pTopicName
Topic name on which the message is published.
Definition: core_mqtt_serializer.h:228
const void * pPayload
Message payload.
Definition: core_mqtt_serializer.h:238
MQTT SUBSCRIBE packet parameters.
Definition: core_mqtt_serializer.h:187
MQTTQoS_t qos
Quality of Service for subscription.
Definition: core_mqtt_serializer.h:191
uint16_t topicFilterLength
Length of subscription topic filter.
Definition: core_mqtt_serializer.h:201
const char * pTopicFilter
Topic filter to subscribe to.
Definition: core_mqtt_serializer.h:196
Transport interface definitions to send and receive data over the network.