coreMQTT v2.1.1
MQTT 3.1.1 Client Library
MQTT_DeserializeAck

Deserialize an MQTT CONNACK, SUBACK, UNSUBACK, PUBACK, PUBREC, PUBREL, PUBCOMP, or PINGRESP.

uint16_t * pPacketId,
bool * pSessionPresent );
MQTTStatus_t MQTT_DeserializeAck(const MQTTPacketInfo_t *pIncomingPacket, uint16_t *pPacketId, bool *pSessionPresent)
Deserialize an MQTT CONNACK, SUBACK, UNSUBACK, PUBACK, PUBREC, PUBREL, PUBCOMP, or PINGRESP.
Definition: core_mqtt_serializer.c:2488
MQTTStatus_t
Return codes from MQTT functions.
Definition: core_mqtt_serializer.h:99
MQTT incoming packet parameters.
Definition: core_mqtt_serializer.h:256
Parameters
[in]pIncomingPacketMQTTPacketInfo_t containing the buffer.
[out]pPacketIdThe packet ID of obtained from the buffer. Not used in CONNACK or PINGRESP.
[out]pSessionPresentBoolean flag from a CONNACK indicating present session.
Returns
MQTTBadParameter, MQTTBadResponse, MQTTServerRefused, or MQTTSuccess.

Example

// Variables used in this example.
MQTTStatus_t status;
MQTTPacketInfo_t incomingPacket;
// Used for SUBACK, UNSUBACK, PUBACK, PUBREC, PUBREL, and PUBCOMP.
uint16_t packetId;
// Used for CONNACK.
bool sessionPresent;
// Receive an incoming packet and populate all fields. The details are out of scope
// for this example.
receiveIncomingPacket( &incomingPacket );
// Deserialize ack information if the incoming packet is not a publish.
if( ( incomingPacket.type & 0xF0 ) != MQTT_PACKET_TYPE_PUBLISH )
{
status = MQTT_DeserializeAck( &incomingPacket, &packetId, &sessionPresent );
if( status == MQTTSuccess )
{
// The packet ID or session present flag information is available. For
// ping response packets, the only information is the status code.
}
}
#define MQTT_PACKET_TYPE_PUBLISH
PUBLISH (bidirectional).
Definition: core_mqtt_serializer.h:67
@ MQTTSuccess
Definition: core_mqtt_serializer.h:100
uint8_t type
Type of incoming MQTT packet.
Definition: core_mqtt_serializer.h:260