CommsChampion Ecosystem MQTT v3.1.1 Client
MQTT v3.1.1 Client Library.
Classes | Typedefs | Enumerations | Functions
"Connect Operation Data Type and Functions"

Classes

struct  CC_Mqtt311ConnectConfig
 Configuration structure to be passed to the cc_mqtt311_client_connect_config(). More...
 
struct  CC_Mqtt311ConnectResponse
 Response information from broker to "connect" request. More...
 
struct  CC_Mqtt311ConnectWillConfig
 Configuration structure to be passed to the cc_mqtt311_client_connect_config_will(). More...
 

Typedefs

typedef void(* CC_Mqtt311ConnectCompleteCb) (void *data, CC_Mqtt311AsyncOpStatus status, const CC_Mqtt311ConnectResponse *response)
 Callback used to report completion of the "connect" operation. More...
 
typedef struct CC_Mqtt311Connect * CC_Mqtt311ConnectHandle
 Handle for "connect" operation. More...
 

Enumerations

enum  CC_Mqtt311ConnectReturnCode {
  CC_Mqtt311ConnectReturnCode_Accepted = 0 , CC_Mqtt311ConnectReturnCode_InvalidProtocolVersion = 1 , CC_Mqtt311ConnectReturnCode_IdRejected = 2 , CC_Mqtt311ConnectReturnCode_ServerUnavailable = 3 ,
  CC_Mqtt311ConnectReturnCode_BadAuth = 4 , CC_Mqtt311ConnectReturnCode_NotAuthorized = 5 , CC_Mqtt311ConnectReturnCode_ValuesLimit
}
 "Connect Return Code" as defined in MQTT v3.1.1 specification More...
 

Functions

CC_Mqtt311ErrorCode cc_mqtt311_client_connect (CC_Mqtt311ClientHandle handle, const CC_Mqtt311ConnectConfig *config, const CC_Mqtt311ConnectWillConfig *willConfig, CC_Mqtt311ConnectCompleteCb cb, void *cbData)
 Prepare, configure, and send "connect" request in one go. More...
 
CC_Mqtt311ErrorCode cc_mqtt311_client_connect_cancel (CC_Mqtt311ConnectHandle handle)
 Cancel the allocated "connect" operation. More...
 
CC_Mqtt311ErrorCode cc_mqtt311_client_connect_config (CC_Mqtt311ConnectHandle handle, const CC_Mqtt311ConnectConfig *config)
 Perform basic configuration of the "connect" operation. More...
 
CC_Mqtt311ErrorCode cc_mqtt311_client_connect_config_will (CC_Mqtt311ConnectHandle handle, const CC_Mqtt311ConnectWillConfig *config)
 Perform will configuration of the "connect" operation. More...
 
unsigned cc_mqtt311_client_connect_get_response_timeout (CC_Mqtt311ConnectHandle handle)
 Retrieve the configured the broker response timeout for the "connect" operation. More...
 
void cc_mqtt311_client_connect_init_config (CC_Mqtt311ConnectConfig *config)
 Intialize the CC_Mqtt311ConnectConfig configuration structure. More...
 
void cc_mqtt311_client_connect_init_config_will (CC_Mqtt311ConnectWillConfig *config)
 Intialize the CC_Mqtt311ConnectWillConfig configuration structure. More...
 
CC_Mqtt311ConnectHandle cc_mqtt311_client_connect_prepare (CC_Mqtt311ClientHandle handle, CC_Mqtt311ErrorCode *ec)
 Prepare "connect" operation. More...
 
CC_Mqtt311ErrorCode cc_mqtt311_client_connect_send (CC_Mqtt311ConnectHandle handle, CC_Mqtt311ConnectCompleteCb cb, void *cbData)
 Send the configured "connect" operation to broker. More...
 
CC_Mqtt311ErrorCode cc_mqtt311_client_connect_set_response_timeout (CC_Mqtt311ConnectHandle handle, unsigned ms)
 Configure the broker response timeout for the "connect" operation. More...
 
bool cc_mqtt311_client_is_connected (CC_Mqtt311ClientHandle handle)
 Check the inner state of the library of whether it's connected to the broker. More...
 

Detailed Description

Typedef Documentation

◆ CC_Mqtt311ConnectCompleteCb

typedef void(* CC_Mqtt311ConnectCompleteCb) (void *data, CC_Mqtt311AsyncOpStatus status, const CC_Mqtt311ConnectResponse *response)

Callback used to report completion of the "connect" operation.

Parameters
[in]dataPointer to user data object passed as last parameter to the cc_mqtt311_client_connect_send().
[in]statusStatus of the "connect" operation.
[in]responseResponse information from the broker. Not-NULL is reported if and onfly if the "status" is equal to CC_Mqtt311AsyncOpStatus_Complete.
Postcondition
The data members of the reported response can NOT be accessed after the function returns.

◆ CC_Mqtt311ConnectHandle

typedef struct CC_Mqtt311Connect* CC_Mqtt311ConnectHandle

Handle for "connect" operation.

Returned by cc_mqtt311_client_connect_prepare() function.

Enumeration Type Documentation

◆ CC_Mqtt311ConnectReturnCode

"Connect Return Code" as defined in MQTT v3.1.1 specification

Enumerator
CC_Mqtt311ConnectReturnCode_Accepted 

value Connection Accepted.

CC_Mqtt311ConnectReturnCode_InvalidProtocolVersion 

value Invalid Protocol Version.

CC_Mqtt311ConnectReturnCode_IdRejected 

value Client ID is rejected.

CC_Mqtt311ConnectReturnCode_ServerUnavailable 

value Server is Unavailable.

CC_Mqtt311ConnectReturnCode_BadAuth 

value Bad authentication details.

CC_Mqtt311ConnectReturnCode_NotAuthorized 

value No Subscription Existed.

CC_Mqtt311ConnectReturnCode_ValuesLimit 

Upper limit of the values.

Function Documentation

◆ cc_mqtt311_client_connect()

CC_Mqtt311ErrorCode cc_mqtt311_client_connect ( CC_Mqtt311ClientHandle  handle,
const CC_Mqtt311ConnectConfig config,
const CC_Mqtt311ConnectWillConfig willConfig,
CC_Mqtt311ConnectCompleteCb  cb,
void *  cbData 
)

Prepare, configure, and send "connect" request in one go.

Abstracts away sequence of the following functions invocation:

Parameters
[in]handleHandle returned by cc_mqtt311_client_alloc() function.
[in]configConnection configuration. Can be NULL.
[in]willConfigWill configuration. Can be NULL.
[in]cbCallback to be invoked when "connect" operation is complete.
[in]cbDataPointer to any user data structure. It will passed as one of the parameters in callback invocation. May be NULL.
Returns
Result code of the call.

◆ cc_mqtt311_client_connect_cancel()

CC_Mqtt311ErrorCode cc_mqtt311_client_connect_cancel ( CC_Mqtt311ConnectHandle  handle)

Cancel the allocated "connect" operation.

In case the cc_mqtt311_client_connect_send() function was successfully called before, the operation is cancelled without callback invocation.

Parameters
[in]handleHandle returned by cc_mqtt311_client_connect_prepare() function.
Returns
Result code of the call.
Postcondition
The handle of the "connect" operation is no longer valid and must be discarded.

◆ cc_mqtt311_client_connect_config()

CC_Mqtt311ErrorCode cc_mqtt311_client_connect_config ( CC_Mqtt311ConnectHandle  handle,
const CC_Mqtt311ConnectConfig config 
)

Perform basic configuration of the "connect" operation.

Parameters
[in]handleHandle returned by cc_mqtt311_client_connect_prepare() function.
[in]configConfiguration structure. Must NOT be NULL. Does not need to be preserved after invocation.
Returns
Result code of the call.

◆ cc_mqtt311_client_connect_config_will()

CC_Mqtt311ErrorCode cc_mqtt311_client_connect_config_will ( CC_Mqtt311ConnectHandle  handle,
const CC_Mqtt311ConnectWillConfig config 
)

Perform will configuration of the "connect" operation.

Parameters
[in]handleHandle returned by cc_mqtt311_client_connect_prepare() function.
[in]configWill configuration structure. Must NOT be NULL. Does not need to be preserved after invocation.
Returns
Result code of the call.

◆ cc_mqtt311_client_connect_get_response_timeout()

unsigned cc_mqtt311_client_connect_get_response_timeout ( CC_Mqtt311ConnectHandle  handle)

Retrieve the configured the broker response timeout for the "connect" operation.

Parameters
[in]handleHandle returned by cc_mqtt311_client_connect_prepare() function.
Returns
Response timeout duration in milliseconds.

◆ cc_mqtt311_client_connect_init_config()

void cc_mqtt311_client_connect_init_config ( CC_Mqtt311ConnectConfig config)

Intialize the CC_Mqtt311ConnectConfig configuration structure.

Parameters
[out]configConfiguration structure. Must not be NULL.

◆ cc_mqtt311_client_connect_init_config_will()

void cc_mqtt311_client_connect_init_config_will ( CC_Mqtt311ConnectWillConfig config)

Intialize the CC_Mqtt311ConnectWillConfig configuration structure.

Parameters
[out]configConfiguration structure. Must not be NULL.

◆ cc_mqtt311_client_connect_prepare()

CC_Mqtt311ConnectHandle cc_mqtt311_client_connect_prepare ( CC_Mqtt311ClientHandle  handle,
CC_Mqtt311ErrorCode ec 
)

Prepare "connect" operation.

For successful operation the client needs to be in the "disconnected" state and there are no other incomplete "connect" operation

Parameters
[in]handleHandle returned by cc_mqtt311_client_alloc() function.
[out]ecError code reporting result of the operation. Can be NULL.
Returns
Handle of the "connect" operation, will be NULL in case of failure. To analyze the reason failure use "ec" output parameter.
Precondition
The function can NOT be called from within a callback, use next event iteration.
Postcondition
The network assumed to be in the "connected" state, use cc_mqtt311_client_is_network_disconnected() to notify about the network disconnection.
The "connect" operation is allocated, use either cc_mqtt311_client_connect_send() or cc_mqtt311_client_connect_cancel() to prevent memory leaks.

◆ cc_mqtt311_client_connect_send()

CC_Mqtt311ErrorCode cc_mqtt311_client_connect_send ( CC_Mqtt311ConnectHandle  handle,
CC_Mqtt311ConnectCompleteCb  cb,
void *  cbData 
)

Send the configured "connect" operation to broker.

Parameters
[in]handleHandle returned by cc_mqtt311_client_connect_prepare() function.
[in]cbCallback to be invoked when "connect" operation is complete.
[in]cbDataPointer to any user data structure. It will passed as one of the parameters in callback invocation. May be NULL.
Returns
Result code of the call.
Postcondition
The handle of the "connect" operation can be discarded.
The provided callback will be invoked when the "connect" operation is complete if and only if the function returns CC_Mqtt311ErrorCode_Success.

◆ cc_mqtt311_client_connect_set_response_timeout()

CC_Mqtt311ErrorCode cc_mqtt311_client_connect_set_response_timeout ( CC_Mqtt311ConnectHandle  handle,
unsigned  ms 
)

Configure the broker response timeout for the "connect" operation.

Parameters
[in]handleHandle returned by cc_mqtt311_client_connect_prepare() function.
[in]msResponse timeout duration in milliseconds.
Returns
Result code of the call.

◆ cc_mqtt311_client_is_connected()

bool cc_mqtt311_client_is_connected ( CC_Mqtt311ClientHandle  handle)

Check the inner state of the library of whether it's connected to the broker.

Parameters
[in]handleHandle returned by cc_mqtt311_client_alloc() function.