AWS IoT Device SDK C:
MQTT
MQTT 3.1.1 client library
|
Return to main page ↑ |
Interface definition for MQTT client. More...
#include "stdio.h"
#include "stdbool.h"
#include "stdint.h"
#include "stddef.h"
#include "aws_iot_error.h"
#include "aws_iot_config.h"
#include "aws_iot_mqtt_client.h"
#include "network_interface.h"
#include "timer_interface.h"
Go to the source code of this file.
Functions | |
IoT_Error_t | aws_iot_mqtt_free (AWS_IoT_Client *pClient) |
Clean mqtt client from all dynamic memory allocate. More... | |
IoT_Error_t | aws_iot_mqtt_init (AWS_IoT_Client *pClient, IoT_Client_Init_Params *pInitParams) |
MQTT Client Initialization Function. More... | |
IoT_Error_t | aws_iot_mqtt_connect (AWS_IoT_Client *pClient, IoT_Client_Connect_Params *pConnectParams) |
MQTT Connection Function. More... | |
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_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... | |
IoT_Error_t | aws_iot_mqtt_unsubscribe (AWS_IoT_Client *pClient, const char *pTopicFilter, uint16_t topicFilterLen) |
Unsubscribe to an MQTT topic. More... | |
IoT_Error_t | aws_iot_mqtt_disconnect (AWS_IoT_Client *pClient) |
Disconnect an MQTT Connection. More... | |
IoT_Error_t | aws_iot_mqtt_yield (AWS_IoT_Client *pClient, uint32_t timeout_ms) |
Yield to the MQTT client. More... | |
IoT_Error_t | aws_iot_mqtt_attempt_reconnect (AWS_IoT_Client *pClient) |
MQTT Manual Re-Connection Function. More... | |
Interface definition for MQTT client.
IoT_Error_t aws_iot_mqtt_free | ( | AWS_IoT_Client * | pClient | ) |
Clean mqtt client from all dynamic memory allocate.
This function will free up memory that was dynamically allocated for the client.
pClient | MQTT Client that was previously created by calling aws_iot_mqtt_init |
IoT_Error_t aws_iot_mqtt_init | ( | AWS_IoT_Client * | pClient, |
IoT_Client_Init_Params * | pInitParams | ||
) |
MQTT Client Initialization Function.
Called to initialize the MQTT Client
pClient | Reference to the IoT Client |
pInitParams | Pointer to MQTT connection parameters |
IoT_Error_t aws_iot_mqtt_connect | ( | AWS_IoT_Client * | pClient, |
IoT_Client_Connect_Params * | pConnectParams | ||
) |
MQTT Connection Function.
Called to establish an MQTT connection with the AWS IoT Service
pClient | Reference to the IoT Client |
pConnectParams | Pointer to MQTT connection parameters |
Called to establish an MQTT connection with the AWS IoT Service This is the outer function which does the validations and calls the internal connect above to perform the actual operation. It is also responsible for client state changes
pClient | Reference to the IoT Client |
pConnectParams | Pointer to MQTT connection parameters |
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.
pClient | Reference to the IoT Client |
pTopicName | Topic Name to publish to |
topicNameLen | Length of the topic name |
pParams | Pointer to Publish Message parameters |
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.
pClient | Reference to the IoT Client |
pTopicName | Topic Name to publish to. pTopicName needs to be static in memory since no malloc is performed by the SDK |
topicNameLen | Length of the topic name |
qos | Quality of service for subscription |
pApplicationHandler | Reference to the handler function for this subscription |
pApplicationHandlerData | Point to data passed to the callback. pApplicationHandlerData also needs to be static in memory since no malloc is performed by the SDK |
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
pClient | Reference to the IoT Client |
IoT_Error_t aws_iot_mqtt_unsubscribe | ( | AWS_IoT_Client * | pClient, |
const char * | pTopicFilter, | ||
uint16_t | topicFilterLen | ||
) |
Unsubscribe to an MQTT topic.
Called to send an unsubscribe message to the broker requesting removal of a subscription to an MQTT topic.
pClient | Reference to the IoT Client |
pTopicFilter | Topic filter of subscription |
topicFilterLen | Length of the topic filter |
IoT_Error_t aws_iot_mqtt_disconnect | ( | AWS_IoT_Client * | pClient | ) |
Disconnect an MQTT Connection.
Called to send a disconnect message to the broker.
pClient | Reference to the IoT Client |
Called to send a disconnect message to the broker. This is the outer function which does the validations and calls the internal disconnect above to perform the actual operation. It is also responsible for client state changes
pClient | Reference to the IoT Client |
IoT_Error_t aws_iot_mqtt_yield | ( | AWS_IoT_Client * | pClient, |
uint32_t | timeout_ms | ||
) |
Yield to the MQTT client.
Called to yield the current thread to the underlying MQTT client. This time is used by the MQTT client to manage PING requests to monitor the health of the TCP connection as well as periodically check the socket receive buffer for subscribe messages. Yield() must be called at a rate faster than the keepalive interval. It must also be called at a rate faster than the incoming message rate as this is the only way the client receives processing time to manage incoming messages.
pClient | Reference to the IoT Client |
timeout_ms | Maximum number of milliseconds to pass thread execution to the client. |
IoT_Error_t aws_iot_mqtt_attempt_reconnect | ( | AWS_IoT_Client * | pClient | ) |
MQTT Manual Re-Connection Function.
Called to establish an MQTT connection with the AWS IoT Service using parameters from the last time a connection was attempted Use after disconnect to start the reconnect process manually Makes only one reconnect attempt Sets the client state to pending reconnect in case of failure
pClient | Reference to the IoT Client |
Called to establish an MQTT connection with the AWS IoT Service using parameters from the last time a connection was attempted Use after disconnect to start the reconnect process manually Makes only one reconnect attempt. Sets the client state to pending reconnect in case of failure
pClient | Reference to the IoT Client |