CommsChampion Ecosystem MQTT v3.1.1 Client
MQTT v3.1.1 Client Library.
Loading...
Searching...
No Matches
client.h
Go to the documentation of this file.
1//
2// Copyright 2024 - 2025 (C). Alex Robenko. All rights reserved.
3//
4// This Source Code Form is subject to the terms of the Mozilla Public
5// License, v. 2.0. If a copy of the MPL was not distributed with this
6// file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
10
11#pragma once
12
13#include "cc_mqtt311_client/common.h"
14
15#ifdef __cplusplus
16extern "C" {
17#endif // #ifdef __cplusplus
18
26
34
43
58
71unsigned cc_mqtt311_client_process_data(CC_Mqtt311ClientHandle handle, const unsigned char* buf, unsigned bufLen);
72
79
87
94
100
107
113
120
126
133
139
153
158
163
170
176
183
190
202
211
229 const CC_Mqtt311ConnectConfig* config,
230 const CC_Mqtt311ConnectWillConfig* willConfig,
232 void* cbData);
233
238
249
256
263
273
283
290
296
301
308
321
330
347 const CC_Mqtt311SubscribeTopicConfig* topicConfigs,
348 unsigned topicConfigsCount,
350 void* cbData);
351
361
368
374
379
386
399
408
425 const CC_Mqtt311UnsubscribeTopicConfig* topicConfigs,
426 unsigned topicConfigsCount,
428 void* cbData);
429
439
445
450
457
463
471
477
485
497
506
515
531 const CC_Mqtt311PublishConfig* config,
533 void* cbData);
534
544
550
551
552// --------------------- Callbacks ---------------------
553
566 void* data);
567
581 void* data);
582
594 void* data);
595
604 void* data);
605
614 void* data);
615
624 void* data);
625
626#ifdef __cplusplus
627}
628#endif
void cc_mqtt311_client_set_broker_disconnect_report_callback(CC_Mqtt311ClientHandle handle, CC_Mqtt311BrokerDisconnectReportCb cb, void *data)
Set callback to report unsolicited disconnection of the broker.
void cc_mqtt311_client_set_next_tick_program_callback(CC_Mqtt311ClientHandle handle, CC_Mqtt311NextTickProgramCb cb, void *data)
Set callback to call when time measurement is required.
void cc_mqtt311_client_set_message_received_report_callback(CC_Mqtt311ClientHandle handle, CC_Mqtt311MessageReceivedReportCb cb, void *data)
Set callback to report received message from the broker.
void cc_mqtt311_client_set_send_output_data_callback(CC_Mqtt311ClientHandle handle, CC_Mqtt311SendOutputDataCb cb, void *data)
Set callback to send raw data over I/O link.
void cc_mqtt311_client_set_cancel_next_tick_wait_callback(CC_Mqtt311ClientHandle handle, CC_Mqtt311CancelNextTickWaitCb cb, void *data)
Set callback to terminate current time measurement.
void cc_mqtt311_client_set_error_log_callback(CC_Mqtt311ClientHandle handle, CC_Mqtt311ErrorLogCb cb, void *data)
Set callback to report error messages.
bool cc_mqtt311_client_get_verify_incoming_msg_subscribed(CC_Mqtt311ClientHandle handle)
Retrieve current incoming message being correctly subscribed control.
bool cc_mqtt311_client_get_verify_incoming_topic_enabled(CC_Mqtt311ClientHandle handle)
Retrieve current incoming topic format verification control.
void(* CC_Mqtt311NextTickProgramCb)(void *data, unsigned duration)
Callback used to request time measurement.
Definition common.h:274
void(* CC_Mqtt311SendOutputDataCb)(void *data, const unsigned char *buf, unsigned bufLen)
Callback used to request to send data to the broker.
Definition common.h:298
CC_Mqtt311ErrorCode cc_mqtt311_client_set_verify_outgoing_topic_enabled(CC_Mqtt311ClientHandle handle, bool enabled)
Control outgoing topic format verification.
void(* CC_Mqtt311MessageReceivedReportCb)(void *data, const CC_Mqtt311MessageInfo *info)
Callback used to report new message received of the broker.
Definition common.h:313
CC_Mqtt311ErrorCode cc_mqtt311_client_set_verify_incoming_msg_subscribed(CC_Mqtt311ClientHandle handle, bool enabled)
Control verification of the incoming message being correctly subscribed.
unsigned cc_mqtt311_client_get_default_response_timeout(CC_Mqtt311ClientHandle handle)
Retrieved currently configured default response timeout period.
CC_Mqtt311ClientHandle cc_mqtt311_client_alloc()
Allocate new client.
unsigned(* CC_Mqtt311CancelNextTickWaitCb)(void *data)
Callback used to request termination of existing time measurement.
Definition common.h:283
CC_Mqtt311ErrorCode cc_mqtt311_client_set_verify_incoming_topic_enabled(CC_Mqtt311ClientHandle handle, bool enabled)
Control incoming topic format verification.
void cc_mqtt311_client_notify_network_disconnected(CC_Mqtt311ClientHandle handle)
Report network disconnected.
void(* CC_Mqtt311ErrorLogCb)(void *data, const char *msg)
Callback used to report discovered errors.
Definition common.h:320
void cc_mqtt311_client_tick(CC_Mqtt311ClientHandle handle, unsigned ms)
Notify client about requested time expiry.
CC_Mqtt311ErrorCode cc_mqtt311_client_set_default_response_timeout(CC_Mqtt311ClientHandle handle, unsigned ms)
Configure default response timeout period.
struct CC_Mqtt311Client * CC_Mqtt311ClientHandle
Handle used to access client specific data structures.
Definition common.h:138
void(* CC_Mqtt311BrokerDisconnectReportCb)(void *data, CC_Mqtt311BrokerDisconnectReason reason)
Callback used to report unsolicited disconnection of the broker.
Definition common.h:305
bool cc_mqtt311_client_is_network_disconnected(CC_Mqtt311ClientHandle handle)
Check current network disconnected status.
bool cc_mqtt311_client_get_verify_outgoing_topic_enabled(CC_Mqtt311ClientHandle handle)
Retrieve current outgoing topic format verification control.
void cc_mqtt311_client_free(CC_Mqtt311ClientHandle handle)
Free previously allocated client.
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.
CC_Mqtt311ConnectHandle cc_mqtt311_client_connect_prepare(CC_Mqtt311ClientHandle handle, CC_Mqtt311ErrorCode *ec)
Prepare "connect" operation.
void cc_mqtt311_client_connect_init_config(CC_Mqtt311ConnectConfig *config)
Intialize the CC_Mqtt311ConnectConfig configuration structure.
CC_Mqtt311ErrorCode cc_mqtt311_client_connect_set_response_timeout(CC_Mqtt311ConnectHandle handle, unsigned ms)
Configure the broker response timeout for the "connect" operation.
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.
unsigned cc_mqtt311_client_connect_get_response_timeout(CC_Mqtt311ConnectHandle handle)
Retrieve the configured the broker response timeout for the "connect" operation.
CC_Mqtt311ErrorCode cc_mqtt311_client_connect_config_will(CC_Mqtt311ConnectHandle handle, const CC_Mqtt311ConnectWillConfig *config)
Perform will configuration of the "connect" operation.
CC_Mqtt311ErrorCode cc_mqtt311_client_connect_send(CC_Mqtt311ConnectHandle handle, CC_Mqtt311ConnectCompleteCb cb, void *cbData)
Send the configured "connect" operation to broker.
void cc_mqtt311_client_connect_init_config_will(CC_Mqtt311ConnectWillConfig *config)
Intialize the CC_Mqtt311ConnectWillConfig configuration structure.
CC_Mqtt311ErrorCode cc_mqtt311_client_connect_cancel(CC_Mqtt311ConnectHandle handle)
Cancel the allocated "connect" operation.
void(* CC_Mqtt311ConnectCompleteCb)(void *data, CC_Mqtt311AsyncOpStatus status, const CC_Mqtt311ConnectResponse *response)
Callback used to report completion of the "connect" operation.
Definition common.h:330
CC_Mqtt311ErrorCode cc_mqtt311_client_connect_config(CC_Mqtt311ConnectHandle handle, const CC_Mqtt311ConnectConfig *config)
Perform basic configuration of the "connect" operation.
bool cc_mqtt311_client_is_connected(CC_Mqtt311ClientHandle handle)
Check the inner state of the library of whether it's connected to the broker.
struct CC_Mqtt311Connect * CC_Mqtt311ConnectHandle
Handle for "connect" operation.
Definition common.h:147
CC_Mqtt311DisconnectHandle cc_mqtt311_client_disconnect_prepare(CC_Mqtt311ClientHandle handle, CC_Mqtt311ErrorCode *ec)
Prepare "disconnect" operation.
CC_Mqtt311ErrorCode cc_mqtt311_client_disconnect_send(CC_Mqtt311DisconnectHandle handle)
Send the configured "disconnect" operation to broker.
CC_Mqtt311ErrorCode cc_mqtt311_client_disconnect_cancel(CC_Mqtt311DisconnectHandle handle)
Cancel the allocated "disconnect" operation.
CC_Mqtt311ErrorCode cc_mqtt311_client_disconnect(CC_Mqtt311ClientHandle handle)
Prepare, and send "disconnect" request in one go.
struct CC_Mqtt311Disconnect * CC_Mqtt311DisconnectHandle
Handle for "disconnect" operation.
Definition common.h:156
CC_Mqtt311ErrorCode
Error code returned by various API functions.
Definition common.h:55
CC_Mqtt311ErrorCode cc_mqtt311_client_publish_send(CC_Mqtt311PublishHandle handle, CC_Mqtt311PublishCompleteCb cb, void *cbData)
Send the configured "publish" operation to broker.
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.
unsigned cc_mqtt311_client_publish_count(CC_Mqtt311ClientHandle handle)
Get amount incomplete "publish" operations.
CC_Mqtt311PublishOrdering cc_mqtt311_client_publish_get_ordering(CC_Mqtt311ClientHandle handle)
Retrieve the configured the publish operations ordering.
unsigned cc_mqtt311_client_publish_get_resend_attempts(CC_Mqtt311PublishHandle handle)
Retrieve the configured the amount of resend attempts for the "publish" operation.
CC_Mqtt311ErrorCode cc_mqtt311_client_publish_set_response_timeout(CC_Mqtt311PublishHandle handle, unsigned ms)
Configure the broker response timeout for the "publish" operation.
unsigned cc_mqtt311_client_publish_get_response_timeout(CC_Mqtt311PublishHandle handle)
Retrieve the configured the broker response timeout for the "publish" operation.
void cc_mqtt311_client_publish_init_config(CC_Mqtt311PublishConfig *config)
Intialize the CC_Mqtt311PublishConfig configuration structure.
CC_Mqtt311ErrorCode cc_mqtt311_client_publish_set_ordering(CC_Mqtt311ClientHandle handle, CC_Mqtt311PublishOrdering ordering)
Configure the ordering of the published messages.
struct CC_Mqtt311Publish * CC_Mqtt311PublishHandle
Handle for "publish" operation.
Definition common.h:183
CC_Mqtt311ErrorCode cc_mqtt311_client_publish_config(CC_Mqtt311PublishHandle handle, const CC_Mqtt311PublishConfig *config)
Perform basic configuration of the "publish" operation.
void(* CC_Mqtt311PublishCompleteCb)(void *data, CC_Mqtt311PublishHandle handle, CC_Mqtt311AsyncOpStatus status)
Callback used to report completion of the "publish" operation.
Definition common.h:366
CC_Mqtt311PublishHandle cc_mqtt311_client_publish_prepare(CC_Mqtt311ClientHandle handle, CC_Mqtt311ErrorCode *ec)
Prepare "publish" operation.
CC_Mqtt311ErrorCode cc_mqtt311_client_publish_cancel(CC_Mqtt311PublishHandle handle)
Cancel the allocated "publish" operation.
bool cc_mqtt311_client_publish_was_initiated(CC_Mqtt311PublishHandle handle)
Check whether the "publish" operation was actually initiated (PUBLISH was sent)
CC_Mqtt311PublishOrdering
Publish ordering configuration.
Definition common.h:92
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.
CC_Mqtt311ErrorCode cc_mqtt311_client_subscribe_set_response_timeout(CC_Mqtt311SubscribeHandle handle, unsigned ms)
Configure the broker response timeout for the "subscribe" operation.
unsigned cc_mqtt311_client_subscribe_get_response_timeout(CC_Mqtt311SubscribeHandle handle)
Retrieve the configured the broker response timeout for the "subscribe" operation.
CC_Mqtt311SubscribeHandle cc_mqtt311_client_subscribe_prepare(CC_Mqtt311ClientHandle handle, CC_Mqtt311ErrorCode *ec)
Prepare "subscribe" operation.
CC_Mqtt311ErrorCode cc_mqtt311_client_subscribe_config_topic(CC_Mqtt311SubscribeHandle handle, const CC_Mqtt311SubscribeTopicConfig *config)
Add topic configuration of the "subscribe" operation.
CC_Mqtt311ErrorCode cc_mqtt311_client_subscribe(CC_Mqtt311ClientHandle handle, const CC_Mqtt311SubscribeTopicConfig *topicConfigs, unsigned topicConfigsCount, CC_Mqtt311SubscribeCompleteCb cb, void *cbData)
Prepare, configure, and send "subscribe" request in one go.
void cc_mqtt311_client_subscribe_init_config_topic(CC_Mqtt311SubscribeTopicConfig *config)
Intialize the CC_Mqtt311SubscribeTopicConfig configuration structure.
void(* CC_Mqtt311SubscribeCompleteCb)(void *data, CC_Mqtt311SubscribeHandle handle, CC_Mqtt311AsyncOpStatus status, const CC_Mqtt311SubscribeResponse *response)
Callback used to report completion of the "subscribe" operation.
Definition common.h:344
CC_Mqtt311ErrorCode cc_mqtt311_client_subscribe_cancel(CC_Mqtt311SubscribeHandle handle)
Cancel the allocated "subscribe" operation.
CC_Mqtt311ErrorCode cc_mqtt311_client_subscribe_send(CC_Mqtt311SubscribeHandle handle, CC_Mqtt311SubscribeCompleteCb cb, void *cbData)
Send the configured "subscribe" operation to broker.
struct CC_Mqtt311Subscribe * CC_Mqtt311SubscribeHandle
Handle for "subscribe" operation.
Definition common.h:165
CC_Mqtt311ErrorCode cc_mqtt311_client_unsubscribe_cancel(CC_Mqtt311UnsubscribeHandle handle)
Cancel the allocated "unsubscribe" operation.
CC_Mqtt311ErrorCode cc_mqtt311_client_unsubscribe_set_response_timeout(CC_Mqtt311UnsubscribeHandle handle, unsigned ms)
Configure the broker response timeout for the "unsubscribe" operation.
struct CC_Mqtt311Unsubscribe * CC_Mqtt311UnsubscribeHandle
Handle for "unsubscribe" operation.
Definition common.h:174
void cc_mqtt311_client_unsubscribe_init_config_topic(CC_Mqtt311UnsubscribeTopicConfig *config)
Intialize the CC_Mqtt311UnsubscribeTopicConfig configuration structure.
CC_Mqtt311ErrorCode cc_mqtt311_client_unsubscribe_config_topic(CC_Mqtt311UnsubscribeHandle handle, const CC_Mqtt311UnsubscribeTopicConfig *config)
Add topic configuration of the "unsubscribe" operation.
void(* CC_Mqtt311UnsubscribeCompleteCb)(void *data, CC_Mqtt311UnsubscribeHandle handle, CC_Mqtt311AsyncOpStatus status)
Callback used to report completion of the "unsubscribe" operation.
Definition common.h:355
unsigned cc_mqtt311_client_unsubscribe_get_response_timeout(CC_Mqtt311UnsubscribeHandle handle)
Retrieve the configured the broker response timeout for the "unsubscribe" operation.
CC_Mqtt311UnsubscribeHandle cc_mqtt311_client_unsubscribe_prepare(CC_Mqtt311ClientHandle handle, CC_Mqtt311ErrorCode *ec)
Prepare "unsubscribe" operation.
CC_Mqtt311ErrorCode cc_mqtt311_client_unsubscribe(CC_Mqtt311ClientHandle handle, const CC_Mqtt311UnsubscribeTopicConfig *topicConfigs, unsigned topicConfigsCount, CC_Mqtt311UnsubscribeCompleteCb cb, void *cbData)
Prepare, configure, and send "unsubscribe" request in one go.
CC_Mqtt311ErrorCode cc_mqtt311_client_unsubscribe_send(CC_Mqtt311UnsubscribeHandle handle, CC_Mqtt311UnsubscribeCompleteCb cb, void *cbData)
Send the configured "unsubscribe" operation to broker.
Configuration structure to be passed to the cc_mqtt311_client_connect_config().
Definition common.h:189
Configuration structure to be passed to the cc_mqtt311_client_connect_config_will().
Definition common.h:202
Configuration structure to be passed to the cc_mqtt311_client_publish_config().
Definition common.h:258
Topic filter configuration structure of the "subscribe" operation.
Definition common.h:222
Topic filter configuration structure of the "unsubscribe" operation.
Definition common.h:239