coreMQTT v2.2.0
MQTT 3.1.1 Client Library
 
Loading...
Searching...
No Matches
MQTT_SerializeAck
uint8_t packetType,
uint16_t packetId );
MQTTStatus_t MQTT_SerializeAck(const MQTTFixedBuffer_t *pFixedBuffer, uint8_t packetType, uint16_t packetId)
Serialize an MQTT PUBACK, PUBREC, PUBREL, or PUBCOMP into the given buffer.
Definition: core_mqtt_serializer.c:2266
MQTTStatus_t
Return codes from MQTT functions.
Definition: core_mqtt_serializer.h:87
Buffer passed to MQTT library.
Definition: core_mqtt_serializer.h:123

Serialize an MQTT PUBACK, PUBREC, PUBREL, or PUBCOMP into the given buffer.

Parameters
[out]pFixedBufferBuffer for packet serialization.
[in]packetTypeByte of the corresponding packet fixed header per the MQTT spec.
[in]packetIdPacket ID of the publish.
Returns
MQTTBadParameter, MQTTNoMemory, or MQTTSuccess.

Example

// Variables used in this example.
MQTTStatus_t status;
MQTTFixedBuffer_t fixedBuffer;
uint8_t buffer[ BUFFER_SIZE ];
uint16_t packetId;
uint8_t packetType;
fixedBuffer.pBuffer = buffer;
fixedBuffer.size = BUFFER_SIZE;
// The fixed buffer must be large enough to hold 4 bytes.
assert( BUFFER_SIZE >= MQTT_PUBLISH_ACK_PACKET_SIZE );
// The packet ID must be the same as the original publish packet.
packetId = publishPacketId;
// The byte representing a packet of type ACK. This function accepts PUBACK, PUBREC, PUBREL, or PUBCOMP.
// Serialize the publish acknowledgment into the fixed buffer.
status = MQTT_SerializeAck( &fixedBuffer, packetType, packetId );
if( status == MQTTSuccess )
{
// The publish acknowledgment can now be sent to the broker.
}
#define MQTT_PUBLISH_ACK_PACKET_SIZE
The size of MQTT PUBACK, PUBREC, PUBREL, and PUBCOMP packets, per MQTT spec.
Definition: core_mqtt_serializer.h:73
#define MQTT_PACKET_TYPE_PUBACK
PUBACK (bidirectional).
Definition: core_mqtt_serializer.h:56
@ MQTTSuccess
Definition: core_mqtt_serializer.h:88
size_t size
Size of buffer.
Definition: core_mqtt_serializer.h:125
uint8_t * pBuffer
Pointer to buffer.
Definition: core_mqtt_serializer.h:124