天嵌二次封装库使用手册  V2.1.2
MQTTClient_connectOptions结构体 参考

#include <MQTTClient.h>

MQTTClient_connectOptions 的协作图:

Public 属性

char struct_id [4]
 
int struct_version
 
int keepAliveInterval
 
int cleansession
 
int reliable
 
MQTTClient_willOptionswill
 
const char * username
 
const char * password
 
int connectTimeout
 
int retryInterval
 
MQTTClient_SSLOptionsssl
 
int serverURIcount
 
char *const * serverURIs
 
int MQTTVersion
 
struct {
   const char *   serverURI
 
   int   MQTTVersion
 
   int   sessionPresent
 
returned
 
struct {
   int   len
 
   const void *   data
 
binarypwd
 
int maxInflightMessages
 
int cleanstart
 
const MQTTClient_nameValuehttpHeaders
 
const char * httpProxy
 
const char * httpsProxy
 

详细描述

MQTTClient_connectOptions defines several settings that control the way the client connects to an MQTT server.

Note: Default values are not defined for members of MQTTClient_connectOptions so it is good practice to specify all settings. If the MQTTClient_connectOptions structure is defined as an automatic variable, all members are set to random values and thus must be set by the client application. If the MQTTClient_connectOptions structure is defined as a static variable, initialization (in compliant compilers) sets all values to 0 (NULL for pointers). A keepAliveInterval setting of 0 prevents correct operation of the client and so you must at least set a value for keepAliveInterval.

在文件 MQTTClient.h806 行定义.

类成员变量说明

struct { ... } MQTTClient_connectOptions::binarypwd

Optional binary password. Only checked and used if the password option is NULL

int MQTTClient_connectOptions::cleansession

This is a boolean value. The cleansession setting controls the behaviour of both the client and the server at connection and disconnection time. The client and server both maintain session state information. This information is used to ensure "at least once" and "exactly once" delivery, and "exactly once" receipt of messages. Session state also includes subscriptions created by an MQTT client. You can choose to maintain or discard state information between sessions.

When cleansession is true, the state information is discarded at connect and disconnect. Setting cleansession to false keeps the state information. When you connect an MQTT client application with MQTTClient_connect(), the client identifies the connection using the client identifier and the address of the server. The server checks whether session information for this client has been saved from a previous connection to the server. If a previous session still exists, and cleansession=true, then the previous session information at the client and server is cleared. If cleansession=false, the previous session is resumed. If no previous session exists, a new session is started.

在文件 MQTTClient.h852 行定义.

int MQTTClient_connectOptions::cleanstart

在文件 MQTTClient.h948 行定义.

int MQTTClient_connectOptions::connectTimeout

The time interval in seconds to allow a connect to complete.

在文件 MQTTClient.h884 行定义.

const void* MQTTClient_connectOptions::data

binary password data

在文件 MQTTClient.h939 行定义.

const MQTTClient_nameValue* MQTTClient_connectOptions::httpHeaders

HTTP headers for websockets

在文件 MQTTClient.h952 行定义.

const char* MQTTClient_connectOptions::httpProxy

HTTP proxy for websockets

在文件 MQTTClient.h956 行定义.

const char* MQTTClient_connectOptions::httpsProxy

HTTPS proxy for websockets

在文件 MQTTClient.h960 行定义.

int MQTTClient_connectOptions::keepAliveInterval

The "keep alive" interval, measured in seconds, defines the maximum time that should pass without communication between the client and the server The client will ensure that at least one message travels across the network within each keep alive period. In the absence of a data-related message during the time period, the client sends a very small MQTT "ping" message, which the server will acknowledge. The keep alive interval enables the client to detect when the server is no longer available without having to wait for the long TCP/IP timeout.

在文件 MQTTClient.h830 行定义.

int MQTTClient_connectOptions::len

binary password length

在文件 MQTTClient.h938 行定义.

int MQTTClient_connectOptions::maxInflightMessages

The maximum number of messages in flight

在文件 MQTTClient.h944 行定义.

int MQTTClient_connectOptions::MQTTVersion

Sets the version of MQTT to be used on the connect. MQTTVERSION_DEFAULT (0) = default: start with 3.1.1, and if that fails, fall back to 3.1 MQTTVERSION_3_1 (3) = only try version 3.1 MQTTVERSION_3_1_1 (4) = only try version 3.1.1 MQTTVERSION_5 (5) = only try version 5.0

the MQTT version used to connect with

在文件 MQTTClient.h923 行定义.

const char* MQTTClient_connectOptions::password

MQTT servers that support the MQTT v3.1.1 protocol provide authentication and authorisation by user name and password. This is the password parameter.

在文件 MQTTClient.h880 行定义.

int MQTTClient_connectOptions::reliable

This is a boolean value that controls how many messages can be in-flight simultaneously. Setting reliable to true means that a published message must be completed (acknowledgements received) before another can be sent. Attempts to publish additional messages receive an MQTTCLIENT_MAX_MESSAGES_INFLIGHT return code. Setting this flag to false allows up to 10 messages to be in-flight. This can increase overall throughput in some circumstances.

在文件 MQTTClient.h862 行定义.

int MQTTClient_connectOptions::retryInterval

The time interval in seconds after which unacknowledged publish requests are retried during a TCP session. With MQTT 3.1.1 and later, retries are not required except on reconnect. 0 turns off in-session retries, and is the recommended setting. Adding retries to an already overloaded network only exacerbates the problem.

在文件 MQTTClient.h892 行定义.

struct { ... } MQTTClient_connectOptions::returned

Returned from the connect when the MQTT version used to connect is 3.1.1

const char* MQTTClient_connectOptions::serverURI

the serverURI connected to

在文件 MQTTClient.h929 行定义.

int MQTTClient_connectOptions::serverURIcount

The number of entries in the optional serverURIs array. Defaults to 0.

在文件 MQTTClient.h901 行定义.

char* const* MQTTClient_connectOptions::serverURIs

An optional array of null-terminated strings specifying the servers to which the client will connect. Each string takes the form protocol://host:port. protocol must be tcp, ssl, ws or wss. The TLS enabled prefixes (ssl, wss) are only valid if a TLS version of the library is linked with. For host, you can specify either an IP address or a host name. For instance, to connect to a server running on the local machines with the default MQTT port, specify tcp://localhost:1883. If this list is empty (the default), the server URI specified on MQTTClient_create() is used.

在文件 MQTTClient.h915 行定义.

int MQTTClient_connectOptions::sessionPresent

if the MQTT version is 3.1.1, the value of sessionPresent returned in the connack

在文件 MQTTClient.h931 行定义.

MQTTClient_SSLOptions* MQTTClient_connectOptions::ssl

This is a pointer to an MQTTClient_SSLOptions structure. If your application does not make use of SSL, set this pointer to NULL.

在文件 MQTTClient.h897 行定义.

char MQTTClient_connectOptions::struct_id[4]

The eyecatcher for this structure. must be MQTC.

在文件 MQTTClient.h809 行定义.

int MQTTClient_connectOptions::struct_version

The version number of this structure. Must be 0, 1, 2, 3, 4, 5, 6, 7 or 8. 0 signifies no SSL options and no serverURIs 1 signifies no serverURIs 2 signifies no MQTTVersion 3 signifies no returned values 4 signifies no binary password option 5 signifies no maxInflightMessages and cleanstart 6 signifies no HTTP headers option 7 signifies no HTTP proxy and HTTPS proxy options

在文件 MQTTClient.h820 行定义.

const char* MQTTClient_connectOptions::username

MQTT servers that support the MQTT v3.1.1 protocol provide authentication and authorisation by user name and password. This is the user name parameter.

在文件 MQTTClient.h874 行定义.

MQTTClient_willOptions* MQTTClient_connectOptions::will

This is a pointer to an MQTTClient_willOptions structure. If your application does not make use of the Last Will and Testament feature, set this pointer to NULL.

在文件 MQTTClient.h868 行定义.


该结构体的文档由以下文件生成: