AWS IoT Device SDK C:
MQTT
MQTT 3.1.1 client library
|
Return to main page ↑ |
User-facing functions for serializing MQTT 3.1.1 packets. This header should be included for building a single threaded light-weight MQTT client bypassing stateful CSDK MQTT library. More...
Go to the source code of this file.
Functions | |
IotMqttError_t | IotMqtt_GetConnectPacketSize (const IotMqttConnectInfo_t *pConnectInfo, size_t *pRemainingLength, size_t *pPacketSize) |
Calculate the size and "Remaining length" of a CONNECT packet generated from the given parameters. More... | |
IotMqttError_t | IotMqtt_SerializeConnect (const IotMqttConnectInfo_t *pConnectInfo, size_t remainingLength, uint8_t *pBuffer, size_t bufferSize) |
Generate a CONNECT packet from the given parameters. More... | |
IotMqttError_t | IotMqtt_GetSubscriptionPacketSize (IotMqttOperationType_t type, const IotMqttSubscription_t *pSubscriptionList, size_t subscriptionCount, size_t *pRemainingLength, size_t *pPacketSize) |
Calculate the size and "Remaining length" of a SUBSCRIBE or UNSUBSCRIBE packet generated from the given parameters. More... | |
IotMqttError_t | IotMqtt_SerializeSubscribe (const IotMqttSubscription_t *pSubscriptionList, size_t subscriptionCount, size_t remainingLength, uint16_t *pPacketIdentifier, uint8_t *pBuffer, size_t bufferSize) |
Generate a SUBSCRIBE packet from the given parameters. More... | |
IotMqttError_t | IotMqtt_SerializeUnsubscribe (const IotMqttSubscription_t *pSubscriptionList, size_t subscriptionCount, size_t remainingLength, uint16_t *pPacketIdentifier, uint8_t *pBuffer, size_t bufferSize) |
Generate a UNSUBSCRIBE packet from the given parameters. More... | |
IotMqttError_t | IotMqtt_GetPublishPacketSize (const IotMqttPublishInfo_t *pPublishInfo, size_t *pRemainingLength, size_t *pPacketSize) |
Calculate the size and "Remaining length" of a PUBLISH packet generated from the given parameters. More... | |
IotMqttError_t | IotMqtt_SerializePublish (const IotMqttPublishInfo_t *pPublishInfo, size_t remainingLength, uint16_t *pPacketIdentifier, uint8_t **pPacketIdentifierHigh, uint8_t *pBuffer, size_t bufferSize) |
Generate a PUBLISH packet from the given parameters. More... | |
IotMqttError_t | IotMqtt_SerializeDisconnect (uint8_t *pBuffer, size_t bufferSize) |
Generate a DISCONNECT packet. More... | |
IotMqttError_t | IotMqtt_SerializePingreq (uint8_t *pBuffer, size_t bufferSize) |
Generate a PINGREQ packet. More... | |
IotMqttError_t | IotMqtt_GetIncomingMQTTPacketTypeAndLength (IotMqttPacketInfo_t *pIncomingPacket, IotMqttGetNextByte_t getNextByte, IotNetworkConnection_t pNetworkConnection) |
Extract MQTT packet type and length from incoming packet. More... | |
IotMqttError_t | IotMqtt_DeserializePublish (IotMqttPacketInfo_t *pMqttPacket) |
Deserialize incoming publish packet. More... | |
IotMqttError_t | IotMqtt_DeserializeResponse (IotMqttPacketInfo_t *pMqttPacket) |
Deserialize incoming ack packets. More... | |
User-facing functions for serializing MQTT 3.1.1 packets. This header should be included for building a single threaded light-weight MQTT client bypassing stateful CSDK MQTT library.
IotMqttError_t IotMqtt_GetConnectPacketSize | ( | const IotMqttConnectInfo_t * | pConnectInfo, |
size_t * | pRemainingLength, | ||
size_t * | pPacketSize | ||
) |
Calculate the size and "Remaining length" of a CONNECT packet generated from the given parameters.
[in] | pConnectInfo | User-provided CONNECT information struct. |
[out] | pRemainingLength | Output for calculated "Remaining length" field. |
[out] | pPacketSize | Output for calculated total packet size. |
IOT_MQTT_BAD_PARAMETER
, the output parameters should be ignored.Example
IotMqttError_t IotMqtt_SerializeConnect | ( | const IotMqttConnectInfo_t * | pConnectInfo, |
size_t | remainingLength, | ||
uint8_t * | pBuffer, | ||
size_t | bufferSize | ||
) |
Generate a CONNECT packet from the given parameters.
[in] | pConnectInfo | User-provided CONNECT information. |
[in] | remainingLength | remaining length of the packet to be serialized. |
[in,out] | pBuffer | User provided buffer where the CONNECT packet is written. |
[in] | bufferSize | Size of the buffer pointed to by pBuffer. |
Example
IotMqttError_t IotMqtt_GetSubscriptionPacketSize | ( | IotMqttOperationType_t | type, |
const IotMqttSubscription_t * | pSubscriptionList, | ||
size_t | subscriptionCount, | ||
size_t * | pRemainingLength, | ||
size_t * | pPacketSize | ||
) |
Calculate the size and "Remaining length" of a SUBSCRIBE or UNSUBSCRIBE packet generated from the given parameters.
[in] | type | Either IOT_MQTT_SUBSCRIBE or IOT_MQTT_UNSUBSCRIBE. |
[in] | pSubscriptionList | User-provided array of subscriptions. |
[in] | subscriptionCount | Size of pSubscriptionList . |
[out] | pRemainingLength | Output for calculated "Remaining length" field. |
[out] | pPacketSize | Output for calculated total packet size. |
Example
IotMqttError_t IotMqtt_SerializeSubscribe | ( | const IotMqttSubscription_t * | pSubscriptionList, |
size_t | subscriptionCount, | ||
size_t | remainingLength, | ||
uint16_t * | pPacketIdentifier, | ||
uint8_t * | pBuffer, | ||
size_t | bufferSize | ||
) |
Generate a SUBSCRIBE packet from the given parameters.
[in] | pSubscriptionList | User-provided array of subscriptions. |
[in] | subscriptionCount | Size of pSubscriptionList . |
[in] | remainingLength | remaining length of the packet to be serialized. |
[out] | pPacketIdentifier | The packet identifier generated for this SUBSCRIBE. |
[in,out] | pBuffer | User provide buffer where the SUBSCRIBE packet is written. |
[in] | bufferSize | Size of the buffer pointed to by pBuffer. |
IotMqttError_t IotMqtt_SerializeUnsubscribe | ( | const IotMqttSubscription_t * | pSubscriptionList, |
size_t | subscriptionCount, | ||
size_t | remainingLength, | ||
uint16_t * | pPacketIdentifier, | ||
uint8_t * | pBuffer, | ||
size_t | bufferSize | ||
) |
Generate a UNSUBSCRIBE packet from the given parameters.
[in] | pSubscriptionList | User-provided array of subscriptions to remove. |
[in] | subscriptionCount | Size of pSubscriptionList . |
[in] | remainingLength | remaining length of the packet to be serialized. |
[out] | pPacketIdentifier | The packet identifier generated for this UNSUBSCRIBE. |
[in,out] | pBuffer | User provide buffer where the UNSUBSCRIBE packet is written. |
[in] | bufferSize | Size of the buffer pointed to by pBuffer. |
Example
IotMqttError_t IotMqtt_GetPublishPacketSize | ( | const IotMqttPublishInfo_t * | pPublishInfo, |
size_t * | pRemainingLength, | ||
size_t * | pPacketSize | ||
) |
Calculate the size and "Remaining length" of a PUBLISH packet generated from the given parameters.
[in] | pPublishInfo | User-provided PUBLISH information struct. |
[out] | pRemainingLength | Output for calculated "Remaining length" field. |
[out] | pPacketSize | Output for calculated total packet size. |
Example
IotMqttError_t IotMqtt_SerializePublish | ( | const IotMqttPublishInfo_t * | pPublishInfo, |
size_t | remainingLength, | ||
uint16_t * | pPacketIdentifier, | ||
uint8_t ** | pPacketIdentifierHigh, | ||
uint8_t * | pBuffer, | ||
size_t | bufferSize | ||
) |
Generate a PUBLISH packet from the given parameters.
[in] | pPublishInfo | User-provided PUBLISH information. |
[in] | remainingLength | remaining length of the packet to be serialized. |
[out] | pPacketIdentifier | The packet identifier generated for this PUBLISH. |
[out] | pPacketIdentifierHigh | Where the high byte of the packet identifier is written. |
[in,out] | pBuffer | User provide buffer where the PUBLISH packet is written. |
[in] | bufferSize | Size of the buffer pointed to by pBuffer. |
Example
IotMqttError_t IotMqtt_SerializeDisconnect | ( | uint8_t * | pBuffer, |
size_t | bufferSize | ||
) |
Generate a DISCONNECT packet.
[in,out] | pBuffer | User provide buffer where the DISCONNECT packet is written. |
[in] | bufferSize | Size of the buffer pointed to by pBuffer. |
Example
IotMqttError_t IotMqtt_SerializePingreq | ( | uint8_t * | pBuffer, |
size_t | bufferSize | ||
) |
Generate a PINGREQ packet.
[in,out] | pBuffer | User provide buffer where the PINGREQ packet is written. |
[in] | bufferSize | Size of the buffer pointed to by pBuffer. |
Example
IotMqttError_t IotMqtt_GetIncomingMQTTPacketTypeAndLength | ( | IotMqttPacketInfo_t * | pIncomingPacket, |
IotMqttGetNextByte_t | getNextByte, | ||
IotNetworkConnection_t | pNetworkConnection | ||
) |
Extract MQTT packet type and length from incoming packet.
[in,out] | pIncomingPacket | Pointer to IotMqttPacketInfo_t structure where type, remaining length and packet identifier are stored. |
[in] | getNextByte | Pointer to platform specific function which is used to extract type and length from incoming received stream (see example ). |
[in] | pNetworkConnection | Pointer to platform specific network connection which is used by getNextByte to receive network data |
Example
IotMqttError_t IotMqtt_DeserializePublish | ( | IotMqttPacketInfo_t * | pMqttPacket | ) |
Deserialize incoming publish packet.
[in,out] | pMqttPacket | The caller of this API sets type, remainingLength and pRemainingData. On success, packetIdentifier and pubInfo will be set by the function. |
Example
IotMqttError_t IotMqtt_DeserializeResponse | ( | IotMqttPacketInfo_t * | pMqttPacket | ) |
Deserialize incoming ack packets.
[in,out] | pMqttPacket | The caller of this API sets type, remainingLength and pRemainingData. On success, packetIdentifier will be set. |
Example