Get packet size and Remaining Length of an MQTT SUBSCRIBE packet.
size_t subscriptionCount,
size_t * pRemainingLength,
size_t * pPacketSize );
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:1852
MQTTStatus_t
Return codes from MQTT functions.
Definition: core_mqtt_serializer.h:99
MQTT SUBSCRIBE packet parameters.
Definition: core_mqtt_serializer.h:192
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. 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.
- Parameters
-
[in] | pSubscriptionList | List of MQTT subscription info. |
[in] | subscriptionCount | The number of elements in pSubscriptionList. |
[out] | pRemainingLength | The Remaining Length of the MQTT SUBSCRIBE packet. |
[out] | pPacketSize | The total size of the MQTT SUBSCRIBE packet. |
- Returns
- MQTTBadParameter if the packet would exceed the size allowed by the MQTT spec; MQTTSuccess otherwise.
Example
size_t remainingLength = 0, packetSize = 0;
const char * filters[ NUMBER_OF_SUBSCRIPTIONS ];
for( int i = 0; i < NUMBER_OF_SUBSCRIPTIONS; i++ )
{
}
&subscriptionList[ 0 ], NUMBER_OF_SUBSCRIPTIONS, &remainingLength, &packetSize
);
{
}
@ MQTTSuccess
Definition: core_mqtt_serializer.h:100
@ MQTTQoS0
Definition: core_mqtt_serializer.h:122
MQTTQoS_t qos
Quality of Service for subscription.
Definition: core_mqtt_serializer.h:196
uint16_t topicFilterLength
Length of subscription topic filter.
Definition: core_mqtt_serializer.h:206
const char * pTopicFilter
Topic filter to subscribe to.
Definition: core_mqtt_serializer.h:201