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

Classes

struct  CC_Mqtt311PublishConfig
 Configuration structure to be passed to the cc_mqtt311_client_publish_config(). More...
 

Typedefs

typedef void(* CC_Mqtt311PublishCompleteCb) (void *data, CC_Mqtt311PublishHandle handle, CC_Mqtt311AsyncOpStatus status)
 Callback used to report completion of the "publish" operation. More...
 
typedef struct CC_Mqtt311Publish * CC_Mqtt311PublishHandle
 Handle for "publish" operation. More...
 

Enumerations

enum  CC_Mqtt311PublishOrdering { CC_Mqtt311PublishOrdering_SameQos , CC_Mqtt311PublishOrdering_Full , CC_Mqtt311PublishOrdering_ValuesLimit }
 Publish ordering configuration. More...
 

Functions

CC_Mqtt311ErrorCode cc_mqtt311_client_publish (CC_Mqtt311ClientHandle handle, const CC_Mqtt311PublishConfig *config, CC_Mqtt311PublishCompleteCb cb, void *cbData)
 Prepare, configure, and send "publish" request in one go. More...
 
CC_Mqtt311ErrorCode cc_mqtt311_client_publish_cancel (CC_Mqtt311PublishHandle handle)
 Cancel the allocated "publish" operation. More...
 
CC_Mqtt311ErrorCode cc_mqtt311_client_publish_config (CC_Mqtt311PublishHandle handle, const CC_Mqtt311PublishConfig *config)
 Perform basic configuration of the "publish" operation. More...
 
unsigned cc_mqtt311_client_publish_count (CC_Mqtt311ClientHandle handle)
 Get amount incomplete "publish" operations. More...
 
CC_Mqtt311PublishOrdering cc_mqtt311_client_publish_get_ordering (CC_Mqtt311ClientHandle handle)
 Retrieve the configured the publish operations ordering. More...
 
unsigned cc_mqtt311_client_publish_get_resend_attempts (CC_Mqtt311PublishHandle handle)
 Retrieve the configured the amount of resend attempts for the "publish" operation. More...
 
unsigned cc_mqtt311_client_publish_get_response_timeout (CC_Mqtt311PublishHandle handle)
 Retrieve the configured the broker response timeout for the "publish" operation. More...
 
void cc_mqtt311_client_publish_init_config (CC_Mqtt311PublishConfig *config)
 Intialize the CC_Mqtt311PublishConfig configuration structure. More...
 
CC_Mqtt311PublishHandle cc_mqtt311_client_publish_prepare (CC_Mqtt311ClientHandle handle, CC_Mqtt311ErrorCode *ec)
 Prepare "publish" operation. More...
 
CC_Mqtt311ErrorCode cc_mqtt311_client_publish_send (CC_Mqtt311PublishHandle handle, CC_Mqtt311PublishCompleteCb cb, void *cbData)
 Send the configured "publish" operation to broker. More...
 
CC_Mqtt311ErrorCode cc_mqtt311_client_publish_set_ordering (CC_Mqtt311ClientHandle handle, CC_Mqtt311PublishOrdering ordering)
 Configure the ordering of the published messages. More...
 
CC_Mqtt311ErrorCode cc_mqtt311_client_publish_set_resend_attempts (CC_Mqtt311PublishHandle handle, unsigned attempts)
 Configure the amount of attempts to resend "publish" operation until the acknowledgement is received. More...
 
CC_Mqtt311ErrorCode cc_mqtt311_client_publish_set_response_timeout (CC_Mqtt311PublishHandle handle, unsigned ms)
 Configure the broker response timeout for the "publish" operation. More...
 
bool cc_mqtt311_client_publish_was_initiated (CC_Mqtt311PublishHandle handle)
 Check whether the "publish" operation was actually initiated (PUBLISH was sent) More...
 

Detailed Description

Typedef Documentation

◆ CC_Mqtt311PublishCompleteCb

typedef void(* CC_Mqtt311PublishCompleteCb) (void *data, CC_Mqtt311PublishHandle handle, CC_Mqtt311AsyncOpStatus status)

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

Parameters
[in]dataPointer to user data object passed as last parameter to the cc_mqtt311_client_publish_send().
[in]handleHandle returned by cc_mqtt311_client_publish_prepare() function. When the callback is invoked the handle is already invalid and cannot be used in any relevant function invocation, but it allows end application to identify the original "publish" operation and use the same callback function in parallel requests.
[in]statusStatus of the "publish" operation.

◆ CC_Mqtt311PublishHandle

typedef struct CC_Mqtt311Publish* CC_Mqtt311PublishHandle

Handle for "publish" operation.

Returned by cc_mqtt311_client_publish_prepare() function.

Enumeration Type Documentation

◆ CC_Mqtt311PublishOrdering

Publish ordering configuration.

Enumerator
CC_Mqtt311PublishOrdering_SameQos 

Preserve strict order only between same QoS messages.

CC_Mqtt311PublishOrdering_Full 

Preserve strict order between all messages.

CC_Mqtt311PublishOrdering_ValuesLimit 

Limit for the values.

Function Documentation

◆ cc_mqtt311_client_publish()

CC_Mqtt311ErrorCode cc_mqtt311_client_publish ( CC_Mqtt311ClientHandle  handle,
const CC_Mqtt311PublishConfig config,
CC_Mqtt311PublishCompleteCb  cb,
void *  cbData 
)

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

Abstracts away sequence of the following functions invocation:

Parameters
[in]handleHandle returned by cc_mqtt311_client_alloc() function.
[in]configPublish configuration.
[in]cbCallback to be invoked when "publish" 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_publish_cancel()

CC_Mqtt311ErrorCode cc_mqtt311_client_publish_cancel ( CC_Mqtt311PublishHandle  handle)

Cancel the allocated "publish" operation.

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

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

◆ cc_mqtt311_client_publish_config()

CC_Mqtt311ErrorCode cc_mqtt311_client_publish_config ( CC_Mqtt311PublishHandle  handle,
const CC_Mqtt311PublishConfig config 
)

Perform basic configuration of the "publish" operation.

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

unsigned cc_mqtt311_client_publish_count ( CC_Mqtt311ClientHandle  handle)

Get amount incomplete "publish" operations.

Parameters
[in]handleHandle returned by cc_mqtt311_client_alloc() function.
Returns
Amount of publish operations that have been prepared before, and are still incomplete.

◆ cc_mqtt311_client_publish_get_ordering()

CC_Mqtt311PublishOrdering cc_mqtt311_client_publish_get_ordering ( CC_Mqtt311ClientHandle  handle)

Retrieve the configured the publish operations ordering.

Parameters
[in]handleHandle returned by cc_mqtt311_client_publish_prepare() function.
Returns
Current ordering configuraiton.

◆ cc_mqtt311_client_publish_get_resend_attempts()

unsigned cc_mqtt311_client_publish_get_resend_attempts ( CC_Mqtt311PublishHandle  handle)

Retrieve the configured the amount of resend attempts for the "publish" operation.

Parameters
[in]handleHandle returned by cc_mqtt311_client_publish_prepare() function.
Returns
Configured amount of resend attempts.

◆ cc_mqtt311_client_publish_get_response_timeout()

unsigned cc_mqtt311_client_publish_get_response_timeout ( CC_Mqtt311PublishHandle  handle)

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

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

◆ cc_mqtt311_client_publish_init_config()

void cc_mqtt311_client_publish_init_config ( CC_Mqtt311PublishConfig config)

Intialize the CC_Mqtt311PublishConfig configuration structure.

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

◆ cc_mqtt311_client_publish_prepare()

CC_Mqtt311PublishHandle cc_mqtt311_client_publish_prepare ( CC_Mqtt311ClientHandle  handle,
CC_Mqtt311ErrorCode ec 
)

Prepare "publish" operation.

For successful operation the client needs to be in the "connected" state.

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 "publish" operation, will be NULL in case of failure. To analyze the reason failure use "ec" output parameter.
Postcondition
The "publish" operation is allocated, use either cc_mqtt311_client_publish_send() or cc_mqtt311_client_publish_cancel() to prevent memory leaks.

◆ cc_mqtt311_client_publish_send()

CC_Mqtt311ErrorCode cc_mqtt311_client_publish_send ( CC_Mqtt311PublishHandle  handle,
CC_Mqtt311PublishCompleteCb  cb,
void *  cbData 
)

Send the configured "publish" operation to broker.

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

◆ cc_mqtt311_client_publish_set_ordering()

CC_Mqtt311ErrorCode cc_mqtt311_client_publish_set_ordering ( CC_Mqtt311ClientHandle  handle,
CC_Mqtt311PublishOrdering  ordering 
)

Configure the ordering of the published messages.

The ordering configuration is expected to be performed before any "publish" operation is issued. The configuration is persistent between re-connects.

Parameters
[in]handleHandle returned by cc_mqtt311_client_publish_prepare() function.
[in]orderingOrdering configuration.
Returns
Result code of the call.

◆ cc_mqtt311_client_publish_set_resend_attempts()

CC_Mqtt311ErrorCode cc_mqtt311_client_publish_set_resend_attempts ( CC_Mqtt311PublishHandle  handle,
unsigned  attempts 
)

Configure the amount of attempts to resend "publish" operation until the acknowledgement is received.

When resending a second and further time, the DUP flags is set in the PUBLISH message to indicate duplicate.

Parameters
[in]handleHandle returned by cc_mqtt311_client_publish_prepare() function.
[in]attemptsAmount of resend attempts.
Returns
Result code of the call.

◆ cc_mqtt311_client_publish_set_response_timeout()

CC_Mqtt311ErrorCode cc_mqtt311_client_publish_set_response_timeout ( CC_Mqtt311PublishHandle  handle,
unsigned  ms 
)

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

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

◆ cc_mqtt311_client_publish_was_initiated()

bool cc_mqtt311_client_publish_was_initiated ( CC_Mqtt311PublishHandle  handle)

Check whether the "publish" operation was actually initiated (PUBLISH was sent)

Sometimes due to message ordering configuration, the requested "publish" operation can be paused. This API call checks whether the PUBLISH message was already sent to the broker.

Parameters
[in]handleHandle returned by cc_mqtt311_client_publish_prepare() function.
Returns
true in case PUBLISH message has already been sent.