AWS IoT Embedded C Device SDK
Functions
aws_iot_mqtt_client_publish.c File Reference

MQTT client publish API definitions. More...

#include "aws_iot_mqtt_client_common_internal.h"

Functions

IoT_Error_t aws_iot_mqtt_internal_serialize_ack (unsigned char *pTxBuf, size_t txBufLen, MessageTypes msgType, uint8_t dup, uint16_t packetId, uint32_t *pSerializedLen)
 
IoT_Error_t aws_iot_mqtt_publish (AWS_IoT_Client *pClient, const char *pTopicName, uint16_t topicNameLen, IoT_Publish_Message_Params *pParams)
 Publish an MQTT message on a topic. More...
 
IoT_Error_t aws_iot_mqtt_internal_deserialize_publish (uint8_t *dup, QoS *qos, uint8_t *retained, uint16_t *pPacketId, char **pTopicName, uint16_t *topicNameLen, unsigned char **payload, size_t *payloadLen, unsigned char *pRxBuf, size_t rxBufLen)
 
IoT_Error_t aws_iot_mqtt_internal_deserialize_ack (unsigned char *pPacketType, unsigned char *dup, uint16_t *pPacketId, unsigned char *pRxBuf, size_t rxBuflen)
 

Function Documentation

IoT_Error_t aws_iot_mqtt_internal_deserialize_ack ( unsigned char *  pPacketType,
unsigned char *  dup,
uint16_t *  pPacketId,
unsigned char *  pRxBuf,
size_t  rxBuflen 
)

Deserializes the supplied (wire) buffer into an ack

Parameters
pPacketTypereturned integer - the MQTT packet type
dupreturned integer - the MQTT dup flag
pPacketIdreturned integer - the MQTT packet identifier
pRxBufthe raw buffer data, of the correct length determined by the remaining length field
rxBuflenthe length in bytes of the data in the supplied buffer
Returns
An IoT Error Type defining successful/failed call
IoT_Error_t aws_iot_mqtt_internal_deserialize_publish ( uint8_t *  dup,
QoS qos,
uint8_t *  retained,
uint16_t *  pPacketId,
char **  pTopicName,
uint16_t *  topicNameLen,
unsigned char **  payload,
size_t *  payloadLen,
unsigned char *  pRxBuf,
size_t  rxBufLen 
)

Deserializes the supplied (wire) buffer into publish data

Parameters
dupreturned uint8_t - the MQTT dup flag
qosreturned QoS type - the MQTT QoS value
retainedreturned uint8_t - the MQTT retained flag
pPacketIdreturned uint16_t - the MQTT packet identifier
pTopicNamereturned String - the MQTT topic in the publish
topicNameLenreturned uint16_t - the length of the MQTT topic in the publish
payloadreturned byte buffer - the MQTT publish payload
payloadlenreturned size_t - the length of the MQTT payload
pRxBufthe raw buffer data, of the correct length determined by the remaining length field
rxBufLenthe length in bytes of the data in the supplied buffer
Returns
An IoT Error Type defining successful/failed call
IoT_Error_t aws_iot_mqtt_internal_serialize_ack ( unsigned char *  pTxBuf,
size_t  txBufLen,
MessageTypes  msgType,
uint8_t  dup,
uint16_t  packetId,
uint32_t *  pSerializedLen 
)

Serializes the ack packet into the supplied buffer.

Parameters
pTxBufthe buffer into which the packet will be serialized
txBufLenthe length in bytes of the supplied buffer
msgTypethe MQTT packet type
dupthe MQTT dup flag
packetIdthe MQTT packet identifier
pSerializedLenuint32_t - pointer to the variable that stores serialized len
Returns
An IoT Error Type defining successful/failed call
IoT_Error_t aws_iot_mqtt_publish ( AWS_IoT_Client pClient,
const char *  pTopicName,
uint16_t  topicNameLen,
IoT_Publish_Message_Params pParams 
)

Called to publish an MQTT message on a topic.

Note
Call is blocking. In the case of a QoS 0 message the function returns after the message was successfully passed to the TLS layer. In the case of QoS 1 the function returns after the receipt of the PUBACK control packet. This is the outer function which does the validations and calls the internal publish above to perform the actual operation. It is also responsible for client state changes
Parameters
pClientReference to the IoT Client
pTopicNameTopic Name to publish to
topicNameLenLength of the topic name
pParamsPointer to Publish Message parameters
Returns
An IoT Error Type defining successful/failed publish