Implements the user-facing functions in core_mqtt_serializer.h. More...
#include <string.h>#include <assert.h>#include <inttypes.h>#include <stdbool.h>#include "core_mqtt.h"#include "core_mqtt_serializer.h"#include "transport_interface.h"#include "private/core_mqtt_serializer_private.h"#include "core_mqtt_config_defaults.h"Data Structures | |
| struct | ConnackSeenFlags_t |
| Tracks which CONNACK properties have been seen during deserialization, used to detect duplicates. More... | |
Functions | |
| static void | serializePublishCommon (const MQTTPublishInfo_t *pPublishInfo, const MQTTPropBuilder_t *pPublishProperties, uint32_t remainingLength, uint16_t packetIdentifier, const MQTTFixedBuffer_t *pFixedBuffer, bool serializePayload) |
| Serializes MQTT PUBLISH packet into the buffer provided. | |
| static MQTTStatus_t | calculatePublishPacketSize (const MQTTPublishInfo_t *pPublishInfo, uint32_t *pRemainingLength, uint32_t *pPacketSize, uint32_t maxPacketSize, uint32_t publishPropertyLength) |
| Calculates the packet size and remaining length of an MQTT PUBLISH packet. | |
| static MQTTStatus_t | calculateSubscriptionPacketSize (const MQTTSubscribeInfo_t *pSubscriptionList, size_t subscriptionCount, uint32_t *pRemainingLength, uint32_t *pPacketSize, uint32_t subscribePropLen, uint32_t maxPacketSize, MQTTSubscriptionType_t subscriptionType) |
| Calculates the packet size and remaining length of an MQTT SUBSCRIBE or UNSUBSCRIBE packet. | |
| static MQTTStatus_t | validateSubscriptionSerializeParams (const MQTTSubscribeInfo_t *pSubscriptionList, size_t subscriptionCount, uint16_t packetId, uint32_t remainingLength, const MQTTFixedBuffer_t *pFixedBuffer) |
| Validates parameters of MQTT_SerializeSubscribe or MQTT_SerializeUnsubscribe. | |
| static void | serializeConnectPacket (const MQTTConnectInfo_t *pConnectInfo, const MQTTPublishInfo_t *pWillInfo, const MQTTPropBuilder_t *pConnectProperties, const MQTTPropBuilder_t *pWillProperties, uint32_t remainingLength, const MQTTFixedBuffer_t *pFixedBuffer) |
| Serialize an MQTT CONNECT packet in the given buffer. | |
| static void | logConnackResponse (uint8_t responseCode) |
| Prints the appropriate message for the CONNACK response code if logs are enabled. | |
| static uint32_t | remainingLengthEncodedSize (uint32_t length) |
| Retrieve the size of the remaining length if it were to be encoded. | |
| static uint32_t | getRemainingLength (TransportRecv_t recvFunc, NetworkContext_t *pNetworkContext) |
| Retrieves and decodes the Remaining Length from the network interface by reading a single byte at a time. | |
| static MQTTStatus_t | processRemainingLength (const uint8_t *pBuffer, const size_t *pIndex, MQTTPacketInfo_t *pIncomingPacket) |
| Retrieves, decodes and stores the Remaining Length from the network interface by reading a single byte at a time. | |
| static bool | incomingPacketValid (uint8_t packetType) |
| Check if an incoming packet type is valid. | |
| static MQTTStatus_t | checkPublishRemainingLength (uint32_t remainingLength, MQTTQoS_t qos, uint32_t qos0Minimum) |
| Check the remaining length of an incoming PUBLISH packet against some value for QoS 0, or for QoS 1 and 2. | |
| static MQTTStatus_t | processPublishFlags (uint8_t publishFlags, MQTTPublishInfo_t *pPublishInfo) |
| Process the flags of an incoming PUBLISH packet. | |
| static MQTTStatus_t | deserializeConnack (MQTTConnectionProperties_t *pConnackProperties, const MQTTPacketInfo_t *pIncomingPacket, bool *pSessionPresent, MQTTPropBuilder_t *pPropBuffer) |
| Deserialize an MQTT CONNACK packet. | |
| static MQTTStatus_t | readSubackStatus (size_t statusCount, const uint8_t *pStatusStart, MQTTReasonCodeInfo_t *pReasonCodes) |
| Decode the status bytes of a SUBACK packet to a MQTTStatus_t. | |
| static MQTTStatus_t | deserializeSubUnsubAck (const MQTTPacketInfo_t *incomingPacket, uint16_t *pPacketId, MQTTReasonCodeInfo_t *pReasonCodes, MQTTPropBuilder_t *pPropBuffer) |
| Deserialize an MQTT SUBACK / UNSUBACK packet. | |
| static MQTTStatus_t | deserializePublish (const MQTTPacketInfo_t *pIncomingPacket, uint16_t *pPacketId, MQTTPublishInfo_t *pPublishInfo, MQTTPropBuilder_t *pPropBuffer, uint16_t topicAliasMax) |
| Deserialize a PUBLISH packet received from the server. | |
| static MQTTStatus_t | deserializePingresp (const MQTTPacketInfo_t *pPingresp) |
| Deserialize a PINGRESP packet. | |
| static MQTTStatus_t | validateConnackParams (const MQTTPacketInfo_t *pIncomingPacket, bool *pSessionPresent) |
| Validate the connack parameters. | |
| static MQTTStatus_t | deserializeConnackProperties (MQTTConnectionProperties_t *pConnackProperties, uint32_t length, uint8_t *pIndex, MQTTPropBuilder_t *pPropBuffer) |
| Validate the length and decode the connack properties. | |
| static MQTTStatus_t | deserializeSubUnsubAckProperties (MQTTPropBuilder_t *pPropBuffer, uint8_t *pIndex, size_t *pSubackPropertyLength, uint32_t remainingLength) |
| Deserialize properties in the SUBACK packet received from the server. | |
| static MQTTStatus_t | deserializePubAcks (const MQTTPacketInfo_t *pAck, uint16_t *pPacketIdentifier, MQTTReasonCodeInfo_t *pReasonCode, bool requestProblem, MQTTPropBuilder_t *pPropBuffer) |
| Deserialize an PUBACK, PUBREC, PUBREL, or PUBCOMP packet. | |
| static MQTTStatus_t | decodePubAckProperties (MQTTPropBuilder_t *pPropBuffer, uint8_t *pIndex, uint32_t remainingLength) |
| Validate the length and decode the publish ack properties. | |
| static MQTTStatus_t | logAckResponse (MQTTSuccessFailReasonCode_t reasonCode, uint16_t packetIdentifier) |
| Prints the appropriate message for the PUBREL, PUBACK response code if logs are enabled. | |
| static MQTTStatus_t | deserializePublishProperties (MQTTPublishInfo_t *pPublishInfo, MQTTPropBuilder_t *pPropBuffer, uint8_t *pIndex, uint16_t topicAliasMax, uint32_t remainingLength) |
| Deserialize properties in the PUBLISH packet received from the server. | |
| static MQTTStatus_t | validateDisconnectResponse (MQTTSuccessFailReasonCode_t reasonCode, bool incoming) |
| Prints and validates the appropriate message for the Disconnect response code if logs are enabled. | |
| static MQTTStatus_t | validateReasonCodeForAck (uint8_t ackPacketType, MQTTSuccessFailReasonCode_t reasonCode) |
| Validates the reason codes for the given ACK packet type. | |
| static MQTTStatus_t | isValidConnackReasonCode (uint8_t reasonCode) |
| Validate if a reason code is valid for CONNACK packets. | |
| static MQTTStatus_t | validateIncomingDisconnectProperties (uint8_t *pIndex, uint32_t disconnectPropertyLength) |
| Validate properties in the DISCONNECT packet received from the server. | |
| static MQTTStatus_t | deserializeConnackProperty (uint8_t propertyId, MQTTConnectionProperties_t *pConnackProperties, uint32_t *pPropertyLength, uint8_t **ppVariableHeader, MQTTPropBuilder_t *pPropBuffer, ConnackSeenFlags_t *pSeen) |
| Decode and validate a single CONNACK property from the incoming packet. | |
| static void | setConnackPropBit (MQTTPropBuilder_t *pPropBuffer, uint8_t bitPos) |
| Set a bit in pPropBuffer->fieldSet if pPropBuffer is not NULL. | |
| static MQTTStatus_t | validateBoolProp (uint8_t value, const char *pPropName) |
| Validate that a uint8 property value is 0 or 1 (boolean). | |
| static MQTTStatus_t | decodeConnackBoolProp (uint8_t *pDest, uint32_t *pPropertyLength, bool *pSeen, uint8_t **ppIndex, const char *pPropName, MQTTPropBuilder_t *pPropBuffer, uint8_t bitPos) |
| Decode a uint8 boolean CONNACK property, validate it, and record it. | |
| MQTTStatus_t | MQTT_SerializePublishHeaderWithoutTopic (const MQTTPublishInfo_t *pPublishInfo, uint32_t remainingLength, uint8_t *pBuffer, size_t *headerSize) |
| Serialize an MQTT PUBLISH packet header without the topic string in the given buffer. This function will add the topic string length to the provided buffer. This helps reduce an unnecessary copy of the topic string into the buffer. | |
| MQTTStatus_t | updateContextWithConnectProps (const MQTTPropBuilder_t *pPropBuilder, MQTTConnectionProperties_t *pConnectProperties) |
| Updates the MQTT context with connect properties from the property builder. | |
| MQTTStatus_t | MQTT_GetConnectPacketSize (const MQTTConnectInfo_t *pConnectInfo, const MQTTPublishInfo_t *pWillInfo, const MQTTPropBuilder_t *pConnectProperties, const MQTTPropBuilder_t *pWillProperties, uint32_t *pRemainingLength, uint32_t *pPacketSize) |
| Get the size and Remaining Length of an MQTT Version 5 CONNECT packet. | |
| MQTTStatus_t | MQTT_SerializeConnect (const MQTTConnectInfo_t *pConnectInfo, const MQTTPublishInfo_t *pWillInfo, const MQTTPropBuilder_t *pConnectProperties, const MQTTPropBuilder_t *pWillProperties, uint32_t remainingLength, const MQTTFixedBuffer_t *pFixedBuffer) |
Serialize an MQTT CONNECT packet in the given fixed buffer pFixedBuffer. | |
| MQTTStatus_t | MQTT_GetSubscribePacketSize (const MQTTSubscribeInfo_t *pSubscriptionList, size_t subscriptionCount, const MQTTPropBuilder_t *pSubscribeProperties, uint32_t *pRemainingLength, uint32_t *pPacketSize, uint32_t maxPacketSize) |
| Get packet size and Remaining Length of an MQTT SUBSCRIBE packet. | |
| MQTTStatus_t | MQTT_SerializeSubscribe (const MQTTSubscribeInfo_t *pSubscriptionList, size_t subscriptionCount, const MQTTPropBuilder_t *pSubscribeProperties, uint16_t packetId, uint32_t remainingLength, const MQTTFixedBuffer_t *pFixedBuffer) |
| Serialize an MQTT SUBSCRIBE packet in the given buffer. | |
| MQTTStatus_t | MQTT_GetUnsubscribePacketSize (const MQTTSubscribeInfo_t *pSubscriptionList, size_t subscriptionCount, const MQTTPropBuilder_t *pUnsubscribeProperties, uint32_t *pRemainingLength, uint32_t *pPacketSize, uint32_t maxPacketSize) |
| Get packet size and Remaining Length of an MQTT UNSUBSCRIBE packet. | |
| MQTTStatus_t | MQTT_ValidateUnsubscribeProperties (const MQTTPropBuilder_t *pPropertyBuilder) |
| Validates the properties specified for an MQTT UNSUBSCRIBE packet. | |
| MQTTStatus_t | MQTT_SerializeUnsubscribe (const MQTTSubscribeInfo_t *pSubscriptionList, size_t subscriptionCount, const MQTTPropBuilder_t *pUnsubscribeProperties, uint16_t packetId, uint32_t remainingLength, const MQTTFixedBuffer_t *pFixedBuffer) |
| Serialize an MQTT UNSUBSCRIBE packet with properties in the given buffer. | |
| MQTTStatus_t | MQTT_GetPublishPacketSize (const MQTTPublishInfo_t *pPublishInfo, const MQTTPropBuilder_t *pPublishProperties, uint32_t *pRemainingLength, uint32_t *pPacketSize, uint32_t maxPacketSize) |
| Get the packet size and remaining length of an MQTT PUBLISH packet. | |
| MQTTStatus_t | MQTT_SerializePublish (const MQTTPublishInfo_t *pPublishInfo, const MQTTPropBuilder_t *pPublishProperties, uint16_t packetId, uint32_t remainingLength, const MQTTFixedBuffer_t *pFixedBuffer) |
| Serialize an MQTT PUBLISH packet in the given buffer. | |
| MQTTStatus_t | MQTT_SerializePublishHeader (const MQTTPublishInfo_t *pPublishInfo, const MQTTPropBuilder_t *pPublishProperties, uint16_t packetId, uint32_t remainingLength, const MQTTFixedBuffer_t *pFixedBuffer, size_t *pHeaderSize) |
| Serialize an MQTT PUBLISH packet header in the given buffer. | |
| static MQTTStatus_t | serializeAckWithProperties (const MQTTFixedBuffer_t *pFixedBuffer, uint8_t packetType, uint16_t packetId, const MQTTPropBuilder_t *pAckProperties, const MQTTSuccessFailReasonCode_t *pReasonCode) |
| Serialize a publish ACK packet with properties into pFixedBuffer. Called only when pReasonCode != NULL and pAckProperties != NULL. | |
| static MQTTStatus_t | serializeAckBody (const MQTTFixedBuffer_t *pFixedBuffer, uint8_t packetType, uint16_t packetId, const MQTTPropBuilder_t *pAckProperties, const MQTTSuccessFailReasonCode_t *pReasonCode) |
| Validate parameters and serialize a publish ACK packet body. Handles the three cases: no reason code, reason code only, reason code + properties. | |
| MQTTStatus_t | MQTT_SerializeAck (const MQTTFixedBuffer_t *pFixedBuffer, uint8_t packetType, uint16_t packetId, const MQTTPropBuilder_t *pAckProperties, const MQTTSuccessFailReasonCode_t *pReasonCode) |
| Serialize an MQTT PUBACK, PUBREC, PUBREL, or PUBCOMP into the given buffer. | |
| MQTTStatus_t | MQTT_GetDisconnectPacketSize (const MQTTPropBuilder_t *pDisconnectProperties, uint32_t *pRemainingLength, uint32_t *pPacketSize, uint32_t maxPacketSize, const MQTTSuccessFailReasonCode_t *pReasonCode) |
| Get the size of an MQTT DISCONNECT packet. | |
| MQTTStatus_t | MQTT_SerializeDisconnect (const MQTTPropBuilder_t *pDisconnectProperties, const MQTTSuccessFailReasonCode_t *pReasonCode, uint32_t remainingLength, const MQTTFixedBuffer_t *pFixedBuffer) |
| Serialize an MQTT DISCONNECT packet into the given buffer. | |
| MQTTStatus_t | MQTT_GetPingreqPacketSize (uint32_t *pPacketSize) |
| Get the size of an MQTT PINGREQ packet. | |
| MQTTStatus_t | MQTT_SerializePingreq (const MQTTFixedBuffer_t *pFixedBuffer) |
| Serialize an MQTT PINGREQ packet into the given buffer. | |
| MQTTStatus_t | MQTT_DeserializePublish (const MQTTPacketInfo_t *pIncomingPacket, uint16_t *pPacketId, MQTTPublishInfo_t *pPublishInfo, MQTTPropBuilder_t *propBuffer, uint32_t maxPacketSize, uint16_t topicAliasMax) |
| Deserialize an MQTT PUBLISH packet. | |
| MQTTStatus_t | MQTT_DeserializeConnAck (const MQTTPacketInfo_t *pIncomingPacket, bool *pSessionPresent, MQTTPropBuilder_t *pPropBuffer, MQTTConnectionProperties_t *pConnectProperties) |
| Deserialize an MQTT CONNACK. | |
| MQTTStatus_t | MQTT_DeserializeAck (const MQTTPacketInfo_t *pIncomingPacket, uint16_t *pPacketId, MQTTReasonCodeInfo_t *pReasonCode, MQTTPropBuilder_t *pPropBuffer, const MQTTConnectionProperties_t *pConnectProperties) |
| Deserialize an MQTT PUBACK, PUBREC, PUBREL, PUBCOMP, SUBACK, UNSUBACK, or PINGRESP. | |
| MQTTStatus_t | MQTT_GetIncomingPacketTypeAndLength (TransportRecv_t readFunc, NetworkContext_t *pNetworkContext, MQTTPacketInfo_t *pIncomingPacket) |
| Extract the MQTT packet type and length from incoming packet. | |
| MQTTStatus_t | MQTT_UpdateDuplicatePublishFlag (uint8_t *pHeader, bool set) |
| Update the duplicate publish flag within the given header of the publish packet. | |
| MQTTStatus_t | MQTT_ProcessIncomingPacketTypeAndLength (const uint8_t *pBuffer, const size_t *pIndex, MQTTPacketInfo_t *pIncomingPacket) |
| Extract the MQTT packet type and length from incoming packet. | |
| MQTTStatus_t | MQTT_InitConnect (MQTTConnectionProperties_t *pConnectProperties) |
| Initialize an MQTTConnectionProperties_t. | |
| MQTTStatus_t | MQTTPropertyBuilder_Init (MQTTPropBuilder_t *pPropertyBuilder, uint8_t *buffer, size_t length) |
| Initialize the property builder. | |
| MQTTStatus_t | MQTT_ValidateWillProperties (const MQTTPropBuilder_t *pPropertyBuilder) |
| Validates the properties specified for WILL Properties in the MQTT CONNECT packet. | |
| static MQTTStatus_t | checkOnce (uint32_t *pBitMask, uint8_t bitPos, const char *pPropName) |
| Check that a property has not been seen before, then decode it. Returns MQTTBadResponse if the property appears more than once. | |
| static MQTTStatus_t | validateConnectProperty (uint8_t propertyId, uint32_t *pPropertyLength, uint8_t **ppIndex, uint32_t *pBitMask, bool *pIsRequestProblemInfoSet, uint32_t *pPacketMaxSizeValue) |
| Decode and validate a single CONNECT property. | |
| MQTTStatus_t | MQTT_ValidateConnectProperties (const MQTTPropBuilder_t *pPropertyBuilder, bool *isRequestProblemInfoSet, uint32_t *pPacketMaxSizeValue) |
| Validate the properties in a CONNECT packet. | |
| MQTTStatus_t | MQTT_ValidateSubscribeProperties (bool isSubscriptionIdAvailable, const MQTTPropBuilder_t *propBuilder) |
| Validates the properties of a SUBSCRIBE packet. | |
| MQTTStatus_t | MQTT_ValidatePublishProperties (uint16_t serverTopicAliasMax, const MQTTPropBuilder_t *propBuilder, uint16_t *topicAlias) |
| Validates the properties of a PUBLISH packet. | |
| MQTTStatus_t | MQTT_ValidatePublishParams (const MQTTPublishInfo_t *pPublishInfo, uint8_t retainAvailable, uint8_t maxQos, uint16_t topicAlias, uint32_t maxPacketSize) |
Validate the publish parameters present in the given publish structure pPublishInfo. | |
| MQTTStatus_t | MQTT_ValidatePublishAckProperties (const MQTTPropBuilder_t *pPropertyBuilder) |
| Validates the properties specified for an MQTT PUBLISH ACK packet. | |
| MQTTStatus_t | MQTT_GetAckPacketSize (uint32_t *pRemainingLength, uint32_t *pPacketSize, uint32_t maxPacketSize, size_t ackPropertyLength) |
| Get the size of an outgoing PUBLISH ACK packet. | |
| MQTTStatus_t | MQTT_ValidateDisconnectProperties (uint32_t connectSessionExpiry, const MQTTPropBuilder_t *pPropertyBuilder) |
| Validates the properties specified for an MQTT DISCONNECT packet. | |
| MQTTStatus_t | MQTT_DeserializeDisconnect (const MQTTPacketInfo_t *pPacket, uint32_t maxPacketSize, MQTTReasonCodeInfo_t *pDisconnectInfo, MQTTPropBuilder_t *pPropBuffer) |
| Deserialize an MQTT Disconnect packet. | |
Implements the user-facing functions in core_mqtt_serializer.h.
|
static |
Serializes MQTT PUBLISH packet into the buffer provided.
This function serializes MQTT PUBLISH packet into MQTTFixedBuffer_t.pBuffer. Copy of the payload into the buffer is done as part of the serialization only if serializePayload is true.
| [in] | pPublishInfo | Publish information containing topic, QoS, payload and other PUBLISH packet fields. |
| [in] | pPublishProperties | MQTT v5.0 properties for the PUBLISH packet. Can be NULL if no properties are needed. |
| [in] | remainingLength | Remaining length of the PUBLISH packet. |
| [in] | packetIdentifier | Packet identifier of PUBLISH packet. |
| [in,out] | pFixedBuffer | Buffer to which PUBLISH packet will be serialized. |
| [in] | serializePayload | Copy payload to the serialized buffer only if true. Only PUBLISH header will be serialized if false. |
|
static |
Calculates the packet size and remaining length of an MQTT PUBLISH packet.
| [in] | pPublishInfo | MQTT PUBLISH packet parameters. |
| [out] | pRemainingLength | The Remaining Length of the MQTT PUBLISH packet. |
| [out] | pPacketSize | The total size of the MQTT PUBLISH packet. |
| [in] | maxPacketSize | Max packet size allowed by the server. |
| [in] | publishPropertyLength | Length of the optional properties in MQTT_PUBLISH |
|
static |
Calculates the packet size and remaining length of an MQTT SUBSCRIBE or UNSUBSCRIBE packet.
| [in] | pSubscriptionList | List of MQTT subscription info. |
| [in] | subscriptionCount | The number of elements in pSubscriptionList. |
| [out] | pRemainingLength | The Remaining Length of the MQTT SUBSCRIBE or UNSUBSCRIBE packet. |
| [out] | pPacketSize | The total size of the MQTT SUBSCRIBE or MQTT UNSUBSCRIBE packet. |
| [in] | subscribePropLen | Length of the optional properties in MQTT_SUBSCRIBE or MQTT_UNSUBSCRIBE |
| [in] | maxPacketSize | Maximum Packet Size allowed by the broker |
| [in] | subscriptionType | MQTT_TYPE_SUBSCRIBE or MQTT_TYPE_UNSUBSCRIBE. |
|
static |
Validates parameters of MQTT_SerializeSubscribe or MQTT_SerializeUnsubscribe.
| [in] | pSubscriptionList | List of MQTT subscription info. |
| [in] | subscriptionCount | The number of elements in pSubscriptionList. |
| [in] | packetId | Packet identifier. |
| [in] | remainingLength | Remaining length of the packet. |
| [in] | pFixedBuffer | Buffer for packet serialization. |
|
static |
Serialize an MQTT CONNECT packet in the given buffer.
| [in] | pConnectInfo | MQTT CONNECT packet parameters. |
| [in] | pWillInfo | Last Will and Testament. Pass NULL if not used. |
| [in] | pConnectProperties | MQTT CONNECT properties. |
| [in] | pWillProperties | MQTT Will properties. |
| [in] | remainingLength | Remaining Length of MQTT CONNECT packet. |
| [out] | pFixedBuffer | Buffer for packet serialization. |
|
static |
Prints the appropriate message for the CONNACK response code if logs are enabled.
| [in] | responseCode | MQTT standard CONNACK response code. |
|
static |
Retrieve the size of the remaining length if it were to be encoded.
| [in] | length | The remaining length to be encoded. |
|
static |
Retrieves and decodes the Remaining Length from the network interface by reading a single byte at a time.
| [in] | recvFunc | Network interface receive function. |
| [in] | pNetworkContext | Network interface context to the receive function. |
|
static |
Retrieves, decodes and stores the Remaining Length from the network interface by reading a single byte at a time.
| [in] | pBuffer | The buffer holding the raw data to be processed |
| [in] | pIndex | Pointer to the index within the buffer to marking the end of raw data available. |
| [in] | pIncomingPacket | Structure used to hold the fields of the incoming packet. |
|
static |
Check if an incoming packet type is valid.
| [in] | packetType | The packet type to check. |
true if the packet type is valid; false otherwise.
|
static |
Check the remaining length of an incoming PUBLISH packet against some value for QoS 0, or for QoS 1 and 2.
The remaining length for a QoS 1 and 2 packet will always be two greater than for a QoS 0.
| [in] | remainingLength | Remaining length of the PUBLISH packet. |
| [in] | qos | The QoS of the PUBLISH. |
| [in] | qos0Minimum | Minimum possible remaining length for a QoS 0 PUBLISH. |
|
static |
Process the flags of an incoming PUBLISH packet.
| [in] | publishFlags | Flags of an incoming PUBLISH. |
| [in,out] | pPublishInfo | Pointer to MQTTPublishInfo_t struct where output will be written. |
|
static |
Deserialize an MQTT CONNACK packet.
| [out] | pConnackProperties | To store the deserialized connack properties. |
| [in] | pIncomingPacket | MQTTPacketInfo_t containing the buffer. |
| [out] | pSessionPresent | Whether a previous session was present. |
| [out] | pPropBuffer | MQTTPropBuilder_t to store the deserialized properties. |
|
static |
Decode the status bytes of a SUBACK packet to a MQTTStatus_t.
| [in] | statusCount | Number of status bytes in the SUBACK. |
| [in] | pStatusStart | The first status byte in the SUBACK. |
| [out] | pReasonCodes | The MQTTReasonCodeInfo_t to store reason codes for each topic filter. |
|
static |
Deserialize an MQTT SUBACK / UNSUBACK packet.
| [in] | incomingPacket | MQTTPacketInfo_t containing the buffer. |
| [out] | pPacketId | The packet ID obtained from the buffer. |
| [out] | pReasonCodes | Struct to store reason code(s) from the acknowledgment packet. Contains the success/failure status of the corresponding request. |
| [out] | pPropBuffer | MQTTPropBuilder_t to store the deserialized properties. |
|
static |
Deserialize a PUBLISH packet received from the server.
Converts the packet from a stream of bytes to an MQTTPublishInfo_t and extracts the packet identifier. Also prints out debug log messages about the packet.
| [in] | pIncomingPacket | Pointer to an MQTT packet struct representing a PUBLISH. |
| [out] | pPacketId | Packet identifier of the PUBLISH. |
| [out] | pPublishInfo | Pointer to MQTTPublishInfo_t where output is written. |
| [out] | pPropBuffer | Pointer to the property buffer. |
| [in] | topicAliasMax | Maximum allowed Topic Alias. |
|
static |
Deserialize a PINGRESP packet.
Converts the packet from a stream of bytes to an MQTTStatus_t.
| [in] | pPingresp | Pointer to an MQTT packet struct representing a PINGRESP. |
|
static |
Validate the connack parameters.
Converts the packet from a stream of bytes to an MQTTStatus_t and extracts the variable header without connack properties.
| [in] | pIncomingPacket | Pointer to an MQTT packet struct representing a incoming packet. |
| [out] | pSessionPresent | Whether a session is present or not. |
|
static |
Validate the length and decode the connack properties.
| [out] | pConnackProperties | To store the decoded property. |
| [in] | length | Length of the properties. |
| [in] | pIndex | Pointer to the start of the properties. |
| [out] | pPropBuffer | Pointer to the property buffer. |
|
static |
Deserialize properties in the SUBACK packet received from the server.
Converts the packet from a stream of bytes to an MQTTStatus_t and extracts properties.
| [out] | pPropBuffer | Pointer to the property buffer. |
| [in] | pIndex | Pointer to the start of the properties. |
| [out] | pSubackPropertyLength | Pointer to the length of suback properties |
| [in] | remainingLength | Remaining length of the incoming packet. |
|
static |
Deserialize an PUBACK, PUBREC, PUBREL, or PUBCOMP packet.
Converts the packet from a stream of bytes to an MQTTStatus_t and extracts the packet identifier, reason code, properties.
| [in] | pAck | Pointer to the MQTT packet structure representing the packet. |
| [out] | pPacketIdentifier | Packet ID of the ack type packet. |
| [out] | pReasonCode | Structure to store reason code of the ack type packet. |
| [in] | requestProblem | To validate the packet. |
| [out] | pPropBuffer | Pointer to the property buffer. |
|
static |
Validate the length and decode the publish ack properties.
| [out] | pPropBuffer | To store the decoded property. |
| [in] | pIndex | Pointer to the current index of the buffer. |
| [in] | remainingLength | Remaining length of properties in the incoming packet. |
|
static |
Prints the appropriate message for the PUBREL, PUBACK response code if logs are enabled.
| [in] | reasonCode | MQTT Verion 5 standard PUBREL, PUBACK response code. |
| [in] | packetIdentifier | Packet id of the ack packet. |
|
static |
Deserialize properties in the PUBLISH packet received from the server.
Converts the packet from a stream of bytes to an MQTTPublishInfo_t and extracts properties.
| [out] | pPublishInfo | Pointer to MQTTPublishInfo_t where output is written. |
| [out] | pPropBuffer | Pointer to the property buffer. |
| [in] | pIndex | Pointer to the start of the properties. |
| [in] | topicAliasMax | Maximum allowed Topic Alias. |
| [in] | remainingLength | Remaining length of the incoming packet. |
|
static |
Prints and validates the appropriate message for the Disconnect response code if logs are enabled.
| [in] | reasonCode | MQTT Verion 5 standard DISCONNECT response code. |
| [in] | incoming | To differentiate between outgoing and incoming disconnect. |
|
static |
Validates the reason codes for the given ACK packet type.
| [in] | ackPacketType | ACK packet type for which the reason code is being added. |
| [in] | reasonCode | The reason code being added to the ACK packet type. |
|
inlinestatic |
Validate if a reason code is valid for CONNACK packets.
This function checks if the provided reason code is a valid CONNACK reason code according to the MQTT v5 specification.
| [in] | reasonCode | The reason code to validate. |
|
static |
Validate properties in the DISCONNECT packet received from the server.
| [in] | pIndex | Pointer to the start of the properties. |
| [in] | disconnectPropertyLength | Length of the properties in the DISCONNECT packet. |
|
static |
Decode and validate a single CONNACK property from the incoming packet.
Reads one property from the variable header, validates its value, stores it in the appropriate field of pConnackProperties, and sets the corresponding bit in the property buffer's fieldSet if pPropBuffer is not NULL.
| [in] | propertyId | The MQTT property identifier byte. |
| [in,out] | pConnackProperties | Connection properties structure to populate. |
| [in,out] | pPropertyLength | Remaining bytes in the property section; decremented as each property value is consumed. |
| [in,out] | ppVariableHeader | Pointer to the current read position in the packet buffer; advanced past the consumed property value. |
| [in,out] | pPropBuffer | Optional property builder to record which properties were received. May be NULL. |
| [in,out] | pSeen | Duplicate-detection flags for each CONNACK property. |
|
static |
Set a bit in pPropBuffer->fieldSet if pPropBuffer is not NULL.
| [in,out] | pPropBuffer | Property builder whose fieldSet will be updated. If NULL, this function does nothing. |
| [in] | bitPos | Bit position to set in fieldSet. |
|
static |
Validate that a uint8 property value is 0 or 1 (boolean).
| [in] | value | The decoded uint8 property value to validate. |
| [in] | pPropName | Human-readable property name used in the error log message. |
|
static |
Decode a uint8 boolean CONNACK property, validate it, and record it.
Calls decodeUint8t to read the value, validateBoolProp to check it is 0 or 1, and setConnackPropBit to mark the property as received in the property buffer.
| [out] | pDest | Destination to store the decoded uint8 value. |
| [in,out] | pPropertyLength | Remaining bytes in the property section; decremented by the size of the decoded value. |
| [in,out] | pSeen | Duplicate-detection flag; set to true after first decode. |
| [in,out] | ppIndex | Current read position in the packet buffer; advanced past the decoded value. |
| [in] | pPropName | Human-readable property name used in error log messages. |
| [in,out] | pPropBuffer | Optional property builder to record the property bit. May be NULL. |
| [in] | bitPos | Bit position to set in pPropBuffer->fieldSet on success. |
| MQTTStatus_t MQTT_SerializePublishHeaderWithoutTopic | ( | const MQTTPublishInfo_t * | pPublishInfo, |
| uint32_t | remainingLength, | ||
| uint8_t * | pBuffer, | ||
| size_t * | headerSize | ||
| ) |
Serialize an MQTT PUBLISH packet header without the topic string in the given buffer. This function will add the topic string length to the provided buffer. This helps reduce an unnecessary copy of the topic string into the buffer.
| [in] | pPublishInfo | MQTT PUBLISH packet parameters. |
| [in] | remainingLength | Remaining Length provided by MQTT_GetPublishPacketSize. |
| [out] | pBuffer | Buffer for packet serialization. |
| [out] | headerSize | Size of the serialized MQTT PUBLISH header. |
| MQTTStatus_t updateContextWithConnectProps | ( | const MQTTPropBuilder_t * | pPropBuilder, |
| MQTTConnectionProperties_t * | pConnectProperties | ||
| ) |
Updates the MQTT context with connect properties from the property builder.
This function processes the property builder and updates the connect properties in the MQTT context. It handles the conversion and validation of properties from the property builder to the connect properties structure.
| [in] | pPropBuilder | Pointer to the property builder containing MQTT properties. Must not be NULL. |
| [out] | pConnectProperties | Pointer to the connection properties structure to be updated. Must not be NULL. |
Example
This value shall get overwritten if the server sends a sessionExpiry in the CONNACK.
| MQTTStatus_t MQTT_GetConnectPacketSize | ( | const MQTTConnectInfo_t * | pConnectInfo, |
| const MQTTPublishInfo_t * | pWillInfo, | ||
| const MQTTPropBuilder_t * | pConnectProperties, | ||
| const MQTTPropBuilder_t * | pWillProperties, | ||
| uint32_t * | pRemainingLength, | ||
| uint32_t * | pPacketSize | ||
| ) |
Get the size and Remaining Length of an MQTT Version 5 CONNECT packet.
This function must be called before MQTT_SerializeConnect in order to get the size of the MQTT CONNECT packet that is generated from MQTTConnectInfo_t, MQTTPublishInfo_t and optional MQTTPropBuilder_t. The size of the MQTTFixedBuffer_t supplied to MQTT_SerializeConnect must be at least pPacketSize. The provided pConnectInfo and pWillInfo are valid for serialization with MQTT_SerializeConnect only if this function returns MQTTSuccess. The remaining length returned in pRemainingLength and the packet size returned in pPacketSize are valid only if this function returns MQTTSuccess.
| [in] | pConnectInfo | MQTT CONNECT packet parameters. |
| [in] | pWillInfo | Last Will and Testament. Pass NULL if not used. |
| [in] | pConnectProperties | MQTT CONNECT properties builder. Pass NULL if not used. |
| [in] | pWillProperties | MQTT Will properties builder. Pass NULL if not used. |
| [out] | pRemainingLength | The Remaining Length of the MQTT CONNECT packet. |
| [out] | pPacketSize | The total size of the MQTT CONNECT packet. |
Example
| MQTTStatus_t MQTT_SerializeConnect | ( | const MQTTConnectInfo_t * | pConnectInfo, |
| const MQTTPublishInfo_t * | pWillInfo, | ||
| const MQTTPropBuilder_t * | pConnectProperties, | ||
| const MQTTPropBuilder_t * | pWillProperties, | ||
| uint32_t | remainingLength, | ||
| const MQTTFixedBuffer_t * | pFixedBuffer | ||
| ) |
Serialize an MQTT CONNECT packet in the given fixed buffer pFixedBuffer.
MQTT_GetConnectPacketSize should be called with pConnectInfo, pWillInfo, pConnectProperties, and pWillProperties before invoking this function to get the size of the required MQTTFixedBuffer_t and remainingLength. The remainingLength must be the same as returned by MQTT_GetConnectPacketSize. The MQTTFixedBuffer_t must be at least as large as the size returned by MQTT_GetConnectPacketSize.
| [in] | pConnectInfo | MQTT CONNECT packet parameters. |
| [in] | pWillInfo | Last Will and Testament. Pass NULL if not used. |
| [in] | pConnectProperties | MQTT CONNECT properties builder. Pass NULL if not used. |
| [in] | pWillProperties | MQTT Will properties builder. Pass NULL if not used. |
| [in] | remainingLength | Remaining Length provided by MQTT_GetConnectPacketSize. |
| [out] | pFixedBuffer | Buffer for packet serialization. |
Example
| MQTTStatus_t MQTT_GetSubscribePacketSize | ( | const MQTTSubscribeInfo_t * | pSubscriptionList, |
| size_t | subscriptionCount, | ||
| const MQTTPropBuilder_t * | pSubscribeProperties, | ||
| uint32_t * | pRemainingLength, | ||
| uint32_t * | pPacketSize, | ||
| uint32_t | maxPacketSize | ||
| ) |
Get packet size and Remaining Length of an MQTT SUBSCRIBE packet.
This function must be called before MQTT_SerializeSubscribe in order to get the size of the MQTT SUBSCRIBE packet that is generated from the list of MQTTSubscribeInfo_t and MQTTPropBuilder_t (optional subscribe properties). The size of the MQTTFixedBuffer_t supplied to MQTT_SerializeSubscribe must be at least pPacketSize. The provided pSubscriptionList is valid for serialization with MQTT_SerializeSubscribe only if this function returns MQTTSuccess. The remaining length returned in pRemainingLength and the packet size returned in pPacketSize are valid only if this function returns MQTTSuccess.
| [in] | pSubscriptionList | List of MQTT subscription info. |
| [in] | subscriptionCount | The number of elements in pSubscriptionList. |
| [in] | pSubscribeProperties | MQTT SUBSCRIBE properties builder. Pass NULL if not used. |
| [out] | pRemainingLength | The Remaining Length of the MQTT SUBSCRIBE packet. |
| [out] | pPacketSize | The total size of the MQTT SUBSCRIBE packet. |
| [in] | maxPacketSize | Maximum packet size. |
Example
| MQTTStatus_t MQTT_SerializeSubscribe | ( | const MQTTSubscribeInfo_t * | pSubscriptionList, |
| size_t | subscriptionCount, | ||
| const MQTTPropBuilder_t * | pSubscribeProperties, | ||
| uint16_t | packetId, | ||
| uint32_t | remainingLength, | ||
| const MQTTFixedBuffer_t * | pFixedBuffer | ||
| ) |
Serialize an MQTT SUBSCRIBE packet in the given buffer.
MQTT_GetSubscribePacketSize should be called with pSubscriptionList before invoking this function to get the size of the required MQTTFixedBuffer_t and remainingLength. The remainingLength must be the same as returned by MQTT_GetSubscribePacketSize. The MQTTFixedBuffer_t must be at least as large as the size returned by MQTT_GetSubscribePacketSize.
| [in] | pSubscriptionList | List of MQTT subscription info. |
| [in] | subscriptionCount | The number of elements in pSubscriptionList. |
| [in] | pSubscribeProperties | MQTT v5.0 properties for the SUBSCRIBE packet. Can be NULL if no properties are needed. |
| [in] | packetId | packet ID generated by MQTT_GetPacketId. |
| [in] | remainingLength | Remaining Length provided by MQTT_GetSubscribePacketSize. |
| [out] | pFixedBuffer | Buffer for packet serialization. |
Example
| MQTTStatus_t MQTT_GetUnsubscribePacketSize | ( | const MQTTSubscribeInfo_t * | pSubscriptionList, |
| size_t | subscriptionCount, | ||
| const MQTTPropBuilder_t * | pUnsubscribeProperties, | ||
| uint32_t * | pRemainingLength, | ||
| uint32_t * | pPacketSize, | ||
| uint32_t | maxPacketSize | ||
| ) |
Get packet size and Remaining Length of an MQTT UNSUBSCRIBE packet.
This function must be called before MQTT_SerializeUnsubscribe in order to get the size of the MQTT UNSUBSCRIBE packet that is generated from the list of MQTTSubscribeInfo_t and MQTTPropBuilder_t (optional unsubscribe properties). The size of the MQTTFixedBuffer_t supplied to MQTT_SerializeUnsubscribe must be at least pPacketSize. The provided pSubscriptionList is valid for serialization with MQTT_SerializeUnsubscribe only if this function returns MQTTSuccess. The remaining length returned in pRemainingLength and the packet size returned in pPacketSize are valid only if this function returns MQTTSuccess.
| [in] | pSubscriptionList | List of MQTT subscription info. |
| [in] | subscriptionCount | The number of elements in pSubscriptionList. |
| [in] | pUnsubscribeProperties | MQTT UNSUBSCRIBE properties builder. Pass NULL if not used. |
| [out] | pRemainingLength | The Remaining Length of the MQTT UNSUBSCRIBE packet. |
| [out] | pPacketSize | The total size of the MQTT UNSUBSCRIBE packet. |
| [in] | maxPacketSize | Maximum packet size. |
Example
| MQTTStatus_t MQTT_ValidateUnsubscribeProperties | ( | const MQTTPropBuilder_t * | pPropertyBuilder | ) |
Validates the properties specified for an MQTT UNSUBSCRIBE packet.
| [in] | pPropertyBuilder | Pointer to the property builder structure containing unsubscribe properties. |
| MQTTStatus_t MQTT_SerializeUnsubscribe | ( | const MQTTSubscribeInfo_t * | pSubscriptionList, |
| size_t | subscriptionCount, | ||
| const MQTTPropBuilder_t * | pUnsubscribeProperties, | ||
| uint16_t | packetId, | ||
| uint32_t | remainingLength, | ||
| const MQTTFixedBuffer_t * | pFixedBuffer | ||
| ) |
Serialize an MQTT UNSUBSCRIBE packet with properties in the given buffer.
MQTT_GetUnsubscribePacketSize should be called with pSubscriptionList and pUnsubscribeProperties before invoking this function to get the size of the required MQTTFixedBuffer_t and remainingLength. The remainingLength must be the same as returned by MQTT_GetUnsubscribePacketSize. The MQTTFixedBuffer_t must be at least as large as the size returned by MQTT_GetUnsubscribePacketSize.
| [in] | pSubscriptionList | List of MQTT subscription info to unsubscribe from. |
| [in] | subscriptionCount | The number of elements in pSubscriptionList. |
| [in] | pUnsubscribeProperties | MQTT 5.0 properties for the UNSUBSCRIBE packet. Can be NULL if no properties are needed. |
| [in] | packetId | Packet identifier used for the UNSUBSCRIBE packet. |
| [in] | remainingLength | Remaining Length provided by MQTT_GetUnsubscribePacketSize. |
| [out] | pFixedBuffer | Buffer where the serialized UNSUBSCRIBE packet will be written. |
Example
| MQTTStatus_t MQTT_GetPublishPacketSize | ( | const MQTTPublishInfo_t * | pPublishInfo, |
| const MQTTPropBuilder_t * | pPublishProperties, | ||
| uint32_t * | pRemainingLength, | ||
| uint32_t * | pPacketSize, | ||
| uint32_t | maxPacketSize | ||
| ) |
Get the packet size and remaining length of an MQTT PUBLISH packet.
MQTT_ValidatePublishParams should be called with pPublishInfo before invoking this function to validate the publish parameters. This function must be called before sendPublishWithoutCopy in order to get the size of the MQTT PUBLISH packet that is generated from MQTTPublishInfo_t and optional publish properties. The remaining length returned in pRemainingLength and the packet size returned in pPacketSize are valid only if this function returns MQTTSuccess.
| [in] | pPublishInfo | MQTT PUBLISH packet parameters. |
| [in] | pPublishProperties | MQTT PUBLISH properties builder. Pass NULL if not used. |
| [out] | pRemainingLength | The Remaining Length of the MQTT PUBLISH packet. |
| [out] | pPacketSize | The total size of the MQTT PUBLISH packet. |
| [in] | maxPacketSize | Maximum packet size allowed by the server. |
Example
| MQTTStatus_t MQTT_SerializePublish | ( | const MQTTPublishInfo_t * | pPublishInfo, |
| const MQTTPropBuilder_t * | pPublishProperties, | ||
| uint16_t | packetId, | ||
| uint32_t | remainingLength, | ||
| const MQTTFixedBuffer_t * | pFixedBuffer | ||
| ) |
Serialize an MQTT PUBLISH packet in the given buffer.
This function will serialize complete MQTT PUBLISH packet into the given buffer. If the PUBLISH payload can be sent separately, consider using MQTT_SerializePublishHeader, which will serialize only the PUBLISH header into the buffer.
MQTT_GetPublishPacketSize should be called with pPublishInfo before invoking this function to get the size of the required MQTTFixedBuffer_t and remainingLength. The remainingLength must be the same as returned by MQTT_GetPublishPacketSize. The MQTTFixedBuffer_t must be at least as large as the size returned by MQTT_GetPublishPacketSize.
| [in] | pPublishInfo | MQTT PUBLISH packet parameters. |
| [in] | pPublishProperties | MQTT v5.0 properties for the PUBLISH packet. Can be NULL if no properties are needed. |
| [in] | packetId | packet ID generated by MQTT_GetPacketId. |
| [in] | remainingLength | Remaining Length provided by MQTT_GetPublishPacketSize. |
| [out] | pFixedBuffer | Buffer for packet serialization. |
Example
| MQTTStatus_t MQTT_SerializePublishHeader | ( | const MQTTPublishInfo_t * | pPublishInfo, |
| const MQTTPropBuilder_t * | pPublishProperties, | ||
| uint16_t | packetId, | ||
| uint32_t | remainingLength, | ||
| const MQTTFixedBuffer_t * | pFixedBuffer, | ||
| size_t * | pHeaderSize | ||
| ) |
Serialize an MQTT PUBLISH packet header in the given buffer.
This function serializes PUBLISH header in to the given buffer. The payload for PUBLISH will not be copied over to the buffer. This will help reduce the memory needed for the buffer and avoid an unwanted copy operation of the PUBLISH payload into the buffer. If the payload also would need to be part of the serialized buffer, consider using MQTT_SerializePublish.
MQTT_GetPublishPacketSize should be called with pPublishInfo before invoking this function to get the size of the required MQTTFixedBuffer_t and remainingLength. The remainingLength must be the same as returned by MQTT_GetPublishPacketSize. The MQTTFixedBuffer_t must be at least as large as the size returned by MQTT_GetPublishPacketSize.
| [in] | pPublishInfo | MQTT PUBLISH packet parameters. |
| [in] | pPublishProperties | MQTT v5.0 properties for the PUBLISH packet. Can be NULL if no properties are needed. |
| [in] | packetId | packet ID generated by MQTT_GetPacketId. |
| [in] | remainingLength | Remaining Length provided by MQTT_GetPublishPacketSize. |
| [out] | pFixedBuffer | Buffer for packet serialization. |
| [out] | pHeaderSize | Size of the serialized MQTT PUBLISH header. |
Example
| MQTTStatus_t MQTT_SerializeAck | ( | const MQTTFixedBuffer_t * | pFixedBuffer, |
| uint8_t | packetType, | ||
| uint16_t | packetId, | ||
| const MQTTPropBuilder_t * | pAckProperties, | ||
| const MQTTSuccessFailReasonCode_t * | pReasonCode | ||
| ) |
Serialize an MQTT PUBACK, PUBREC, PUBREL, or PUBCOMP into the given buffer.
| [out] | pFixedBuffer | Buffer for packet serialization. |
| [in] | packetType | Byte of the corresponding packet fixed header per the MQTT spec. |
| [in] | packetId | Packet ID of the publish. |
| [in] | pAckProperties | Optional properties to be added to the ACK packet. |
| [in] | pReasonCode | Optional reason code to be added to the ACK packet. |
Example
| MQTTStatus_t MQTT_GetDisconnectPacketSize | ( | const MQTTPropBuilder_t * | pDisconnectProperties, |
| uint32_t * | pRemainingLength, | ||
| uint32_t * | pPacketSize, | ||
| uint32_t | maxPacketSize, | ||
| const MQTTSuccessFailReasonCode_t * | pReasonCode | ||
| ) |
Get the size of an MQTT DISCONNECT packet.
| [in] | pDisconnectProperties | MQTT DISCONNECT properties builder. Pass NULL if not used. |
| [out] | pRemainingLength | The Remaining Length of the MQTT DISCONNECT packet. |
| [out] | pPacketSize | The size of the MQTT DISCONNECT packet. |
| [in] | maxPacketSize | Maximum packet size allowed by the server. |
| [in] | pReasonCode | The reason code for the disconnect. Pass NULL if not used - only valid if the properties are NULL too. |
Example
| MQTTStatus_t MQTT_SerializeDisconnect | ( | const MQTTPropBuilder_t * | pDisconnectProperties, |
| const MQTTSuccessFailReasonCode_t * | pReasonCode, | ||
| uint32_t | remainingLength, | ||
| const MQTTFixedBuffer_t * | pFixedBuffer | ||
| ) |
Serialize an MQTT DISCONNECT packet into the given buffer.
The input MQTTFixedBuffer_t.size must be at least as large as the size returned by MQTT_GetDisconnectPacketSize. This function should only be called after MQTT_GetDisconnectPacketSize to ensure proper buffer sizing.
| [in] | pDisconnectProperties | MQTT v5.0 properties for the DISCONNECT packet. Can be NULL if no properties are needed. |
| [in] | pReasonCode | The reason code for the disconnect. For MQTT v5.0, this indicates why the connection is being terminated. If this is NULL, then the pDisconnectProperties must be NULL as well. |
| [in] | remainingLength | Remaining Length provided by MQTT_GetDisconnectPacketSize. |
| [out] | pFixedBuffer | Buffer for packet serialization. |
Example
| MQTTStatus_t MQTT_GetPingreqPacketSize | ( | uint32_t * | pPacketSize | ) |
Get the size of an MQTT PINGREQ packet.
| [out] | pPacketSize | The size of the MQTT PINGREQ packet. |
Example
| MQTTStatus_t MQTT_SerializePingreq | ( | const MQTTFixedBuffer_t * | pFixedBuffer | ) |
Serialize an MQTT PINGREQ packet into the given buffer.
The input MQTTFixedBuffer_t.size must be at least as large as the size returned by MQTT_GetPingreqPacketSize.
| [out] | pFixedBuffer | Buffer for packet serialization. |
Example
| MQTTStatus_t MQTT_DeserializePublish | ( | const MQTTPacketInfo_t * | pIncomingPacket, |
| uint16_t * | pPacketId, | ||
| MQTTPublishInfo_t * | pPublishInfo, | ||
| MQTTPropBuilder_t * | propBuffer, | ||
| uint32_t | maxPacketSize, | ||
| uint16_t | topicAliasMax | ||
| ) |
Deserialize an MQTT PUBLISH packet.
| [in] | pIncomingPacket | MQTTPacketInfo_t containing the buffer. |
| [out] | pPacketId | The packet ID obtained from the buffer. |
| [out] | pPublishInfo | Struct containing information about the publish. |
| [in] | propBuffer | Buffer to hold the properties. |
| [in] | maxPacketSize | Maximum packet size. |
| [in] | topicAliasMax | Maximum topic alias specified in the CONNECT packet. |
Example
| MQTTStatus_t MQTT_DeserializeConnAck | ( | const MQTTPacketInfo_t * | pIncomingPacket, |
| bool * | pSessionPresent, | ||
| MQTTPropBuilder_t * | pPropBuffer, | ||
| MQTTConnectionProperties_t * | pConnectProperties | ||
| ) |
Deserialize an MQTT CONNACK.
| [in] | pIncomingPacket | MQTTPacketInfo_t containing the buffer. |
| [out] | pSessionPresent | Boolean flag from a CONNACK indicating present session. |
| [out] | pPropBuffer | Struct to store the deserialized acknowledgment properties. Will contain any MQTT v5.0 properties included in the ack packet. |
| [in,out] | pConnectProperties | Struct to store the deserialized connect/connack properties. This parameter cannot be NULL. |
| MQTTStatus_t MQTT_DeserializeAck | ( | const MQTTPacketInfo_t * | pIncomingPacket, |
| uint16_t * | pPacketId, | ||
| MQTTReasonCodeInfo_t * | pReasonCode, | ||
| MQTTPropBuilder_t * | pPropBuffer, | ||
| const MQTTConnectionProperties_t * | pConnectProperties | ||
| ) |
Deserialize an MQTT PUBACK, PUBREC, PUBREL, PUBCOMP, SUBACK, UNSUBACK, or PINGRESP.
| [in] | pIncomingPacket | MQTTPacketInfo_t containing the buffer. |
| [out] | pPacketId | The packet ID obtained from the buffer. |
| [out] | pReasonCode | Struct to store reason code(s) from the acknowledgment packet. Contains the success/failure status of the corresponding request. |
| [out] | pPropBuffer | Struct to store the deserialized acknowledgment properties. Will contain any MQTT v5.0 properties included in the ack packet. |
| [in,out] | pConnectProperties | Struct to store the deserialized connect/connack properties. |
Example
| MQTTStatus_t MQTT_GetIncomingPacketTypeAndLength | ( | TransportRecv_t | readFunc, |
| NetworkContext_t * | pNetworkContext, | ||
| MQTTPacketInfo_t * | pIncomingPacket | ||
| ) |
Extract the MQTT packet type and length from incoming packet.
This function must be called for every incoming packet to retrieve the MQTTPacketInfo_t.type and MQTTPacketInfo_t.remainingLength. A MQTTPacketInfo_t is not valid until this routine has been invoked.
| [in] | readFunc | Transport layer read function pointer. |
| [in] | pNetworkContext | The network context pointer provided by the application. |
| [out] | pIncomingPacket | Pointer to MQTTPacketInfo_t structure. This is where type, remaining length and packet identifier are stored. |
pIncomingPacket is invalid, MQTTRecvFailed on transport receive failure, MQTTBadResponse if an invalid packet is read, and MQTTNoDataAvailable if there is nothing to read.Example
| MQTTStatus_t MQTT_UpdateDuplicatePublishFlag | ( | uint8_t * | pHeader, |
| bool | set | ||
| ) |
Update the duplicate publish flag within the given header of the publish packet.
| [in] | pHeader | The buffer holding the header content |
| [in] | set | If true then the flag will be set else cleared |
| MQTTStatus_t MQTT_ProcessIncomingPacketTypeAndLength | ( | const uint8_t * | pBuffer, |
| const size_t * | pIndex, | ||
| MQTTPacketInfo_t * | pIncomingPacket | ||
| ) |
Extract the MQTT packet type and length from incoming packet.
This function must be called for every incoming packet to retrieve the MQTTPacketInfo_t.type and MQTTPacketInfo_t.remainingLength. A MQTTPacketInfo_t is not valid until this routine has been invoked.
| [in] | pBuffer | The buffer holding the raw data to be processed |
| [in] | pIndex | Pointer to the index within the buffer to marking the end of raw data available. |
| [out] | pIncomingPacket | Structure used to hold the fields of the incoming packet. |
pIncomingPacket is invalid, MQTTBadResponse if an invalid packet is read, and MQTTNoDataAvailable if there is nothing to read. | MQTTStatus_t MQTT_InitConnect | ( | MQTTConnectionProperties_t * | pConnectProperties | ) |
Initialize an MQTTConnectionProperties_t.
| [in] | pConnectProperties | The connect properties to initialize. |
| MQTTStatus_t MQTTPropertyBuilder_Init | ( | MQTTPropBuilder_t * | pPropertyBuilder, |
| uint8_t * | buffer, | ||
| size_t | length | ||
| ) |
Initialize the property builder.
| [out] | pPropertyBuilder | Property builder to initialize. |
| [in] | buffer | Buffer to store the properties. |
| [in] | length | Length of the buffer. |
| MQTTStatus_t MQTT_ValidateWillProperties | ( | const MQTTPropBuilder_t * | pPropertyBuilder | ) |
Validates the properties specified for WILL Properties in the MQTT CONNECT packet.
| [in] | pPropertyBuilder | Pointer to the property builder structure containing will properties. |
| MQTTStatus_t MQTT_ValidateConnectProperties | ( | const MQTTPropBuilder_t * | pPropertyBuilder, |
| bool * | isRequestProblemInfoSet, | ||
| uint32_t * | pPacketMaxSizeValue | ||
| ) |
Validate the properties in a CONNECT packet.
| [in] | pPropertyBuilder | Pointer to the property builder structure containing connect packet properties. |
| [out] | isRequestProblemInfoSet | Whether the request problem info field is set in the properties. |
| [out] | pPacketMaxSizeValue | Optional pointer to get the Maximum Packet Size from the properties. If not required, NULL can be passed. |
| MQTTStatus_t MQTT_ValidateSubscribeProperties | ( | bool | isSubscriptionIdAvailable, |
| const MQTTPropBuilder_t * | propBuilder | ||
| ) |
Validates the properties of a SUBSCRIBE packet.
This function validates the properties in the property builder for a SUBSCRIBE packet.
| [in] | isSubscriptionIdAvailable | Boolean indicating if subscription identifiers are supported. |
| [in] | propBuilder | Pointer to the property builder structure. |
| MQTTStatus_t MQTT_ValidatePublishProperties | ( | uint16_t | serverTopicAliasMax, |
| const MQTTPropBuilder_t * | propBuilder, | ||
| uint16_t * | topicAlias | ||
| ) |
Validates the properties of a PUBLISH packet.
This function validates the properties in the property builder for a PUBLISH packet.
| [in] | serverTopicAliasMax | Maximum topic alias value allowed by the server. |
| [in] | propBuilder | Pointer to the property builder structure. |
| [out] | topicAlias | Pointer to store the topic alias value if present. |
| MQTTStatus_t MQTT_ValidatePublishParams | ( | const MQTTPublishInfo_t * | pPublishInfo, |
| uint8_t | retainAvailable, | ||
| uint8_t | maxQos, | ||
| uint16_t | topicAlias, | ||
| uint32_t | maxPacketSize | ||
| ) |
Validate the publish parameters present in the given publish structure pPublishInfo.
This function must be called before MQTT_GetPublishPacketSize in order to validate the publish parameters.
| [in] | pPublishInfo | MQTT publish packet parameters. |
| [in] | retainAvailable | Whether server allows retain or not. |
| [in] | maxQos | Maximum QoS supported by the server. |
| [in] | topicAlias | Topic alias in the PUBLISH packet. |
| [in] | maxPacketSize | Maximum packet size allowed by the server. |
Example
| MQTTStatus_t MQTT_ValidatePublishAckProperties | ( | const MQTTPropBuilder_t * | pPropertyBuilder | ) |
Validates the properties specified for an MQTT PUBLISH ACK packet.
| [in] | pPropertyBuilder | Pointer to the property builder structure containing unsubscribe properties. |
| MQTTStatus_t MQTT_GetAckPacketSize | ( | uint32_t * | pRemainingLength, |
| uint32_t * | pPacketSize, | ||
| uint32_t | maxPacketSize, | ||
| size_t | ackPropertyLength | ||
| ) |
Get the size of an outgoing PUBLISH ACK packet.
| [out] | pRemainingLength | The remaining length of the packet to be serialized. |
| [out] | pPacketSize | The size of the packet to be serialized. |
| [in] | maxPacketSize | Maximum packet size allowed by the server. |
| [in] | ackPropertyLength | The length of the properties. |
Example
| MQTTStatus_t MQTT_ValidateDisconnectProperties | ( | uint32_t | connectSessionExpiry, |
| const MQTTPropBuilder_t * | pPropertyBuilder | ||
| ) |
Validates the properties specified for an MQTT DISCONNECT packet.
| [in] | connectSessionExpiry | The session expiry interval that was specified in the CONNECT packet. Used to validate that the DISCONNECT session expiry is not non-zero while connectSessionExpiry is zero. |
| [in] | pPropertyBuilder | Pointer to the property builder structure containing subscribe properties. |
| MQTTStatus_t MQTT_DeserializeDisconnect | ( | const MQTTPacketInfo_t * | pPacket, |
| uint32_t | maxPacketSize, | ||
| MQTTReasonCodeInfo_t * | pDisconnectInfo, | ||
| MQTTPropBuilder_t * | pPropBuffer | ||
| ) |
Deserialize an MQTT Disconnect packet.
| [in] | pPacket | MQTTPacketInfo_t containing the buffer. |
| [in] | maxPacketSize | Maximum packet size allowed by the client. |
| [out] | pDisconnectInfo | Struct containing disconnect reason code |
| [out] | pPropBuffer | MQTTPropBuilder_t to store the deserialized properties. |
Example