MQTT API Reference
MQTT 3.1.1 client library
IotMqtt_SerializePingreq

Generate a PINGREQ packet.

size_t bufferSize );
Parameters
[in,out]pBufferUser provide buffer where the PINGREQ packet is written.
[in]bufferSizeSize of the buffer pointed to by pBuffer.
Returns
IOT_MQTT_SUCCESS or IOT_MQTT_BAD_PARAMETER.
Note
This call is part of serializer API used for implementing light-weight MQTT client.

Example

// Example below shows how IotMqtt_SerializePingReq() should be used.
#define mqttexampleSHARED_BUFFER_SIZE 100
static ucSharedBuffer[mqttexampleSHARED_BUFFER_SIZE];
void sendPingRequest( int xMQTTSocket )
{
size_t xSentBytes = 0;
// PingReq is fixed length packet, therefore there is no need to calculate the size,
// just makes sure static buffer can accommodate Ping request.
IotMqtt_Assert( MQTT_PACKET_PINGREQ_SIZE <= mqttexampleSHARED_BUFFER_SIZE );
xResult = IotMqtt_SerializePingreq( ucSharedBuffer, MQTT_PACKET_PINGREQ_SIZE );
// xMQTTSocket here is posix socket created and connected to MQTT broker outside of this function.
xSentByte = send( xMQTTSocket, ( void * ) ucSharedBuffer, MQTT_PACKET_DISCONNECT_SIZE, 0 );
}
MQTT_PACKET_PINGREQ_SIZE
#define MQTT_PACKET_PINGREQ_SIZE
A PINGREQ packet is always 2 bytes in size.
Definition: iot_mqtt_serialize.c:142
IotMqtt_SerializePingreq
IotMqttError_t IotMqtt_SerializePingreq(uint8_t *pBuffer, size_t bufferSize)
Generate a PINGREQ packet.
Definition: iot_mqtt_serialize.c:2470
IotMqttError_t
IotMqttError_t
Return codes of MQTT functions.
Definition: iot_mqtt_types.h:103
IOT_MQTT_SUCCESS
MQTT operation completed successfully.
Definition: iot_mqtt_types.h:119
MQTT_PACKET_DISCONNECT_SIZE
#define MQTT_PACKET_DISCONNECT_SIZE
A DISCONNECT packet is always 2 bytes in size.
Definition: iot_mqtt_serialize.c:148
IotMqtt_Assert
#define IotMqtt_Assert(expression)
Assertion macro for the MQTT library.
Definition: iot_mqtt_internal.h:62