AWS IoT Device SDK C:
MQTT
MQTT 3.1.1 client library
|
Return to main page ↑ |
Client definition for MQTT. More...
#include "stdio.h"
#include "stdbool.h"
#include "stdint.h"
#include "stddef.h"
#include "aws_iot_error.h"
#include "aws_iot_config.h"
#include "network_interface.h"
#include "timer_interface.h"
#include "threads_interface.h"
Go to the source code of this file.
Data Structures | |
struct | IoT_Publish_Message_Params |
Publish Message Parameters Type. More... | |
struct | IoT_MQTT_Will_Options |
Last Will and Testament Definition. More... | |
struct | IoT_Client_Connect_Params |
MQTT Connection Parameters. More... | |
struct | IoT_Client_Init_Params |
MQTT Initialization Parameters. More... | |
struct | MessageHandlers |
MQTT Message Handler. More... | |
struct | ClientStatus |
MQTT Client Status. More... | |
struct | ClientData |
MQTT Client Data. More... | |
struct | AWS_IoT_Client |
MQTT Client. More... | |
Macros | |
#define | MAX_PACKET_ID 65535 |
#define | IoT_MQTT_Will_Options_Initializer { {'M', 'Q', 'T', 'W'}, NULL, 0, NULL, 0, false, QOS0 } |
#define | IoT_Client_Connect_Params_initializer |
#define | IoT_Client_Init_Params_initializer { true, NULL, 0, NULL, NULL, NULL, 2000, 20000, 5000, true, NULL, NULL, false } |
Typedefs | |
typedef void(* | iot_disconnect_handler) (AWS_IoT_Client *, void *) |
Disconnect Callback Handler Type. More... | |
typedef void(* | pApplicationHandler_t) (AWS_IoT_Client *pClient, char *pTopicName, uint16_t topicNameLen, IoT_Publish_Message_Params *pParams, void *pClientData) |
Application Callback Handler Type. More... | |
Enumerations | |
enum | QoS { QOS0 = 0, QOS1 = 1 } |
Quality of Service Type. More... | |
enum | MQTT_Ver_t { MQTT_3_1_1 = 4 } |
MQTT Version Type. More... | |
enum | ClientState { CLIENT_STATE_INVALID = 0, CLIENT_STATE_INITIALIZED = 1, CLIENT_STATE_CONNECTING = 2, CLIENT_STATE_CONNECTED_IDLE = 3, CLIENT_STATE_CONNECTED_YIELD_IN_PROGRESS = 4, CLIENT_STATE_CONNECTED_PUBLISH_IN_PROGRESS = 5, CLIENT_STATE_CONNECTED_SUBSCRIBE_IN_PROGRESS = 6, CLIENT_STATE_CONNECTED_UNSUBSCRIBE_IN_PROGRESS = 7, CLIENT_STATE_CONNECTED_RESUBSCRIBE_IN_PROGRESS = 8, CLIENT_STATE_CONNECTED_WAIT_FOR_CB_RETURN = 9, CLIENT_STATE_DISCONNECTING = 10, CLIENT_STATE_DISCONNECTED_ERROR = 11, CLIENT_STATE_DISCONNECTED_MANUALLY = 12, CLIENT_STATE_PENDING_RECONNECT = 13 } |
MQTT Client State Type. More... | |
Functions | |
uint16_t | aws_iot_mqtt_get_next_packet_id (AWS_IoT_Client *pClient) |
What is the next available packet Id. 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... | |
bool | aws_iot_mqtt_is_client_connected (AWS_IoT_Client *pClient) |
Is the MQTT client currently connected? More... | |
ClientState | aws_iot_mqtt_get_client_state (AWS_IoT_Client *pClient) |
Get the current state of the client. 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_set_disconnect_handler (AWS_IoT_Client *pClient, iot_disconnect_handler pDisconnectHandler, void *pDisconnectHandlerData) |
Set the IoT Client disconnect handler. More... | |
IoT_Error_t | aws_iot_mqtt_autoreconnect_set_status (AWS_IoT_Client *pClient, bool newStatus) |
Enable or Disable AutoReconnect on Network Disconnect. 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... | |
Variables | |
const IoT_MQTT_Will_Options | iotMqttWillOptionsDefault |
const IoT_Client_Connect_Params | iotClientConnectParamsDefault |
const IoT_Client_Init_Params | iotClientInitParamsDefault |
Client definition for MQTT.
#define MAX_PACKET_ID 65535 |
Greatest packet identifier, per MQTT spec
#define IoT_MQTT_Will_Options_Initializer { {'M', 'Q', 'T', 'W'}, NULL, 0, NULL, 0, false, QOS0 } |
Default initializer for will
#define IoT_Client_Connect_Params_initializer |
Default initializer for connect
#define IoT_Client_Init_Params_initializer { true, NULL, 0, NULL, NULL, NULL, 2000, 20000, 5000, true, NULL, NULL, false } |
Default initializer for client
typedef void(* iot_disconnect_handler) (AWS_IoT_Client *, void *) |
Disconnect Callback Handler Type.
Defining a TYPE for definition of disconnect callback function pointers.
typedef void(* pApplicationHandler_t) (AWS_IoT_Client *pClient, char *pTopicName, uint16_t topicNameLen, IoT_Publish_Message_Params *pParams, void *pClientData) |
Application Callback Handler Type.
Defining a TYPE for definition of application callback function pointers. Used to send incoming data to the application
enum QoS |
Quality of Service Type.
Defining a QoS type.
enum MQTT_Ver_t |
enum ClientState |
MQTT Client State Type.
Defining a type for MQTT Client State
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 |
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 |
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 |
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 |
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_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 |
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 |
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_MQTT_Will_Options iotMqttWillOptionsDefault |
Default initializer for will
const IoT_Client_Connect_Params iotClientConnectParamsDefault |
Default initializer for connect
const IoT_Client_Init_Params iotClientInitParamsDefault |
Default initializer for client