Serialize an MQTT SUBSCRIBE packet in the given buffer.
size_t subscriptionCount,
uint16_t packetId,
size_t remainingLength,
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:1936
MQTTStatus_t
Return codes from MQTT functions.
Definition: core_mqtt_serializer.h:99
Buffer passed to MQTT library.
Definition: core_mqtt_serializer.h:135
MQTT SUBSCRIBE packet parameters.
Definition: core_mqtt_serializer.h:192
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.
- Parameters
-
[in] | pSubscriptionList | List of MQTT subscription info. |
[in] | subscriptionCount | The number of elements in pSubscriptionList. |
[in] | packetId | packet ID generated by MQTT_GetPacketId. |
[in] | remainingLength | Remaining Length provided by MQTT_GetSubscribePacketSize. |
[out] | pFixedBuffer | Buffer for packet serialization. |
- Returns
- MQTTNoMemory if pFixedBuffer is too small to hold the MQTT packet; MQTTBadParameter if invalid parameters are passed; MQTTSuccess otherwise.
Example
uint8_t buffer[ BUFFER_SIZE ];
size_t remainingLength = 0, packetSize = 0;
uint16_t packetId;
fixedBuffer.
size = BUFFER_SIZE;
packetId = getNewPacketId();
&subscriptionList[ 0 ], NUMBER_OF_SUBSCRIPTIONS, &remainingLength, &packetSize
);
assert( packetSize <= BUFFER_SIZE );
&subscriptionList[ 0 ],
NUMBER_OF_SUBSCRIPTIONS,
packetId,
remainingLength,
&fixedBuffer
);
{
}
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
@ MQTTSuccess
Definition: core_mqtt_serializer.h:100
size_t size
Size of buffer.
Definition: core_mqtt_serializer.h:137
uint8_t * pBuffer
Pointer to buffer.
Definition: core_mqtt_serializer.h:136