coreMQTT v2.0.0
MQTT 3.1.1 Client Library
MQTT_SerializeDisconnect

Serialize an MQTT DISCONNECT packet into the given buffer.

MQTTStatus_t MQTT_SerializeDisconnect(const MQTTFixedBuffer_t *pFixedBuffer)
Serialize an MQTT DISCONNECT packet into the given buffer.
Definition: core_mqtt_serializer.c:2343
MQTTStatus_t
Return codes from MQTT functions.
Definition: core_mqtt_serializer.h:97
Buffer passed to MQTT library.
Definition: core_mqtt_serializer.h:133

The input MQTTFixedBuffer_t.size must be at least as large as the size returned by MQTT_GetDisconnectPacketSize.

Parameters
[out]pFixedBufferBuffer for packet serialization.
Returns
MQTTNoMemory if pFixedBuffer is too small to hold the MQTT packet; MQTTBadParameter if invalid parameters are passed; MQTTSuccess otherwise.

Example

// Variables used in this example.
MQTTStatus_t status;
MQTTFixedBuffer_t fixedBuffer;
uint8_t buffer[ BUFFER_SIZE ];
fixedBuffer.pBuffer = buffer;
fixedBuffer.size = BUFFER_SIZE;
// Get the disconnect packet size.
status = MQTT_GetDisconnectPacketSize( &packetSize );
assert( status == MQTTSuccess );
assert( packetSize <= BUFFER_SIZE );
// Serialize the disconnect into the fixed buffer.
status = MQTT_SerializeDisconnect( &fixedBuffer );
if( status == MQTTSuccess )
{
// The disconnect packet can now be sent to the broker.
}
MQTTStatus_t MQTT_GetDisconnectPacketSize(size_t *pPacketSize)
Get the size of an MQTT DISCONNECT packet.
Definition: core_mqtt_serializer.c:2323
@ MQTTSuccess
Definition: core_mqtt_serializer.h:98
size_t size
Size of buffer.
Definition: core_mqtt_serializer.h:135
uint8_t * pBuffer
Pointer to buffer.
Definition: core_mqtt_serializer.h:134