coreMQTT  v1.0.0
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 );
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.
}
}
MQTTPacketInfo_t
MQTT incoming packet parameters.
Definition: core_mqtt_serializer.h:259
MQTT_DeserializeAck
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:2262
MQTTStatus_t
MQTTStatus_t
Return codes from MQTT functions.
Definition: core_mqtt_serializer.h:105
MQTT_PACKET_TYPE_PUBLISH
#define MQTT_PACKET_TYPE_PUBLISH
PUBLISH (bidirectional).
Definition: core_mqtt_serializer.h:73
MQTTPacketInfo_t::type
uint8_t type
Type of incoming MQTT packet.
Definition: core_mqtt_serializer.h:263
MQTTSuccess
@ MQTTSuccess
Definition: core_mqtt_serializer.h:106