AWS IoT Device SDK C:
MQTT
MQTT 3.1.1 client library
|
Return to main page ↑ |
MQTT connection details. More...
#include <iot_mqtt_types.h>
Data Fields | |
bool | awsIotMqttMode |
Specifies if this MQTT connection is to an AWS IoT MQTT server. More... | |
bool | cleanSession |
Whether this connection is a clean session. More... | |
const IotMqttSubscription_t * | pPreviousSubscriptions |
An array of MQTT subscriptions present in a previous session, if any. More... | |
size_t | previousSubscriptionCount |
The number of MQTT subscriptions present in a previous session, if any. More... | |
const IotMqttPublishInfo_t * | pWillInfo |
A message to publish if the new MQTT connection is unexpectedly closed. More... | |
uint16_t | keepAliveSeconds |
Period of keep-alive messages. Set to 0 to disable keep-alive. | |
const char * | pClientIdentifier |
MQTT client identifier. | |
uint16_t | clientIdentifierLength |
Length of IotMqttConnectInfo_t.pClientIdentifier. | |
const char * | pUserName |
Username for MQTT connection. More... | |
uint16_t | userNameLength |
Length of IotMqttConnectInfo_t.pUserName. | |
const char * | pPassword |
Password for MQTT connection. | |
uint16_t | passwordLength |
Length of IotMqttConnectInfo_t.pPassword. | |
MQTT connection details.
Parameter for: IotMqtt_Connect
Passed as an argument to IotMqtt_Connect. Most members of this struct correspond to the content of an MQTT CONNECT packet.
All instances of IotMqttConnectInfo_t should be initialized with IOT_MQTT_CONNECT_INFO_INITIALIZER.
bool IotMqttConnectInfo_t::awsIotMqttMode |
Specifies if this MQTT connection is to an AWS IoT MQTT server.
Set this member to true
when connecting to the AWS IoT MQTT broker or false
otherwise. Additional details about connecting to AWS IoT via MQTT are available here
true
when using the AWS IoT MQTT server; it MUST be false
otherwise. true
. bool IotMqttConnectInfo_t::cleanSession |
Whether this connection is a clean session.
MQTT servers can maintain and topic filter subscriptions and unacknowledged PUBLISH messages. These form part of an MQTT session, which is identified by the client identifier.
Setting this value to true
establishes a clean session, which causes the MQTT server to discard any previous session data for a client identifier. When the client disconnects, the server discards all session data. If this value is true
, IotMqttConnectInfo_t.pPreviousSubscriptions and IotMqttConnectInfo_t.previousSubscriptionCount are ignored.
Setting this value to false
does one of the following:
When a client with a persistent session disconnects, the MQTT server continues to maintain all subscriptions and unacknowledged PUBLISH messages. The client must also remember the session subscriptions to restore them upon reconnecting. IotMqttConnectInfo_t.pPreviousSubscriptions and IotMqttConnectInfo_t.previousSubscriptionCount are used to restore a previous session's subscriptions client-side.
const IotMqttSubscription_t* IotMqttConnectInfo_t::pPreviousSubscriptions |
An array of MQTT subscriptions present in a previous session, if any.
Pointer to the start of an array of subscriptions present a previous session, if any. These subscriptions will be immediately restored upon reconnecting.
[Optional] The field can also be used to pass a list of subscriptions to be stored locally without a SUBSCRIBE packet being sent to the broker. These subscriptions are useful to invoke application level callbacks for messages received on unsolicited topics from the broker.
This member is ignored if it is NULL
. If this member is not NULL
, IotMqttConnectInfo_t.previousSubscriptionCount must be nonzero.
size_t IotMqttConnectInfo_t::previousSubscriptionCount |
The number of MQTT subscriptions present in a previous session, if any.
Number of subscriptions contained in the array IotMqttConnectInfo_t.pPreviousSubscriptions.
This value is ignored if IotMqttConnectInfo_t.pPreviousSubscriptions is NULL
. If IotMqttConnectInfo_t.pPreviousSubscriptions is not NULL
, this value must be nonzero.
const IotMqttPublishInfo_t* IotMqttConnectInfo_t::pWillInfo |
A message to publish if the new MQTT connection is unexpectedly closed.
A Last Will and Testament (LWT) message may be published if this connection is closed without sending an MQTT DISCONNECT packet. This pointer should be set to an IotMqttPublishInfo_t representing any LWT message to publish. If an LWT is not needed, this member must be set to NULL
.
Unlike other PUBLISH messages, an LWT message is limited to 65535 bytes in length. Additionally, pWillInfo->retryMs and pWillInfo->retryLimit will be ignored.
const char* IotMqttConnectInfo_t::pUserName |
Username for MQTT connection.
The MQTT username and password can be used for AWS IoT Enhanced Custom Authentication as described here.