MQTT API Reference
MQTT 3.1.1 client library
IotMqtt_DeserializeResponse

Deserialize incoming ack packets.

Parameters
[in,out]pMqttPacketThe caller of this API sets type, remainingLength and pRemainingData. On success, packetIdentifier will be set.
Returns
One of the following:
Note
This call is part of serializer API used for implementing light-weight MQTT client.

Example

// Example below shows how IotMqtt_DeserializeResponse() is used to process unsubscribe ack.
// xMQTTSocket here is posix socket created and connected to MQTT broker outside of this function.
void processUnsubscribeAck( int xMQTTSocket )
{
IotMqttError_t xResult;
IotMqttPacketInfo_t xIncomingPacket;
xResult = IotMqtt_GetIncomingMQTTPacketTypeAndLength( &xIncomingPacket, getNextByte, ( void * ) xMQTTSocket );
IotMqtt_Assert( xIncomingPacket.remainingLength <= sizeof( ucSharedBuffer ) );
// Receive the remaining bytes.
if( recv( xMQTTSocket, ( void * ) ucSharedBuffer, xIncomingPacket.remainingLength, 0 ) == xIncomingPacket.remainingLength )
{
xIncomingPacket.pRemainingData = ucSharedBuffer;
if( IotMqtt_DeserializeResponse( &xIncomingPacket ) != IOT_MQTT_SUCCESS )
{
}
}
else
{
}
}
IotMqttPacketInfo_t::type
uint8_t type
(Input) A value identifying the packet type.
Definition: iot_mqtt_types.h:699
IotMqttError_t
IotMqttError_t
Return codes of MQTT functions.
Definition: iot_mqtt_types.h:103
IotMqttPacketInfo_t::pRemainingData
uint8_t * pRemainingData
(Input) The remaining data in MQTT packet.
Definition: iot_mqtt_types.h:696
IOT_MQTT_SUCCESS
MQTT operation completed successfully.
Definition: iot_mqtt_types.h:119
IotMqtt_GetIncomingMQTTPacketTypeAndLength
IotMqttError_t IotMqtt_GetIncomingMQTTPacketTypeAndLength(IotMqttPacketInfo_t *pIncomingPacket, IotMqttGetNextByte_t getNextByte, void *pNetworkConnection)
Extract MQTT packet type and length from incoming packet.
Definition: iot_mqtt_network.c:847
IotMqttPacketInfo_t
MQTT packet details.
Definition: iot_mqtt_types.h:694
IotMqtt_DeserializeResponse
IotMqttError_t IotMqtt_DeserializeResponse(IotMqttPacketInfo_t *pMqttPacket)
Deserialize incoming ack packets.
Definition: iot_mqtt_serialize.c:2543
IotMqttPacketInfo_t::remainingLength
size_t remainingLength
(Input) Length of the remaining data in the MQTT packet.
Definition: iot_mqtt_types.h:697
IOT_MQTT_NETWORK_ERROR
MQTT operation failed because the network was unusable.
Definition: iot_mqtt_types.h:177
MQTT_PACKET_TYPE_UNSUBACK
#define MQTT_PACKET_TYPE_UNSUBACK
UNSUBACK (server-to-client).
Definition: iot_mqtt_internal.h:269
IOT_MQTT_BAD_RESPONSE
MQTT response packet received from the network is malformed.
Definition: iot_mqtt_types.h:205
IotMqtt_Assert
#define IotMqtt_Assert(expression)
Assertion macro for the MQTT library.
Definition: iot_mqtt_internal.h:62