Jim Flynn / Mbed OS aws-iot-device-sdk-mbed-c
Embed: (wiki syntax)

« Back to documentation index

aws_iot_mqtt_client_publish.c File Reference

aws_iot_mqtt_client_publish.c File Reference

MQTT client publish API definitions. More...

Go to the source code of this file.

Functions

static IoT_Error_t _aws_iot_mqtt_read_string_with_len (char **stringVar, uint16_t *stringLen, unsigned char **pptr, unsigned char *enddata)
static IoT_Error_t _aws_iot_mqtt_internal_serialize_publish (unsigned char *pTxBuf, size_t txBufLen, uint8_t dup, QoS qos, uint8_t retained, uint16_t packetId, const char *pTopicName, uint16_t topicNameLen, const unsigned char *pPayload, size_t payloadLen, uint32_t *pSerializedLen)
 Serializes the supplied publish data into the supplied buffer, ready for sending.
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.
static IoT_Error_t _aws_iot_mqtt_internal_publish (AWS_IoT_Client *pClient, const char *pTopicName, uint16_t topicNameLen, IoT_Publish_Message_Params *pParams)
 Publish an MQTT message on a topic.
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.
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.
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.

Detailed Description

MQTT client publish API definitions.

Definition in file aws_iot_mqtt_client_publish.c.


Function Documentation

static IoT_Error_t _aws_iot_mqtt_internal_publish ( AWS_IoT_Client pClient,
const char *  pTopicName,
uint16_t  topicNameLen,
IoT_Publish_Message_Params pParams 
) [static]

Publish an MQTT message on a topic.

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 internal function which is called by the publish API to perform the operation. Not meant to be called directly as it doesn't do validations or 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

Definition at line 197 of file aws_iot_mqtt_client_publish.c.

static IoT_Error_t _aws_iot_mqtt_internal_serialize_publish ( unsigned char *  pTxBuf,
size_t  txBufLen,
uint8_t  dup,
QoS  qos,
uint8_t  retained,
uint16_t  packetId,
const char *  pTopicName,
uint16_t  topicNameLen,
const unsigned char *  pPayload,
size_t  payloadLen,
uint32_t *  pSerializedLen 
) [static]

Serializes the supplied publish data into the supplied buffer, ready for sending.

Parameters:
pTxBufthe buffer into which the packet will be serialized
txBufLenthe length in bytes of the supplied buffer
dupuint8_t - the MQTT dup flag
qosQoS - the MQTT QoS value
retaineduint8_t - the MQTT retained flag
packetIduint16_t - the MQTT packet identifier
pTopicNamechar * - the MQTT topic in the publish
topicNameLenuint16_t - the length of the Topic Name
pPayloadbyte buffer - the MQTT publish payload
payloadLensize_t - the length of the MQTT payload
pSerializedLenuint32_t - pointer to the variable that stores serialized len
Returns:
An IoT Error Type defining successful/failed call

Definition at line 87 of file aws_iot_mqtt_client_publish.c.

static IoT_Error_t _aws_iot_mqtt_read_string_with_len ( char **  stringVar,
uint16_t *  stringLen,
unsigned char **  pptr,
unsigned char *  enddata 
) [static]
Parameters:
stringVarpointer to the String into which the data is to be read
stringLenpointer to variable which has the length of the string
pptrpointer to the output buffer - incremented by the number of bytes used & returned
enddatapointer to the end of the data: do not read beyond
Returns:
AWS_SUCCESS if successful, FAILURE if not

Definition at line 52 of file aws_iot_mqtt_client_publish.c.

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

Definition at line 383 of file aws_iot_mqtt_client_publish.c.

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

Definition at line 312 of file aws_iot_mqtt_client_publish.c.

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

Definition at line 146 of file aws_iot_mqtt_client_publish.c.

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.

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

Definition at line 262 of file aws_iot_mqtt_client_publish.c.