Get the packet size and remaining length of an MQTT PUBLISH packet.
size_t * pRemainingLength,
size_t * pPacketSize );
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:1835
MQTTStatus_t
Return codes from MQTT functions.
Definition: core_mqtt_serializer.h:105
MQTT PUBLISH packet parameters.
Definition: core_mqtt_serializer.h:217
This function must be called before MQTT_SerializePublish in order to get the size of the MQTT PUBLISH packet that is generated from MQTTPublishInfo_t. The size of the MQTTFixedBuffer_t supplied to MQTT_SerializePublish must be at least pPacketSize
. The provided pPublishInfo
is valid for serialization with MQTT_SerializePublish 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.
- Parameters
-
[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. |
- Returns
- MQTTBadParameter if the packet would exceed the size allowed by the MQTT spec or if invalid parameters are passed; MQTTSuccess otherwise.
Example
size_t remainingLength = 0, packetSize = 0;
&publishInfo, &remainingLength, &packetSize
);
{
}
@ MQTTSuccess
Definition: core_mqtt_serializer.h:106
@ MQTTQoS0
Definition: core_mqtt_serializer.h:125
MQTTQoS_t qos
Quality of Service for message.
Definition: core_mqtt_serializer.h:221
uint16_t topicNameLength
Length of topic name.
Definition: core_mqtt_serializer.h:241
size_t payloadLength
Message payload length.
Definition: core_mqtt_serializer.h:251
const char * pTopicName
Topic name on which the message is published.
Definition: core_mqtt_serializer.h:236
const void * pPayload
Message payload.
Definition: core_mqtt_serializer.h:246