Extract the MQTT packet type and length from incoming packet.
MQTTStatus_t MQTT_GetIncomingPacketTypeAndLength(TransportRecv_t readFunc, NetworkContext_t *pNetworkContext, MQTTPacketInfo_t *pIncomingPacket)
Extract the MQTT packet type and length from incoming packet.
Definition: core_mqtt_serializer.c:2565
int32_t(* TransportRecv_t)(NetworkContext_t *pNetworkContext, void *pBuffer, size_t bytesToRecv)
Transport interface for receiving data on the network.
Definition: transport_interface.h:221
MQTTStatus_t
Return codes from MQTT functions.
Definition: core_mqtt_serializer.h:99
struct NetworkContext NetworkContext_t
The NetworkContext is an incomplete type. An implementation of this interface must define struct Netw...
Definition: transport_interface.h:191
MQTT incoming packet parameters.
Definition: core_mqtt_serializer.h:256
This function must be called for every incoming packet to retrieve the MQTTPacketInfo_t.type and MQTTPacketInfo_t.remainingLength. A MQTTPacketInfo_t is not valid until this routine has been invoked.
- Parameters
-
[in] | readFunc | Transport layer read function pointer. |
[in] | pNetworkContext | The network context pointer provided by the application. |
[out] | pIncomingPacket | Pointer to MQTTPacketInfo_t structure. This is where type, remaining length and packet identifier are stored. |
- Returns
- MQTTSuccess on successful extraction of type and length, MQTTBadParameter if
pIncomingPacket
is invalid, MQTTRecvFailed on transport receive failure, MQTTBadResponse if an invalid packet is read, and MQTTNoDataAvailable if there is nothing to read.
Example
int32_t socket_recv(
void * pBuffer,
size_t bytesToRecv
);
int32_t bytesRecvd;
uint8_t buffer[ BUFFER_SIZE ];
do{
socket_recv,
&networkContext,
&incomingPacket
);
bytesRecvd = socket_recv(
&networkContext,
( void * ) buffer,
);
@ MQTTSuccess
Definition: core_mqtt_serializer.h:100
@ MQTTNoDataAvailable
Definition: core_mqtt_serializer.h:107
size_t remainingLength
Length of remaining serialized data.
Definition: core_mqtt_serializer.h:270
uint8_t * pRemainingData
Remaining serialized data in the MQTT packet.
Definition: core_mqtt_serializer.h:265