AWS IoT Device SDK C: MQTT
MQTT 3.1.1 client library
Return to main page ↑
aws_iot_mqtt_client_subscribe.c File Reference

MQTT client subscribe API definitions. More...

Functions

IoT_Error_t aws_iot_mqtt_subscribe (AWS_IoT_Client *pClient, const char *pTopicName, uint16_t topicNameLen, QoS qos, pApplicationHandler_t pApplicationHandler, void *pApplicationHandlerData)
 Subscribe to an MQTT topic. More...
 
IoT_Error_t aws_iot_mqtt_resubscribe (AWS_IoT_Client *pClient)
 Subscribe to an MQTT topic. More...
 

Detailed Description

MQTT client subscribe API definitions.

Function Documentation

◆ aws_iot_mqtt_subscribe()

IoT_Error_t aws_iot_mqtt_subscribe ( AWS_IoT_Client *  pClient,
const char *  pTopicName,
uint16_t  topicNameLen,
QoS  qos,
pApplicationHandler_t  pApplicationHandler,
void *  pApplicationHandlerData 
)

Subscribe to an MQTT topic.

Called to send a subscribe message to the broker requesting a subscription to an MQTT topic.

Note
Call is blocking. The call returns after the receipt of the SUBACK control packet.
Warning
pTopicName and pApplicationHandlerData need to be static in memory.
Parameters
pClientReference to the IoT Client
pTopicNameTopic Name to publish to. pTopicName needs to be static in memory since no malloc is performed by the SDK
topicNameLenLength of the topic name
qosQuality of service for subscription
pApplicationHandlerReference to the handler function for this subscription
pApplicationHandlerDataPoint to data passed to the callback. pApplicationHandlerData also needs to be static in memory since no malloc is performed by the SDK
Returns
An IoT Error Type defining successful/failed subscription

◆ aws_iot_mqtt_resubscribe()

IoT_Error_t aws_iot_mqtt_resubscribe ( AWS_IoT_Client *  pClient)

Subscribe to an MQTT topic.

Called to resubscribe to the topics that the client has active subscriptions on. Internally called when autoreconnect is enabled

Note
Call is blocking. The call returns after the receipt of the SUBACK control packet.
Parameters
pClientReference to the IoT Client
Returns
An IoT Error Type defining successful/failed subscription