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:2061
MQTTStatus_t
Return codes from MQTT functions.
Definition: core_mqtt_serializer.h:99
MQTT PUBLISH packet parameters.
Definition: core_mqtt_serializer.h:214
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:100
@ MQTTQoS0
Definition: core_mqtt_serializer.h:122
MQTTQoS_t qos
Quality of Service for message.
Definition: core_mqtt_serializer.h:218
uint16_t topicNameLength
Length of topic name.
Definition: core_mqtt_serializer.h:238
size_t payloadLength
Message payload length.
Definition: core_mqtt_serializer.h:248
const char * pTopicName
Topic name on which the message is published.
Definition: core_mqtt_serializer.h:233
const void * pPayload
Message payload.
Definition: core_mqtt_serializer.h:243