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

Classes

struct  CC_Mqtt5ConnectBasicConfig
 Configuration structure to be passed to the cc_mqtt5_client_connect_config_basic(). More...
 
struct  CC_Mqtt5ConnectExtraConfig
 Extra properties configuration of the "connect" operation. More...
 
struct  CC_Mqtt5ConnectResponse
 Response information from broker to "connect" request. More...
 
struct  CC_Mqtt5ConnectWillConfig
 Configuration structure to be passed to the cc_mqtt5_client_connect_config_will(). More...
 

Typedefs

typedef void(* CC_Mqtt5ConnectCompleteCb) (void *data, CC_Mqtt5AsyncOpStatus status, const CC_Mqtt5ConnectResponse *response)
 Callback used to report completion of the "connect" operation. More...
 
typedef struct CC_Mqtt5Connect * CC_Mqtt5ConnectHandle
 Handle for "connect" operation. More...
 

Functions

CC_Mqtt5ErrorCode cc_mqtt5_client_connect_add_user_prop (CC_Mqtt5ConnectHandle handle, const CC_Mqtt5UserProp *prop)
 Add user property to the configuration of the "connect" operation. More...
 
CC_Mqtt5ErrorCode cc_mqtt5_client_connect_add_will_user_prop (CC_Mqtt5ConnectHandle handle, const CC_Mqtt5UserProp *prop)
 Add user property to the will configuration of the "connect" operation. More...
 
CC_Mqtt5ErrorCode cc_mqtt5_client_connect_cancel (CC_Mqtt5ConnectHandle handle)
 Cancel the allocated "connect" operation. More...
 
CC_Mqtt5ErrorCode cc_mqtt5_client_connect_config_auth (CC_Mqtt5ConnectHandle handle, const CC_Mqtt5AuthConfig *config)
 Perform authentication handshake configuration of the "connect" operation. More...
 
CC_Mqtt5ErrorCode cc_mqtt5_client_connect_config_basic (CC_Mqtt5ConnectHandle handle, const CC_Mqtt5ConnectBasicConfig *config)
 Perform basic configuration of the "connect" operation. More...
 
CC_Mqtt5ErrorCode cc_mqtt5_client_connect_config_extra (CC_Mqtt5ConnectHandle handle, const CC_Mqtt5ConnectExtraConfig *config)
 Perform extra properties configuration of the "connect" operation. More...
 
CC_Mqtt5ErrorCode cc_mqtt5_client_connect_config_will (CC_Mqtt5ConnectHandle handle, const CC_Mqtt5ConnectWillConfig *config)
 Perform will configuration of the "connect" operation. More...
 
CC_Mqtt5ErrorCode cc_mqtt5_client_connect_full (CC_Mqtt5ClientHandle handle, const CC_Mqtt5ConnectBasicConfig *basicConfig, const CC_Mqtt5ConnectWillConfig *willConfig, const CC_Mqtt5ConnectExtraConfig *extraConfig, const CC_Mqtt5AuthConfig *authConfig, CC_Mqtt5ConnectCompleteCb cb, void *cbData)
 Prepare, configure, and send "connect" request in one go (full version) More...
 
unsigned cc_mqtt5_client_connect_get_response_timeout (CC_Mqtt5ConnectHandle handle)
 Retrieve the configured the broker response timeout for the "connect" operation. More...
 
void cc_mqtt5_client_connect_init_auth_info (CC_Mqtt5AuthInfo *info)
 Intialize the CC_Mqtt5AuthInfo configuration structure. More...
 
void cc_mqtt5_client_connect_init_config_auth (CC_Mqtt5AuthConfig *config)
 Intialize the CC_Mqtt5AuthConfig configuration structure. More...
 
void cc_mqtt5_client_connect_init_config_basic (CC_Mqtt5ConnectBasicConfig *config)
 Intialize the CC_Mqtt5ConnectBasicConfig configuration structure. More...
 
void cc_mqtt5_client_connect_init_config_extra (CC_Mqtt5ConnectExtraConfig *config)
 Intialize the CC_Mqtt5ConnectExtraConfig configuration structure. More...
 
void cc_mqtt5_client_connect_init_config_will (CC_Mqtt5ConnectWillConfig *config)
 Intialize the CC_Mqtt5ConnectWillConfig configuration structure. More...
 
CC_Mqtt5ConnectHandle cc_mqtt5_client_connect_prepare (CC_Mqtt5ClientHandle handle, CC_Mqtt5ErrorCode *ec)
 Prepare "connect" operation. More...
 
CC_Mqtt5ErrorCode cc_mqtt5_client_connect_send (CC_Mqtt5ConnectHandle handle, CC_Mqtt5ConnectCompleteCb cb, void *cbData)
 Send the configured "connect" operation to broker. More...
 
CC_Mqtt5ErrorCode cc_mqtt5_client_connect_set_response_timeout (CC_Mqtt5ConnectHandle handle, unsigned ms)
 Configure the broker response timeout for the "connect" operation. More...
 
CC_Mqtt5ErrorCode cc_mqtt5_client_connect_simple (CC_Mqtt5ClientHandle handle, const CC_Mqtt5ConnectBasicConfig *basicConfig, CC_Mqtt5ConnectCompleteCb cb, void *cbData)
 Prepare, configure, and send "connect" request in one go (simple version) More...
 
bool cc_mqtt5_client_is_connected (CC_Mqtt5ClientHandle handle)
 Check the inner state of the library of whether it's connected to the broker. More...
 

Detailed Description

Typedef Documentation

◆ CC_Mqtt5ConnectCompleteCb

typedef void(* CC_Mqtt5ConnectCompleteCb) (void *data, CC_Mqtt5AsyncOpStatus status, const CC_Mqtt5ConnectResponse *response)

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

Parameters
[in]dataPointer to user data object passed as last parameter to the cc_mqtt5_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_Mqtt5AsyncOpStatus_Complete.
Postcondition
The data members of the reported response can NOT be accessed after the function returns.

◆ CC_Mqtt5ConnectHandle

typedef struct CC_Mqtt5Connect* CC_Mqtt5ConnectHandle

Handle for "connect" operation.

Returned by cc_mqtt5_client_connect_prepare() function.

Function Documentation

◆ cc_mqtt5_client_connect_add_user_prop()

CC_Mqtt5ErrorCode cc_mqtt5_client_connect_add_user_prop ( CC_Mqtt5ConnectHandle  handle,
const CC_Mqtt5UserProp prop 
)

Add user property to the configuration of the "connect" operation.

Parameters
[in]handleHandle returned by cc_mqtt5_client_connect_prepare() function.
[in]propSingle user property info. Must NOT be NULL. Does not need to be preserved after invocation.
Returns
Result code of the call.

◆ cc_mqtt5_client_connect_add_will_user_prop()

CC_Mqtt5ErrorCode cc_mqtt5_client_connect_add_will_user_prop ( CC_Mqtt5ConnectHandle  handle,
const CC_Mqtt5UserProp prop 
)

Add user property to the will configuration of the "connect" operation.

Parameters
[in]handleHandle returned by cc_mqtt5_client_connect_prepare() function.
[in]propSingle user property info. Must NOT be NULL. Does not need to be preserved after invocation.
Returns
Result code of the call.
Precondition
The will has been previously configured using the cc_mqtt5_client_connect_config_will().

◆ cc_mqtt5_client_connect_cancel()

CC_Mqtt5ErrorCode cc_mqtt5_client_connect_cancel ( CC_Mqtt5ConnectHandle  handle)

Cancel the allocated "connect" operation.

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

Parameters
[in]handleHandle returned by cc_mqtt5_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_mqtt5_client_connect_config_auth()

CC_Mqtt5ErrorCode cc_mqtt5_client_connect_config_auth ( CC_Mqtt5ConnectHandle  handle,
const CC_Mqtt5AuthConfig config 
)

Perform authentication handshake configuration of the "connect" operation.

Parameters
[in]handleHandle returned by cc_mqtt5_client_connect_prepare() function.
[in]configAuthentication configuration structure. Must NOT be NULL. Does not need to be preserved after invocation.
Returns
Result code of the call.
Precondition
Mustn't be called more than once for a single "connect" operation.
Postcondition
Some of the properties can get assigned regardless of the return value.

◆ cc_mqtt5_client_connect_config_basic()

CC_Mqtt5ErrorCode cc_mqtt5_client_connect_config_basic ( CC_Mqtt5ConnectHandle  handle,
const CC_Mqtt5ConnectBasicConfig config 
)

Perform basic configuration of the "connect" operation.

Parameters
[in]handleHandle returned by cc_mqtt5_client_connect_prepare() function.
[in]configBasic configuration structure. Must NOT be NULL. Does not need to be preserved after invocation.
Returns
Result code of the call.
Postcondition
Some of the properties can get assigned regardless of the return value.

◆ cc_mqtt5_client_connect_config_extra()

CC_Mqtt5ErrorCode cc_mqtt5_client_connect_config_extra ( CC_Mqtt5ConnectHandle  handle,
const CC_Mqtt5ConnectExtraConfig config 
)

Perform extra properties configuration of the "connect" operation.

Parameters
[in]handleHandle returned by cc_mqtt5_client_connect_prepare() function.
[in]configExtra properties configuration structure. Must NOT be NULL. Does not need to be preserved after invocation.
Returns
Result code of the call.
Precondition
Mustn't be called more than once for a single "connect" operation.
Postcondition
Some of the properties can get assigned regardless of the return value.

◆ cc_mqtt5_client_connect_config_will()

CC_Mqtt5ErrorCode cc_mqtt5_client_connect_config_will ( CC_Mqtt5ConnectHandle  handle,
const CC_Mqtt5ConnectWillConfig config 
)

Perform will configuration of the "connect" operation.

Parameters
[in]handleHandle returned by cc_mqtt5_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.
Precondition
Mustn't be called more than once for a single "connect" operation.
Postcondition
Some of the properties can get assigned regardless of the return value.

◆ cc_mqtt5_client_connect_full()

CC_Mqtt5ErrorCode cc_mqtt5_client_connect_full ( CC_Mqtt5ClientHandle  handle,
const CC_Mqtt5ConnectBasicConfig basicConfig,
const CC_Mqtt5ConnectWillConfig willConfig,
const CC_Mqtt5ConnectExtraConfig extraConfig,
const CC_Mqtt5AuthConfig authConfig,
CC_Mqtt5ConnectCompleteCb  cb,
void *  cbData 
)

Prepare, configure, and send "connect" request in one go (full version)

Abstracts away sequence of the following functions invocation:

Parameters
[in]handleHandle returned by cc_mqtt5_client_alloc() function.
[in]basicConfigBasic configuration. Can be NULL.
[in]willConfigWill configuration. Can be NULL.
[in]extraConfigExtra configuration. Can be NULL.
[in]authConfigAuth 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_mqtt5_client_connect_get_response_timeout()

unsigned cc_mqtt5_client_connect_get_response_timeout ( CC_Mqtt5ConnectHandle  handle)

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

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

◆ cc_mqtt5_client_connect_init_auth_info()

void cc_mqtt5_client_connect_init_auth_info ( CC_Mqtt5AuthInfo info)

Intialize the CC_Mqtt5AuthInfo configuration structure.

Parameters
[out]infoAuthentication information structure. Must not be NULL.

◆ cc_mqtt5_client_connect_init_config_auth()

void cc_mqtt5_client_connect_init_config_auth ( CC_Mqtt5AuthConfig config)

Intialize the CC_Mqtt5AuthConfig configuration structure.

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

◆ cc_mqtt5_client_connect_init_config_basic()

void cc_mqtt5_client_connect_init_config_basic ( CC_Mqtt5ConnectBasicConfig config)

Intialize the CC_Mqtt5ConnectBasicConfig configuration structure.

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

◆ cc_mqtt5_client_connect_init_config_extra()

void cc_mqtt5_client_connect_init_config_extra ( CC_Mqtt5ConnectExtraConfig config)

Intialize the CC_Mqtt5ConnectExtraConfig configuration structure.

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

◆ cc_mqtt5_client_connect_init_config_will()

void cc_mqtt5_client_connect_init_config_will ( CC_Mqtt5ConnectWillConfig config)

Intialize the CC_Mqtt5ConnectWillConfig configuration structure.

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

◆ cc_mqtt5_client_connect_prepare()

CC_Mqtt5ConnectHandle cc_mqtt5_client_connect_prepare ( CC_Mqtt5ClientHandle  handle,
CC_Mqtt5ErrorCode 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_mqtt5_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_mqtt5_client_is_network_disconnected() to notify about the network disconnection.
The "connect" operation is allocated, use either cc_mqtt5_client_connect_send() or cc_mqtt5_client_connect_cancel() to prevent memory leaks.

◆ cc_mqtt5_client_connect_send()

CC_Mqtt5ErrorCode cc_mqtt5_client_connect_send ( CC_Mqtt5ConnectHandle  handle,
CC_Mqtt5ConnectCompleteCb  cb,
void *  cbData 
)

Send the configured "connect" operation to broker.

Parameters
[in]handleHandle returned by cc_mqtt5_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_Mqtt5ErrorCode_Success.

◆ cc_mqtt5_client_connect_set_response_timeout()

CC_Mqtt5ErrorCode cc_mqtt5_client_connect_set_response_timeout ( CC_Mqtt5ConnectHandle  handle,
unsigned  ms 
)

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

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

◆ cc_mqtt5_client_connect_simple()

CC_Mqtt5ErrorCode cc_mqtt5_client_connect_simple ( CC_Mqtt5ClientHandle  handle,
const CC_Mqtt5ConnectBasicConfig basicConfig,
CC_Mqtt5ConnectCompleteCb  cb,
void *  cbData 
)

Prepare, configure, and send "connect" request in one go (simple version)

Abstracts away sequence of the following functions invocation:

Parameters
[in]handleHandle returned by cc_mqtt5_client_alloc() function.
[in]basicConfigBasic 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_mqtt5_client_is_connected()

bool cc_mqtt5_client_is_connected ( CC_Mqtt5ClientHandle  handle)

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

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