Interface definition for MQTT client.
More...
#include "stddef.h"
#include "stdbool.h"
#include "stdint.h"
#include "aws_iot_error.h"
Go to the source code of this file.
| typedef void(* iot_disconnect_handler) (void) |
Defining a TYPE for definition of disconnect callback function pointers.
Defines a type for the function pointer which stores the message callback function. A pointer to the desired callback function to be invoked upon receipt of a message on a subscribed toipc. Supplied upon subscribing to a topic.
Defining an MQTT version type.
| Enumerator |
|---|
| MQTT_3_1 |
MQTT 3.1 (protocol message byte = 3)
|
| MQTT_3_1_1 |
MQTT 3.1.1 (protocol message byte = 4)
|
Defining a QoS type.
- Note
- QoS 2 is NOT supported by the AWS IoT Service at the time of this SDK release.
| Enumerator |
|---|
| QOS_0 |
QoS 0 = at most once delivery.
|
| QOS_1 |
QoS 1 = at least once delivery.
|
| QOS_2 |
QoS 2 is NOT supported.
|
| bool aws_iot_is_autoreconnect_enabled |
( |
void |
| ) |
|
Called to determine if the MQTT client is set to reconnect automatically. Used to support logic in the device application around reconnecting
- Returns
- true = enabled, false = disabled
| bool aws_iot_is_mqtt_connected |
( |
void |
| ) |
|
Called to determine if the MQTT client is currently connected. Used to support logic in the device application around reconnecting and managing offline state.
- Returns
- true = connected, false = not currently connected
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
- Returns
- An IoT Error Type defining successful/failed connection
| IoT_Error_t aws_iot_mqtt_autoreconnect_set_status |
( |
bool |
value | ) |
|
Called to enable or disabled the auto reconnect features provided with the SDK
- Parameters
-
| value | set to true for enabling and false for disabling |
- Returns
- IoT_Error_t Type defining successful/failed API call
Called to establish an MQTT connection with the AWS IoT Service
- Parameters
-
| pParams | Pointer to MQTT connection parameters |
- Returns
- An IoT Error Type defining successful/failed connection
Called to send a disconnect message to the broker.
- Returns
- An IoT Error Type defining successful/failed send of the disconnect control packet.
This function provides a way to pass in an MQTT client implementation to the AWS IoT MQTT wrapper layer. This is done through function pointers to the interface functions.
Called to publish an MQTT message on a topic.
- Note
- Call is blocking. In the case of a QoS 0 message the function returns after the message was successfully passed to the TLS layer. In the case of QoS 1 the function returns after the receipt of the PUBACK control packet.
- Parameters
-
| pParams | Pointer to MQTT publish parameters |
- Returns
- An IoT Error Type defining successful/failed publish
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.
- Parameters
-
| pParams | Pointer to MQTT subscribe parameters |
- Returns
- An IoT Error Type defining successful/failed subscription
Called to send an usubscribe message to the broker requesting removal of a subscription to an MQTT topic.
- Note
- Call is blocking. The call returns after the receipt of the UNSUBACK control packet.
- Parameters
-
| pTopic | Pointer to the requested topic string. Ensure the string is null terminated |
- Returns
- An IoT Error Type defining successful/failed unsubscription
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.
- Parameters
-
| timeout | Maximum number of milliseconds to pass thread execution to the client. |
- Returns
- An IoT Error Type defining successful/failed client processing. If this call results in an error it is likely the MQTT connection has dropped. iot_is_mqtt_connected can be called to confirm.