CommsChampion Ecosystem MQTT v3.1.1 Client
MQTT v3.1.1 Client Library.
Typedefs | Functions
"Client Data Types and Functions"

Typedefs

typedef void(* CC_Mqtt311BrokerDisconnectReportCb) (void *data, CC_Mqtt311BrokerDisconnectReason reason)
 Callback used to report unsolicited disconnection of the broker. More...
 
typedef unsigned(* CC_Mqtt311CancelNextTickWaitCb) (void *data)
 Callback used to request termination of existing time measurement. More...
 
typedef struct CC_Mqtt311Client * CC_Mqtt311ClientHandle
 Handle used to access client specific data structures. More...
 
typedef void(* CC_Mqtt311ErrorLogCb) (void *data, const char *msg)
 Callback used to report discovered errors. More...
 
typedef void(* CC_Mqtt311MessageReceivedReportCb) (void *data, const CC_Mqtt311MessageInfo *info)
 Callback used to report new message received of the broker. More...
 
typedef void(* CC_Mqtt311NextTickProgramCb) (void *data, unsigned duration)
 Callback used to request time measurement. More...
 
typedef void(* CC_Mqtt311SendOutputDataCb) (void *data, const unsigned char *buf, unsigned bufLen)
 Callback used to request to send data to the broker. More...
 

Functions

CC_Mqtt311ClientHandle cc_mqtt311_client_alloc ()
 Allocate new client. More...
 
void cc_mqtt311_client_free (CC_Mqtt311ClientHandle handle)
 Free previously allocated client. More...
 
unsigned cc_mqtt311_client_get_default_response_timeout (CC_Mqtt311ClientHandle handle)
 Retrieved currently configured default response timeout period. More...
 
bool cc_mqtt311_client_get_verify_incoming_msg_subscribed (CC_Mqtt311ClientHandle handle)
 Retrieve current incoming message being correctly subscribed control. More...
 
bool cc_mqtt311_client_get_verify_incoming_topic_enabled (CC_Mqtt311ClientHandle handle)
 Retrieve current incoming topic format verification control. More...
 
bool cc_mqtt311_client_get_verify_outgoing_topic_enabled (CC_Mqtt311ClientHandle handle)
 Retrieve current outgoing topic format verification control. More...
 
bool cc_mqtt311_client_is_network_disconnected (CC_Mqtt311ClientHandle handle)
 Check current network disconnected status. More...
 
void cc_mqtt311_client_notify_network_disconnected (CC_Mqtt311ClientHandle handle)
 Report network disconnected. More...
 
unsigned cc_mqtt311_client_process_data (CC_Mqtt311ClientHandle handle, const unsigned char *buf, unsigned bufLen)
 Provide data (received over I/O link), to the library for processing. More...
 
CC_Mqtt311ErrorCode cc_mqtt311_client_set_default_response_timeout (CC_Mqtt311ClientHandle handle, unsigned ms)
 Configure default response timeout period. More...
 
CC_Mqtt311ErrorCode cc_mqtt311_client_set_verify_incoming_msg_subscribed (CC_Mqtt311ClientHandle handle, bool enabled)
 Control verification of the incoming message being correctly subscribed. More...
 
CC_Mqtt311ErrorCode cc_mqtt311_client_set_verify_incoming_topic_enabled (CC_Mqtt311ClientHandle handle, bool enabled)
 Control incoming topic format verification. More...
 
CC_Mqtt311ErrorCode cc_mqtt311_client_set_verify_outgoing_topic_enabled (CC_Mqtt311ClientHandle handle, bool enabled)
 Control outgoing topic format verification. More...
 
void cc_mqtt311_client_tick (CC_Mqtt311ClientHandle handle, unsigned ms)
 Notify client about requested time expiry. More...
 

Detailed Description

Typedef Documentation

◆ CC_Mqtt311BrokerDisconnectReportCb

typedef void(* CC_Mqtt311BrokerDisconnectReportCb) (void *data, CC_Mqtt311BrokerDisconnectReason reason)

Callback used to report unsolicited disconnection of the broker.

Parameters
[in]dataPointer to user data object, passed as the last parameter to the request call.
[in]reasonReson for reporting unsolicited broker disconnection.

◆ CC_Mqtt311CancelNextTickWaitCb

typedef unsigned(* CC_Mqtt311CancelNextTickWaitCb) (void *data)

Callback used to request termination of existing time measurement.

The callback is set using cc_mqtt311_client_set_cancel_next_tick_wait_callback() function.

Parameters
[in]dataPointer to user data object, passed as last parameter to cc_mqtt311_client_set_cancel_next_tick_wait_callback() function.
Returns
Number of elapsed milliseconds since last time measurement request.

◆ CC_Mqtt311ClientHandle

typedef struct CC_Mqtt311Client* CC_Mqtt311ClientHandle

Handle used to access client specific data structures.

Returned by cc_mqtt311_client_alloc() function.

◆ CC_Mqtt311ErrorLogCb

typedef void(* CC_Mqtt311ErrorLogCb) (void *data, const char *msg)

Callback used to report discovered errors.

Parameters
[in]dataPointer to user data object, passed as the last parameter to the request call.
[in]msgError log message.

◆ CC_Mqtt311MessageReceivedReportCb

typedef void(* CC_Mqtt311MessageReceivedReportCb) (void *data, const CC_Mqtt311MessageInfo *info)

Callback used to report new message received of the broker.

Parameters
[in]dataPointer to user data object, passed as the last parameter to the request call.
[in]infoMessage information. Will NOT be NULL.
Postcondition
The data members of the reported info can NOT be accessed after the function returns.

◆ CC_Mqtt311NextTickProgramCb

typedef void(* CC_Mqtt311NextTickProgramCb) (void *data, unsigned duration)

Callback used to request time measurement.

The callback is set using cc_mqtt311_client_set_next_tick_program_callback() function.

Parameters
[in]dataPointer to user data object, passed as last parameter to cc_mqtt311_client_set_next_tick_program_callback() function.
[in]durationTime duration in milliseconds. After the requested time expires, the cc_mqtt311_client_tick() function is expected to be invoked.

◆ CC_Mqtt311SendOutputDataCb

typedef void(* CC_Mqtt311SendOutputDataCb) (void *data, const unsigned char *buf, unsigned bufLen)

Callback used to request to send data to the broker.

The callback is set using cc_mqtt311_client_set_send_output_data_callback() function. The reported data resides in internal data structures of the client library, which can be updated / deleted right after the callback function returns. It means the data may need to be copied into some other buffer which will be held intact until the send over I/O link operation is complete.

Parameters
[in]dataPointer to user data object, passed as last parameter to cc_mqtt311_client_set_send_output_data_callback() function.
[in]bufPointer to the buffer containing data to send
[in]bufLenNumber of bytes in the buffer
Postcondition
The buffer data can be deallocated / overwritten after the callback function returns.

Function Documentation

◆ cc_mqtt311_client_alloc()

CC_Mqtt311ClientHandle cc_mqtt311_client_alloc ( )

Allocate new client.

When work with the client is complete, cc_mqtt311_client_free() function must be invoked.

Returns
Handle to allocated client object. This handle needs to be passed as first parameter to all other API functions.

◆ cc_mqtt311_client_free()

void cc_mqtt311_client_free ( CC_Mqtt311ClientHandle  handle)

Free previously allocated client.

The callbacks of the incomplete operations will be invoked with CC_Mqtt311AsyncOpStatus_Aborted status.

Parameters
[in]handleHandle returned by cc_mqtt311_client_alloc() function.
Precondition
Mustn't be called from within a callback, use next event loop iteration.
Postcondition
The client handler becomes invalid and cannot be used any longer.

◆ cc_mqtt311_client_get_default_response_timeout()

unsigned cc_mqtt311_client_get_default_response_timeout ( CC_Mqtt311ClientHandle  handle)

Retrieved currently configured default response timeout period.

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

◆ cc_mqtt311_client_get_verify_incoming_msg_subscribed()

bool cc_mqtt311_client_get_verify_incoming_msg_subscribed ( CC_Mqtt311ClientHandle  handle)

Retrieve current incoming message being correctly subscribed control.

Parameters
[in]handleHandle returned by cc_mqtt311_client_alloc() function.
Returns
true when enabled, false when disabled

◆ cc_mqtt311_client_get_verify_incoming_topic_enabled()

bool cc_mqtt311_client_get_verify_incoming_topic_enabled ( CC_Mqtt311ClientHandle  handle)

Retrieve current incoming topic format verification control.

Parameters
[in]handleHandle returned by cc_mqtt311_client_alloc() function.
Returns
true when enabled, false when disabled

◆ cc_mqtt311_client_get_verify_outgoing_topic_enabled()

bool cc_mqtt311_client_get_verify_outgoing_topic_enabled ( CC_Mqtt311ClientHandle  handle)

Retrieve current outgoing topic format verification control.

Parameters
[in]handleHandle returned by cc_mqtt311_client_alloc() function.
Returns
true when enabled, false when disabled

◆ cc_mqtt311_client_is_network_disconnected()

bool cc_mqtt311_client_is_network_disconnected ( CC_Mqtt311ClientHandle  handle)

Check current network disconnected status.

Parameters
[in]handleHandle returned by cc_mqtt311_client_alloc() function.
Returns
true when disconnected, false when0 connected.
Note
After invocation of the cc_mqtt311_client_alloc(), this function will return false, i.e. after client allocation network is assumend connected.

◆ cc_mqtt311_client_notify_network_disconnected()

void cc_mqtt311_client_notify_network_disconnected ( CC_Mqtt311ClientHandle  handle)

Report network disconnected.

To notify the client that the network is connected again use cc_mqtt311_client_connect_prepare()

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

◆ cc_mqtt311_client_process_data()

unsigned cc_mqtt311_client_process_data ( CC_Mqtt311ClientHandle  handle,
const unsigned char *  buf,
unsigned  bufLen 
)

Provide data (received over I/O link), to the library for processing.

This call may cause invocation of some callbacks, such as request to cancel the currently running time measurement, send some messages to the broker, report incoming application message, and (re)start time measurement.

Parameters
[in]handleHandle returned by cc_mqtt311_client_alloc() function.
[in]bufPointer to the buffer of data to process.
[in]bufLenNumber of bytes in the data buffer.
Returns
Number of processed bytes.
Note
The function returns number of bytes that were actually consumed, and can be removed from the holding buffer.

◆ cc_mqtt311_client_set_default_response_timeout()

CC_Mqtt311ErrorCode cc_mqtt311_client_set_default_response_timeout ( CC_Mqtt311ClientHandle  handle,
unsigned  ms 
)

Configure default response timeout period.

Parameters
[in]handleHandle returned by cc_mqtt311_client_alloc() function.
[in]msResponse timeout duration in milliseconds.
Returns
Error code of the operation

◆ cc_mqtt311_client_set_verify_incoming_msg_subscribed()

CC_Mqtt311ErrorCode cc_mqtt311_client_set_verify_incoming_msg_subscribed ( CC_Mqtt311ClientHandle  handle,
bool  enabled 
)

Control verification of the incoming message being correctly subscribed.

Parameters
[in]handleHandle returned by cc_mqtt311_client_alloc() function.
[in]enabledtrue to enable topic format verification, false to disable.
Returns
Error code of the operation

◆ cc_mqtt311_client_set_verify_incoming_topic_enabled()

CC_Mqtt311ErrorCode cc_mqtt311_client_set_verify_incoming_topic_enabled ( CC_Mqtt311ClientHandle  handle,
bool  enabled 
)

Control incoming topic format verification.

Parameters
[in]handleHandle returned by cc_mqtt311_client_alloc() function.
[in]enabledtrue to enable topic format verification, false to disable.
Returns
Error code of the operation

◆ cc_mqtt311_client_set_verify_outgoing_topic_enabled()

CC_Mqtt311ErrorCode cc_mqtt311_client_set_verify_outgoing_topic_enabled ( CC_Mqtt311ClientHandle  handle,
bool  enabled 
)

Control outgoing topic format verification.

Parameters
[in]handleHandle returned by cc_mqtt311_client_alloc() function.
[in]enabledtrue to enable topic format verification, false to disable.
Returns
Error code of the operation

◆ cc_mqtt311_client_tick()

void cc_mqtt311_client_tick ( CC_Mqtt311ClientHandle  handle,
unsigned  ms 
)

Notify client about requested time expiry.

The reported amount of milliseconds needs to be from the last request to program timer via callback (set by cc_mqtt311_client_set_next_tick_program_callback()). It can be less than actually requested via the callback. If this function is called, the library assumes that previously requested timeout measurement is not in progress any more, and will request new measurement if needed. This call may cause invocation of some other callbacks, such as a request to send new data to the broker.

Parameters
[in]handleHandle returned by cc_mqtt311_client_alloc() function.
[in]msNumber of elapsed milliseconds.