|
AWS IoT Device SDK C:
MQTT
MQTT 3.1.1 client library
|
| Return to main page ↑ |
MQTT client API definitions. More...
#include <string.h>#include "aws_iot_log.h"#include "aws_iot_mqtt_client_interface.h"#include "aws_iot_mqtt_client_common_internal.h"#include "aws_iot_version.h"#include "threads_interface.h"Macros | |
| #define | SDK_METRICS_LEN 25 |
| #define | SDK_METRICS_TEMPLATE "?SDK=C&Version=%d.%d.%d" |
Functions | |
| ClientState | aws_iot_mqtt_get_client_state (AWS_IoT_Client *pClient) |
| Get the current state of the client. More... | |
| IoT_Error_t | aws_iot_mqtt_client_lock_mutex (AWS_IoT_Client *pClient, IoT_Mutex_t *pMutex) |
| Lock a mutex in the MQTT client. More... | |
| IoT_Error_t | aws_iot_mqtt_client_unlock_mutex (AWS_IoT_Client *pClient, IoT_Mutex_t *pMutex) |
| Unlock a mutex in the MQTT client. More... | |
| IoT_Error_t | aws_iot_mqtt_set_client_state (AWS_IoT_Client *pClient, ClientState expectedCurrentState, ClientState newState) |
| Change the state in an MQTT client. More... | |
| IoT_Error_t | aws_iot_mqtt_set_connect_params (AWS_IoT_Client *pClient, IoT_Client_Connect_Params *pNewConnectParams) |
| Set the connection parameters for the IoT Client. More... | |
| 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... | |
| uint16_t | aws_iot_mqtt_get_next_packet_id (AWS_IoT_Client *pClient) |
| What is the next available packet Id. More... | |
| bool | aws_iot_mqtt_is_client_connected (AWS_IoT_Client *pClient) |
| Is the MQTT client currently connected? More... | |
| bool | aws_iot_is_autoreconnect_enabled (AWS_IoT_Client *pClient) |
| Is the MQTT client set to reconnect automatically? More... | |
| IoT_Error_t | aws_iot_mqtt_autoreconnect_set_status (AWS_IoT_Client *pClient, bool newStatus) |
| Enable or Disable AutoReconnect on Network Disconnect. More... | |
| IoT_Error_t | aws_iot_mqtt_set_disconnect_handler (AWS_IoT_Client *pClient, iot_disconnect_handler pDisconnectHandler, void *pDisconnectHandlerData) |
| Set the IoT Client disconnect handler. More... | |
| uint32_t | aws_iot_mqtt_get_network_disconnected_count (AWS_IoT_Client *pClient) |
| Get count of Network Disconnects. More... | |
| void | aws_iot_mqtt_reset_network_disconnected_count (AWS_IoT_Client *pClient) |
| Reset Network Disconnect conter. More... | |
MQTT client API definitions.
| #define SDK_METRICS_LEN 25 |
Length of metrics username
| #define SDK_METRICS_TEMPLATE "?SDK=C&Version=%d.%d.%d" |
Metrics username for AWS IoT
| ClientState aws_iot_mqtt_get_client_state | ( | AWS_IoT_Client * | pClient | ) |
Get the current state of the client.
Called to get the current state of the client
| pClient | Reference to the IoT Client |
| IoT_Error_t aws_iot_mqtt_client_lock_mutex | ( | AWS_IoT_Client * | pClient, |
| IoT_Mutex_t * | pMutex | ||
| ) |
Lock a mutex in the MQTT client.
| pClient | MQTT client |
| pMutex | Mutex to lock |
| IoT_Error_t aws_iot_mqtt_client_unlock_mutex | ( | AWS_IoT_Client * | pClient, |
| IoT_Mutex_t * | pMutex | ||
| ) |
Unlock a mutex in the MQTT client.
| pClient | MQTT client |
| pMutex | Mutex to unlock |
| IoT_Error_t aws_iot_mqtt_set_client_state | ( | AWS_IoT_Client * | pClient, |
| ClientState | expectedCurrentState, | ||
| ClientState | newState | ||
| ) |
Change the state in an MQTT client.
| pClient | MQTT client |
| expectedCurrentState | What the current state of the client should be |
| newState | What the new state of the client should be |
| IoT_Error_t aws_iot_mqtt_set_connect_params | ( | AWS_IoT_Client * | pClient, |
| IoT_Client_Connect_Params * | pNewConnectParams | ||
| ) |
Set the connection parameters for the IoT Client.
Called to set the connection parameters for the IoT Client. Used to update the connection parameters provided before the last connect. Won't take effect until the next time connect is called
| pClient | Reference to the IoT Client |
| pNewConnectParams | Reference to the new Connection Parameters structure |
| 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 |
| uint16_t aws_iot_mqtt_get_next_packet_id | ( | AWS_IoT_Client * | pClient | ) |
What is the next available packet Id.
Called to retrieve the next packet id to be used for outgoing packets. Automatically increments the last sent packet id variable
| pClient | Reference to the IoT Client |
| bool aws_iot_mqtt_is_client_connected | ( | AWS_IoT_Client * | pClient | ) |
Is the MQTT client currently connected?
Called to determine if the MQTT client is currently connected. Used to support logic in the device application around reconnecting and managing offline state.
| pClient | Reference to the IoT Client |
| bool aws_iot_is_autoreconnect_enabled | ( | AWS_IoT_Client * | pClient | ) |
Is the MQTT client set to reconnect automatically?
Called to determine if the MQTT client is set to reconnect automatically. Used to support logic in the device application around reconnecting
| pClient | Reference to the IoT Client |
| IoT_Error_t aws_iot_mqtt_autoreconnect_set_status | ( | AWS_IoT_Client * | pClient, |
| bool | newStatus | ||
| ) |
Enable or Disable AutoReconnect on Network Disconnect.
Called to enable or disabled the auto reconnect features provided with the SDK
| pClient | Reference to the IoT Client |
| newStatus | set to true for enabling and false for disabling |
| IoT_Error_t aws_iot_mqtt_set_disconnect_handler | ( | AWS_IoT_Client * | pClient, |
| iot_disconnect_handler | pDisconnectHandler, | ||
| void * | pDisconnectHandlerData | ||
| ) |
Set the IoT Client disconnect handler.
Called to set the IoT Client disconnect handler The disconnect handler is called whenever the client disconnects with error
| pClient | Reference to the IoT Client |
| pDisconnectHandler | Reference to the new Disconnect Handler |
| pDisconnectHandlerData | Reference to the data to be passed as argument when disconnect handler is called |
| uint32_t aws_iot_mqtt_get_network_disconnected_count | ( | AWS_IoT_Client * | pClient | ) |
Get count of Network Disconnects.
Called to get the number of times a network disconnect occurred due to errors
| pClient | Reference to the IoT Client |
| void aws_iot_mqtt_reset_network_disconnected_count | ( | AWS_IoT_Client * | pClient | ) |
Reset Network Disconnect conter.
Called to reset the Network Disconnect counter to zero
| pClient | Reference to the IoT Client |
| const IoT_Client_Init_Params iotClientInitParamsDefault = IoT_Client_Init_Params_initializer |
Default initializer for client
| const IoT_MQTT_Will_Options iotMqttWillOptionsDefault = IoT_MQTT_Will_Options_Initializer |
Default initializer for will
| const IoT_Client_Connect_Params iotClientConnectParamsDefault = IoT_Client_Connect_Params_initializer |
Default initializer for connect