MQTT-SN Gateway Library
Library that allows implementation of MQTT-SN gateway.
|
C interface for MQTT-SN Gateway library. More...
Go to the source code of this file.
Classes | |
struct | CC_MqttsnPredefinedTopicInfo |
Info about single predefined topic. More... | |
struct | CC_MqttsnAuthInfo |
Authentication infor for a single client. More... | |
Typedefs | |
typedef struct CC_MqttsnGateway * | CC_MqttsnGatewayHandle |
Handle for gateway object used in all cc_mqttsn_gw_* functions. | |
typedef void(* | CC_MqttsnGwTickReqCb) (void *userData, unsigned duration) |
Type of callback function, to be used to request time measurement for the Gateway object. | |
typedef void(* | CC_MqttsnGwBroadcastReqCb) (void *userData, const unsigned char *buf, unsigned bufLen) |
Type of callback function, to be used to request broadcast of serialised ADVERTISE message. | |
typedef struct CC_MqttsnSession * | CC_MqttsnSessionHandle |
Handle for session object used in all cc_mqttsn_gw_session_* functions. | |
typedef void(* | CC_MqttsnSessionTickReqCb) (void *userData, CC_MqttsnSessionHandle session, unsigned duration) |
Type of callback, used to request new time measurement. | |
typedef unsigned(* | CC_MqttsnSessionCancelTickReqCb) (void *userData, CC_MqttsnSessionHandle session) |
Type of callback, used to cancel existing time measurement. | |
typedef void(* | CC_MqttsnSessionClientSendDataReqCb) (void *userData, CC_MqttsnSessionHandle session, const unsigned char *buf, unsigned bufLen, unsigned broadcastRadius) |
Type of callback, used to request delivery of serialised message to the client. | |
typedef void(* | CC_MqttsnSessionBrokerSendDataReqCb) (void *userData, CC_MqttsnSessionHandle session, const unsigned char *buf, unsigned bufLen) |
Type of callback, used to request delivery of serialised message to the broker. | |
typedef void(* | CC_MqttsnSessionTermReqCb) (void *userData, CC_MqttsnSessionHandle session) |
Type of callback, used to request session termination. | |
typedef void(* | CC_MqttsnSessionBrokerReconnectReqCb) (void *userData, CC_MqttsnSessionHandle session) |
Type of callback used to request reconnection to the broker. | |
typedef void(* | CC_MqttsnSessionClientConnectReportCb) (void *userData, CC_MqttsnSessionHandle session, const char *clientId) |
Type of callback used to report client ID of the newly connected MQTT-SN client. | |
typedef void(* | CC_MqttsnSessionAuthInfoReqCb) (void *userData, CC_MqttsnSessionHandle session, const char *clientId, const char **username, const unsigned char **password, unsigned *passwordLen) |
Type of callback used to request authentication information of the client that is trying to connect. | |
typedef void(* | CC_MqttsnSessionErrorReportCb) (void *userData, CC_MqttsnSessionHandle session, const char *msg) |
Type of callback used to report error messages detected by the session. | |
typedef bool(* | CC_MqttsnSessionFwdEncSessionCreatedCb) (void *userData, CC_MqttsnSessionHandle session) |
Type of callback used to report forwarding encapsulated session creation. | |
typedef void(* | CC_MqttsnSessionFwdEncSessionDeletedCb) (void *userData, CC_MqttsnSessionHandle session) |
Type of callback used to report forwarding encapsulated session about to be deleted. | |
typedef struct CC_MqttsnConfig * | CC_MqttsnConfigHandle |
Handle for session object used in all cc_mqttsn_gw_config_* functions. | |
Enumerations | |
enum | CC_MqttsnClientConnectionType { CC_MqttsnClientConnectionType_Udp , CC_MqttsnClientConnectionType_ValuesLimit } |
Client I/O socket connection type. More... | |
enum | CC_MqttsnBrokerConnectionType { CC_MqttsnBrokerConnectionType_Tcp , CC_MqttsnBrokerConnectionType_ValuesLimit } |
Broker I/O socket connection type. More... | |
Functions | |
CC_MqttsnGatewayHandle | cc_mqttsn_gw_alloc (void) |
Allocate Gateway object. | |
void | cc_mqttsn_gw_free (CC_MqttsnGatewayHandle gw) |
Free allocated Gateway object. | |
void | cc_mqttsn_gw_set_advertise_period (CC_MqttsnGatewayHandle gw, unsigned short value) |
Set the advertise period. | |
unsigned short | cc_mqttsn_gw_get_advertise_period (CC_MqttsnGatewayHandle gw) |
Get current configuration of the advertise period. | |
void | cc_mqttsn_gw_set_id (CC_MqttsnGatewayHandle gw, unsigned char id) |
Set the numeric gateway ID. | |
unsigned char | cc_mqttsn_gw_get_id (CC_MqttsnGatewayHandle gw) |
Get current configuration of the numeric gateway id. | |
void | cc_mqttsn_gw_set_tick_req_cb (CC_MqttsnGatewayHandle gw, CC_MqttsnGwTickReqCb cb, void *data) |
Set callback that requests to perform time measurement. | |
void | cc_mqttsn_gw_set_advertise_broadcast_req_cb (CC_MqttsnGatewayHandle gw, CC_MqttsnGwBroadcastReqCb cb, void *data) |
Set callback that requests to send serialised ADVERTISE message. | |
bool | cc_mqttsn_gw_start (CC_MqttsnGatewayHandle gw) |
Start operation of the Gateway object. | |
void | cc_mqttsn_gw_stop (CC_MqttsnGatewayHandle gw) |
Stop operation of the Gateway object. | |
void | cc_mqttsn_gw_tick (CC_MqttsnGatewayHandle gw) |
Notify the Gateway object about requested time expiry. | |
CC_MqttsnSessionHandle | cc_mqttsn_gw_session_alloc (void) |
Allocate Session object. | |
void | cc_mqttsn_gw_session_free (CC_MqttsnSessionHandle session) |
Free allocated Session object. | |
void | cc_mqttsn_gw_session_set_tick_req_cb (CC_MqttsnSessionHandle session, CC_MqttsnSessionTickReqCb cb, void *data) |
Set the callback to be invoked when new time measurement is required. | |
void | cc_mqttsn_gw_session_set_cancel_tick_cb (CC_MqttsnSessionHandle session, CC_MqttsnSessionCancelTickReqCb cb, void *data) |
Set the callback to be invoked when previously requested time measurement needs to be cancelled. | |
void | cc_mqttsn_gw_session_set_send_data_to_client_cb (CC_MqttsnSessionHandle session, CC_MqttsnSessionClientSendDataReqCb cb, void *data) |
Set the callback to be invoked when new data needs to be sent to the client. | |
void | cc_mqttsn_gw_session_set_send_data_to_broker_cb (CC_MqttsnSessionHandle session, CC_MqttsnSessionBrokerSendDataReqCb cb, void *data) |
Set the callback to be invoked when new data needs to be sent to the broker. | |
void | cc_mqttsn_gw_session_set_term_req_cb (CC_MqttsnSessionHandle session, CC_MqttsnSessionTermReqCb cb, void *data) |
Set the callback to be invoked when the Session needs to be terminated and the calling Session object deleted. | |
void | cc_mqttsn_gw_session_set_broker_reconnect_req_cb (CC_MqttsnSessionHandle session, CC_MqttsnSessionBrokerReconnectReqCb cb, void *data) |
Set the callback to be invoked when the Session needs to close existing TCP/IP connection to the broker and open a new one. | |
void | cc_mqttsn_gw_session_set_client_connect_report_cb (CC_MqttsnSessionHandle session, CC_MqttsnSessionClientConnectReportCb cb, void *data) |
Set the callback to be invoked when MQTT-SN client is successfully connected to the broker. | |
void | cc_mqttsn_gw_session_set_auth_info_req_cb (CC_MqttsnSessionHandle session, CC_MqttsnSessionAuthInfoReqCb cb, void *data) |
Set the callback to be used to request authentication information for specific client. | |
void | cc_mqttsn_gw_session_set_error_report_cb (CC_MqttsnSessionHandle session, CC_MqttsnSessionErrorReportCb cb, void *data) |
Set the callback to be used to report error messages detected by the session. | |
void | cc_mqttsn_gw_session_set_fwd_enc_session_created_cb (CC_MqttsnSessionHandle session, CC_MqttsnSessionFwdEncSessionCreatedCb cb, void *data) |
Set the callback to be invoked when the forwarding encapsulation session is detected and to notify application about such session creation. | |
void | cc_mqttsn_gw_session_set_fwd_enc_session_deleted_cb (CC_MqttsnSessionHandle session, CC_MqttsnSessionFwdEncSessionDeletedCb cb, void *data) |
Set the callback to be invoked when the forwarding encapsulation session is about to be deleted. | |
void | cc_mqttsn_gw_session_set_id (CC_MqttsnSessionHandle session, unsigned char id) |
Set gateway numeric ID to be reported when requested. | |
unsigned char | cc_mqttsn_gw_session_get_id (CC_MqttsnSessionHandle session) |
Get current gateway numeric ID configuration. | |
void | cc_mqttsn_gw_session_set_retry_period (CC_MqttsnSessionHandle session, unsigned value) |
Set retry period to wait between resending unacknowledged message to the client and/or broker. | |
unsigned | cc_mqttsn_gw_session_get_retry_period (CC_MqttsnSessionHandle session) |
Get the current configuration of the retry period. | |
void | cc_mqttsn_gw_session_set_retry_count (CC_MqttsnSessionHandle session, unsigned value) |
Set number of retry attempts to perform before abandoning attempt to send unacknowledged message. | |
unsigned | cc_mqttsn_gw_session_get_retry_count (CC_MqttsnSessionHandle session) |
Get the current configuration of the retry count. | |
void | cc_mqttsn_gw_session_set_sleeping_client_msg_limit (CC_MqttsnSessionHandle session, unsigned long long value) |
Provide limit to number pending messages being accumulated for the sleeping client. | |
unsigned long long | cc_mqttsn_gw_session_get_sleeping_client_msg_limit (CC_MqttsnSessionHandle session) |
Get currenly configured limit to pending messages being accumulated for the sleeping client. | |
void | cc_mqttsn_gw_session_set_default_client_id (CC_MqttsnSessionHandle session, const char *clientId) |
Provide default client ID for clients that report empty one in their attempt to connect. | |
const char * | cc_mqttsn_gw_session_get_default_client_id (CC_MqttsnSessionHandle session) |
Get current default client ID configuration. | |
void | cc_mqttsn_gw_session_set_pub_only_keep_alive (CC_MqttsnSessionHandle session, unsigned value) |
Provide default "keep alive" period for "publish only" clients, that do not make an attempt to connect to the gateway. | |
unsigned | cc_mqttsn_gw_session_get_pub_only_keep_alive (CC_MqttsnSessionHandle session) |
Get current configuration of the default "keep alive" period for "publish only" clients. | |
bool | cc_mqttsn_gw_session_start (CC_MqttsnSessionHandle session) |
Start the Session's object's operation. | |
void | cc_mqttsn_gw_session_stop (CC_MqttsnSessionHandle session) |
Stop the operation of the Session object. | |
void | cc_mqttsn_gw_session_tick (CC_MqttsnSessionHandle session) |
Notify the Session object about requested time period expiry. | |
unsigned | cc_mqttsn_gw_session_data_from_client (CC_MqttsnSessionHandle session, const unsigned char *buf, unsigned bufLen) |
Provide data received from the client for processing. | |
unsigned | cc_mqttsn_gw_session_data_from_broker (CC_MqttsnSessionHandle session, const unsigned char *buf, unsigned bufLen) |
Provide data received from the broker for processing. | |
void | cc_mqttsn_gw_session_set_broker_connected (CC_MqttsnSessionHandle session, bool connected) |
Notify the Session object about broker being connected / disconnected. | |
bool | cc_mqttsn_gw_session_get_broker_connected (CC_MqttsnSessionHandle session) |
Get currently recorded broker connection status. | |
bool | cc_mqttsn_gw_session_add_predefined_topic (CC_MqttsnSessionHandle session, const char *topic, unsigned short topicId) |
Add predefined topic string and ID information. | |
bool | cc_mqttsn_gw_session_set_topic_id_alloc_range (CC_MqttsnSessionHandle session, unsigned short minTopicId, unsigned short maxTopicId) |
Limit range of topic IDs allocated for newly registered topics. | |
CC_MqttsnConfigHandle | cc_mqttsn_gw_config_alloc (void) |
Allocate Config object. | |
void | cc_mqttsn_gw_config_free (CC_MqttsnConfigHandle config) |
Free allocated Config object. | |
void | cc_mqttsn_gw_config_parse (CC_MqttsnConfigHandle config, const char *str) |
Parse configuration contents from string. | |
bool | cc_mqttsn_gw_config_read (CC_MqttsnConfigHandle config, const char *filename) |
Read configuration file. | |
unsigned char | cc_mqttsn_gw_config_id (CC_MqttsnConfigHandle config) |
Get gateway numeric ID. | |
unsigned short | cc_mqttsn_gw_config_advertise_period (CC_MqttsnConfigHandle config) |
Get advertise period. | |
unsigned | cc_mqttsn_gw_config_retry_period (CC_MqttsnConfigHandle config) |
Get retry period. | |
unsigned | cc_mqttsn_gw_config_retry_count (CC_MqttsnConfigHandle config) |
Get number of retry attempts. | |
const char * | cc_mqttsn_gw_config_default_client_id (CC_MqttsnConfigHandle config) |
Get default client ID. | |
unsigned | cc_mqttsn_gw_config_pub_only_keep_alive (CC_MqttsnConfigHandle config) |
Get keep alive period for publish only clients. | |
unsigned | cc_mqttsn_gw_config_sleeping_client_msg_limit (CC_MqttsnConfigHandle config) |
Get limit for max number of messages to accumulate for sleeping clients. | |
unsigned | cc_mqttsn_gw_config_available_predefined_topics (CC_MqttsnConfigHandle config) |
Get number of available predefined topic IDs. | |
unsigned | cc_mqttsn_gw_config_get_predefined_topics (CC_MqttsnConfigHandle config, CC_MqttsnPredefinedTopicInfo *buf, unsigned bufLen) |
Read information about available topic IDs into a buffer. | |
unsigned | cc_mqttsn_gw_config_available_auth_infos (CC_MqttsnConfigHandle config) |
Get number of available authenticatin infos for all the clients. | |
unsigned | cc_mqttsn_gw_config_get_auth_infos (CC_MqttsnConfigHandle config, CC_MqttsnAuthInfo *buf, unsigned bufLen) |
Read clients' authentication information into a buffer. | |
void | cc_mqttsn_gw_config_topic_id_alloc_range (CC_MqttsnConfigHandle config, unsigned short *min, unsigned short *max) |
Get range of allowed topic IDs for allocation. | |
const char * | cc_mqttsn_gw_config_broker_address (CC_MqttsnConfigHandle config) |
Get TCP/IP address of the broker. | |
unsigned short | cc_mqttsn_gw_config_broker_port (CC_MqttsnConfigHandle config) |
Get TCP/IP port of the broker. | |
const char * | cc_mqttsn_gw_config_log_file (CC_MqttsnConfigHandle config) |
Get log file. | |
CC_MqttsnClientConnectionType | cc_mqttsn_gw_config_client_connection_type (CC_MqttsnConfigHandle config) |
Get client I/O socket connection type. | |
CC_MqttsnBrokerConnectionType | cc_mqttsn_gw_config_broker_connection_type (CC_MqttsnConfigHandle config) |
Get broker I/O socket connection type. | |
unsigned | cc_mqttsn_gw_config_values_count (CC_MqttsnConfigHandle config, const char *key) |
Get number of available configuration values for the provided key. | |
const char * | cc_mqttsn_gw_config_get_value (CC_MqttsnConfigHandle config, const char *key, unsigned idx) |
Get the available value for the configuration key. | |
C interface for MQTT-SN Gateway library.
typedef void(* CC_MqttsnGwBroadcastReqCb) (void *userData, const unsigned char *buf, unsigned bufLen) |
Type of callback function, to be used to request broadcast of serialised ADVERTISE message.
The callback is set using cc_mqttsn_gw_set_advertise_broadcast_req_cb().
[in] | userData | User data passed as the last parameter to the setting function. |
[in] | buf | Pointer to the buffer of data, that needs to be sent. |
[in] | bufLen | Number of bytes in the buffer. |
typedef void(* CC_MqttsnGwTickReqCb) (void *userData, unsigned duration) |
Type of callback function, to be used to request time measurement for the Gateway object.
The callback is set using cc_mqttsn_gw_set_tick_req_cb(). When the required time expires, the driving code is responsible to invoke cc_mqttsn_gw_tick() function.
[in] | userData | User data passed as the last parameter to the setting function. |
[in] | duration | Requested time measurement duration in milliseconds. |
typedef void(* CC_MqttsnSessionAuthInfoReqCb) (void *userData, CC_MqttsnSessionHandle session, const char *clientId, const char **username, const unsigned char **password, unsigned *passwordLen) |
Type of callback used to request authentication information of the client that is trying to connect.
[in] | userData | User data passed as the last parameter to the setting function. |
[in] | session | Handle of session performing the request |
[in] | clientId | Client ID |
[out] | username | Username string |
[out] | password | Binary password buffer |
[out] | passwordLen | Length of the binary password |
typedef void(* CC_MqttsnSessionBrokerReconnectReqCb) (void *userData, CC_MqttsnSessionHandle session) |
Type of callback used to request reconnection to the broker.
When the callback is invoked, the driving code must close existing TCP/IP connection to the broker and create a new one.
[in] | userData | User data passed as the last parameter to the setting function. |
[in] | session | Handle of session performing the request |
typedef void(* CC_MqttsnSessionBrokerSendDataReqCb) (void *userData, CC_MqttsnSessionHandle session, const unsigned char *buf, unsigned bufLen) |
Type of callback, used to request delivery of serialised message to the broker.
[in] | userData | User data passed as the last parameter to the setting function. |
[in] | session | Handle of session performing the request |
[in] | buf | Buffer containing serialised message. |
[in] | bufLen | Number of bytes in the buffer |
typedef unsigned(* CC_MqttsnSessionCancelTickReqCb) (void *userData, CC_MqttsnSessionHandle session) |
Type of callback, used to cancel existing time measurement.
When invoked the existing time measurement needs to be cancelled. The function also needs to return amount of milliseconds elapsed since last timer programming request.
[in] | userData | User data passed as the last parameter to the setting function. |
[in] | session | Handle of session performing the request |
typedef void(* CC_MqttsnSessionClientConnectReportCb) (void *userData, CC_MqttsnSessionHandle session, const char *clientId) |
Type of callback used to report client ID of the newly connected MQTT-SN client.
The callback can be used to provide additional client specific information, such as predefined topic IDs.
[in] | userData | User data passed as the last parameter to the setting function. |
[in] | session | Handle of session performing the report |
[in] | clientId | Client ID |
typedef void(* CC_MqttsnSessionClientSendDataReqCb) (void *userData, CC_MqttsnSessionHandle session, const unsigned char *buf, unsigned bufLen, unsigned broadcastRadius) |
Type of callback, used to request delivery of serialised message to the client.
[in] | userData | User data passed as the last parameter to the setting function. |
[in] | session | Handle of session performing the request |
[in] | buf | Buffer containing serialised message. |
[in] | bufLen | Number of bytes in the buffer |
[in] | broadcastRadius | Broadcast radius. 0 means unicast. |
typedef void(* CC_MqttsnSessionErrorReportCb) (void *userData, CC_MqttsnSessionHandle session, const char *msg) |
Type of callback used to report error messages detected by the session.
[in] | userData | User data passed as the last parameter to the setting function. |
[in] | session | Handle of session performing the request |
[in] | msg | Error message |
typedef bool(* CC_MqttsnSessionFwdEncSessionCreatedCb) (void *userData, CC_MqttsnSessionHandle session) |
Type of callback used to report forwarding encapsulated session creation.
The application is responsible to perform the necessary session configuration as well as set all the callbacks except the one set by the cc_mqttsn_gw_session_set_send_data_to_client_cb() and cc_mqttsn_gw_session_set_term_req_cb(). The data sent to the client as well as the session termination are managed by the calling session object. The application is responsible to manage the timer as well as broker connection of the reported session.
[in] | userData | User data passed as the last parameter to the setting function. |
[in] | session | Handle of created session object |
typedef void(* CC_MqttsnSessionFwdEncSessionDeletedCb) (void *userData, CC_MqttsnSessionHandle session) |
Type of callback used to report forwarding encapsulated session about to be deleted.
The application is responsible to remove any reference to the session object from its internal data structes.
[in] | userData | User data passed as the last parameter to the setting function. |
[in] | session | Handle of session object about to be deleted |
typedef void(* CC_MqttsnSessionTermReqCb) (void *userData, CC_MqttsnSessionHandle session) |
Type of callback, used to request session termination.
When the callback is invoked, the driving code must flush all the previously sent messages to appropriate I/O links and delete this session object.
[in] | userData | User data passed as the last parameter to the setting function. |
[in] | session | Handle of session performing the request |
typedef void(* CC_MqttsnSessionTickReqCb) (void *userData, CC_MqttsnSessionHandle session, unsigned duration) |
Type of callback, used to request new time measurement.
When the requested time is due, the driving code is expected to call cc_mqttsn_gw_session_tick() member function.
[in] | userData | User data passed as the last parameter to the setting function. |
[in] | session | Handle of session performing the request |
[in] | duration | Number of milliseconds to measure. |
CC_MqttsnGatewayHandle cc_mqttsn_gw_alloc | ( | void | ) |
Allocate Gateway object.
The returned handle need to be passed as first parameter to all relevant functions. Note that the Gateway object is dynamically allocated and needs to be freed using cc_mqttsn_gw_free() function.
unsigned short cc_mqttsn_gw_config_advertise_period | ( | CC_MqttsnConfigHandle | config | ) |
Get advertise period.
Default value is 900 seconds (15 minutes).
[in] | config | Handle returned by cc_mqttsn_gw_config_alloc() function. |
CC_MqttsnConfigHandle cc_mqttsn_gw_config_alloc | ( | void | ) |
Allocate Config object.
The returned handle need to be passed as first parameter to all relevant functions. Note that the Config object is dynamically allocated and needs to be freed using cc_mqttsn_gw_config_free() function.
unsigned cc_mqttsn_gw_config_available_auth_infos | ( | CC_MqttsnConfigHandle | config | ) |
Get number of available authenticatin infos for all the clients.
[in] | config | Handle returned by cc_mqttsn_gw_config_alloc() function. |
unsigned cc_mqttsn_gw_config_available_predefined_topics | ( | CC_MqttsnConfigHandle | config | ) |
Get number of available predefined topic IDs.
[in] | config | Handle returned by cc_mqttsn_gw_config_alloc() function. |
const char * cc_mqttsn_gw_config_broker_address | ( | CC_MqttsnConfigHandle | config | ) |
Get TCP/IP address of the broker.
Default address is 127.0.0.1
[in] | config | Handle returned by cc_mqttsn_gw_config_alloc() function. |
CC_MqttsnBrokerConnectionType cc_mqttsn_gw_config_broker_connection_type | ( | CC_MqttsnConfigHandle | config | ) |
Get broker I/O socket connection type.
config | Handle returned by cc_mqttsn_gw_config_alloc() function. |
unsigned short cc_mqttsn_gw_config_broker_port | ( | CC_MqttsnConfigHandle | config | ) |
Get TCP/IP port of the broker.
Default value is 1883
[in] | config | Handle returned by cc_mqttsn_gw_config_alloc() function. |
CC_MqttsnClientConnectionType cc_mqttsn_gw_config_client_connection_type | ( | CC_MqttsnConfigHandle | config | ) |
Get client I/O socket connection type.
config | Handle returned by cc_mqttsn_gw_config_alloc() function. |
const char * cc_mqttsn_gw_config_default_client_id | ( | CC_MqttsnConfigHandle | config | ) |
Get default client ID.
Default value is empty string.
[in] | config | Handle returned by cc_mqttsn_gw_config_alloc() function. |
void cc_mqttsn_gw_config_free | ( | CC_MqttsnConfigHandle | config | ) |
Free allocated Config object.
[in] | config | Handle returned by cc_mqttsn_gw_config_alloc() function. |
unsigned cc_mqttsn_gw_config_get_auth_infos | ( | CC_MqttsnConfigHandle | config, |
CC_MqttsnAuthInfo * | buf, | ||
unsigned | bufLen | ||
) |
Read clients' authentication information into a buffer.
[in] | config | Handle returned by cc_mqttsn_gw_config_alloc() function. |
[out] | buf | Buffer to write information into |
[in] | bufLen | Max number of element to write into the buffer. |
unsigned cc_mqttsn_gw_config_get_predefined_topics | ( | CC_MqttsnConfigHandle | config, |
CC_MqttsnPredefinedTopicInfo * | buf, | ||
unsigned | bufLen | ||
) |
Read information about available topic IDs into a buffer.
[in] | config | Handle returned by cc_mqttsn_gw_config_alloc() function. |
[out] | buf | Buffer to write information into |
[in] | bufLen | Max number of element to write into the buffer. |
const char * cc_mqttsn_gw_config_get_value | ( | CC_MqttsnConfigHandle | config, |
const char * | key, | ||
unsigned | idx | ||
) |
Get the available value for the configuration key.
The key is the first word in the configuration line, and the value is rest of the string until the end of the line. If the configuration value doesn't exist, NULL is returned.
unsigned char cc_mqttsn_gw_config_id | ( | CC_MqttsnConfigHandle | config | ) |
Get gateway numeric ID.
Default value is 0.
[in] | config | Handle returned by cc_mqttsn_gw_config_alloc() function. |
const char * cc_mqttsn_gw_config_log_file | ( | CC_MqttsnConfigHandle | config | ) |
Get log file.
Expected to be an aboslute file path or one of the special values: "stdout", "stderr". Defaults to "stdout"
void cc_mqttsn_gw_config_parse | ( | CC_MqttsnConfigHandle | config, |
const char * | str | ||
) |
Parse configuration contents from string.
Updates the default values with values read from string buffer.
[in] | config | Handle returned by cc_mqttsn_gw_config_alloc() function. |
[in] | str | Pointer to the string buffer, containing configuration. |
unsigned cc_mqttsn_gw_config_pub_only_keep_alive | ( | CC_MqttsnConfigHandle | config | ) |
Get keep alive period for publish only clients.
Default value is 60 seconds.
[in] | config | Handle returned by cc_mqttsn_gw_config_alloc() function. |
bool cc_mqttsn_gw_config_read | ( | CC_MqttsnConfigHandle | config, |
const char * | filename | ||
) |
Read configuration file.
Updates the default values with values read from the file.
[in] | config | Handle returned by cc_mqttsn_gw_config_alloc() function. |
[in] | filename | Path to the file. |
unsigned cc_mqttsn_gw_config_retry_count | ( | CC_MqttsnConfigHandle | config | ) |
Get number of retry attempts.
Default value is 3.
[in] | config | Handle returned by cc_mqttsn_gw_config_alloc() function. |
unsigned cc_mqttsn_gw_config_retry_period | ( | CC_MqttsnConfigHandle | config | ) |
Get retry period.
Default value is 10 seconds.
[in] | config | Handle returned by cc_mqttsn_gw_config_alloc() function. |
unsigned cc_mqttsn_gw_config_sleeping_client_msg_limit | ( | CC_MqttsnConfigHandle | config | ) |
Get limit for max number of messages to accumulate for sleeping clients.
Default value is MAX_UINT seconds.
[in] | config | Handle returned by cc_mqttsn_gw_config_alloc() function. |
void cc_mqttsn_gw_config_topic_id_alloc_range | ( | CC_MqttsnConfigHandle | config, |
unsigned short * | min, | ||
unsigned short * | max | ||
) |
Get range of allowed topic IDs for allocation.
Default range is [1, 0xfffe]
[in] | config | Handle returned by cc_mqttsn_gw_config_alloc() function. |
[out] | min | Minimal allowed topic ID. |
[out] | max | Maximal allowed topic ID. |
unsigned cc_mqttsn_gw_config_values_count | ( | CC_MqttsnConfigHandle | config, |
const char * | key | ||
) |
Get number of available configuration values for the provided key.
The key is the first word in the configuration line, and the value is rest of the string until the end of the line.
[in] | config | Handle returned by cc_mqttsn_gw_config_alloc() function. |
[in] | key | Key string. |
void cc_mqttsn_gw_free | ( | CC_MqttsnGatewayHandle | gw | ) |
Free allocated Gateway object.
[in] | gw | Handle returned by cc_mqttsn_gw_alloc() function. |
unsigned short cc_mqttsn_gw_get_advertise_period | ( | CC_MqttsnGatewayHandle | gw | ) |
Get current configuration of the advertise period.
[in] | gw | Handle returned by cc_mqttsn_gw_alloc() function. |
unsigned char cc_mqttsn_gw_get_id | ( | CC_MqttsnGatewayHandle | gw | ) |
Get current configuration of the numeric gateway id.
[in] | gw | Handle returned by cc_mqttsn_gw_alloc() function. |
bool cc_mqttsn_gw_session_add_predefined_topic | ( | CC_MqttsnSessionHandle | session, |
const char * | topic, | ||
unsigned short | topicId | ||
) |
Add predefined topic string and ID information.
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
[in] | topic | Topic string |
[in] | topicId | Numeric topic ID. |
CC_MqttsnSessionHandle cc_mqttsn_gw_session_alloc | ( | void | ) |
Allocate Session object.
The returned handle need to be passed as first parameter to all relevant functions. Note that the Session object is dynamically allocated and needs to be freed using cc_mqttsn_gw_session_free() function.
unsigned cc_mqttsn_gw_session_data_from_broker | ( | CC_MqttsnSessionHandle | session, |
const unsigned char * | buf, | ||
unsigned | bufLen | ||
) |
Provide data received from the broker for processing.
This call may cause invocation of some callbacks, such as request to cancel the currently running time measurement, send new message(s) and/or (re)start time measurement.
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
[in] | buf | Pointer to the buffer of data to process. |
[in] | bufLen | Number of bytes in the data buffer. |
unsigned cc_mqttsn_gw_session_data_from_client | ( | CC_MqttsnSessionHandle | session, |
const unsigned char * | buf, | ||
unsigned | bufLen | ||
) |
Provide data received from the client for processing.
This call may cause invocation of some callbacks, such as request to cancel the currently running time measurement, send new message(s) and/or (re)start time measurement.
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
[in] | buf | Pointer to the buffer of data to process. |
[in] | bufLen | Number of bytes in the data buffer. |
void cc_mqttsn_gw_session_free | ( | CC_MqttsnSessionHandle | session | ) |
Free allocated Session object.
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
bool cc_mqttsn_gw_session_get_broker_connected | ( | CC_MqttsnSessionHandle | session | ) |
Get currently recorded broker connection status.
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
const char * cc_mqttsn_gw_session_get_default_client_id | ( | CC_MqttsnSessionHandle | session | ) |
Get current default client ID configuration.
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
unsigned char cc_mqttsn_gw_session_get_id | ( | CC_MqttsnSessionHandle | session | ) |
Get current gateway numeric ID configuration.
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
unsigned cc_mqttsn_gw_session_get_pub_only_keep_alive | ( | CC_MqttsnSessionHandle | session | ) |
Get current configuration of the default "keep alive" period for "publish only" clients.
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
unsigned cc_mqttsn_gw_session_get_retry_count | ( | CC_MqttsnSessionHandle | session | ) |
Get the current configuration of the retry count.
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
unsigned cc_mqttsn_gw_session_get_retry_period | ( | CC_MqttsnSessionHandle | session | ) |
Get the current configuration of the retry period.
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
unsigned long long cc_mqttsn_gw_session_get_sleeping_client_msg_limit | ( | CC_MqttsnSessionHandle | session | ) |
Get currenly configured limit to pending messages being accumulated for the sleeping client.
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
void cc_mqttsn_gw_session_set_auth_info_req_cb | ( | CC_MqttsnSessionHandle | session, |
CC_MqttsnSessionAuthInfoReqCb | cb, | ||
void * | data | ||
) |
Set the callback to be used to request authentication information for specific client.
This is an optional callback. It can be used when there is a need to provide authentication details (username/password) for specific clients.
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
[in] | cb | Pointer to callback function |
[in] | data | Pointer to any user data, will be passed back as first parameter to the callback. |
void cc_mqttsn_gw_session_set_broker_connected | ( | CC_MqttsnSessionHandle | session, |
bool | connected | ||
) |
Notify the Session object about broker being connected / disconnected.
The report of broker being connected or disconnected must be performed only when the session's operation has been successfully started (see cc_mqttsn_gw_session_start()). Otherwise the call to this function gets ignored.
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
[in] | connected | Connection status - true means connected, false disconnected. |
void cc_mqttsn_gw_session_set_broker_reconnect_req_cb | ( | CC_MqttsnSessionHandle | session, |
CC_MqttsnSessionBrokerReconnectReqCb | cb, | ||
void * | data | ||
) |
Set the callback to be invoked when the Session needs to close existing TCP/IP connection to the broker and open a new one.
This is a must have callback, without it the object can not be started (see cc_mqttsn_gw_session_start()).
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
[in] | cb | Pointer to callback function |
[in] | data | Pointer to any user data, will be passed back as first parameter to the callback. |
void cc_mqttsn_gw_session_set_cancel_tick_cb | ( | CC_MqttsnSessionHandle | session, |
CC_MqttsnSessionCancelTickReqCb | cb, | ||
void * | data | ||
) |
Set the callback to be invoked when previously requested time measurement needs to be cancelled.
This is a must have callback, without it the object can not be started (see cc_mqttsn_gw_session_start()).
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
[in] | cb | Pointer to callback function |
[in] | data | Pointer to any user data, will be passed back as first parameter to the callback. |
void cc_mqttsn_gw_session_set_client_connect_report_cb | ( | CC_MqttsnSessionHandle | session, |
CC_MqttsnSessionClientConnectReportCb | cb, | ||
void * | data | ||
) |
Set the callback to be invoked when MQTT-SN client is successfully connected to the broker.
This is an optional callback. It can be used when there is a need to provide client specific configuration, such as predefined topic IDs, valid only for specific client.
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
[in] | cb | Pointer to callback function |
[in] | data | Pointer to any user data, will be passed back as first parameter to the callback. |
void cc_mqttsn_gw_session_set_default_client_id | ( | CC_MqttsnSessionHandle | session, |
const char * | clientId | ||
) |
Provide default client ID for clients that report empty one in their attempt to connect.
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
[in] | clientId | Default client ID string. |
void cc_mqttsn_gw_session_set_error_report_cb | ( | CC_MqttsnSessionHandle | session, |
CC_MqttsnSessionErrorReportCb | cb, | ||
void * | data | ||
) |
Set the callback to be used to report error messages detected by the session.
This is an optional callback.
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
[in] | cb | Pointer to callback function |
[in] | data | Pointer to any user data, will be passed back as first parameter to the callback. |
void cc_mqttsn_gw_session_set_fwd_enc_session_created_cb | ( | CC_MqttsnSessionHandle | session, |
CC_MqttsnSessionFwdEncSessionCreatedCb | cb, | ||
void * | data | ||
) |
Set the callback to be invoked when the forwarding encapsulation session is detected and to notify application about such session creation.
When not set, the forwarding enapsulation messages will be ignored
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
[in] | cb | Pointer to callback function |
[in] | data | Pointer to any user data, will be passed back as first parameter to the callback. |
void cc_mqttsn_gw_session_set_fwd_enc_session_deleted_cb | ( | CC_MqttsnSessionHandle | session, |
CC_MqttsnSessionFwdEncSessionDeletedCb | cb, | ||
void * | data | ||
) |
Set the callback to be invoked when the forwarding encapsulation session is about to be deleted.
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
[in] | cb | Pointer to callback function |
[in] | data | Pointer to any user data, will be passed back as first parameter to the callback. |
void cc_mqttsn_gw_session_set_id | ( | CC_MqttsnSessionHandle | session, |
unsigned char | id | ||
) |
Set gateway numeric ID to be reported when requested.
If not set, default value 0 is assumed.
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
[in] | id | Gateway numeric ID. |
void cc_mqttsn_gw_session_set_pub_only_keep_alive | ( | CC_MqttsnSessionHandle | session, |
unsigned | value | ||
) |
Provide default "keep alive" period for "publish only" clients, that do not make an attempt to connect to the gateway.
MQTT-SN protocol allows "publish only" clients that don't make any attempt to connect to the gateway/broker and send all their messages with QoS=-1. In this case, the gateway must connect to the broker on behalf of the "publish only" client. Such connection attempt requires to specify "keep alive" period. Use this function to set the value.
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
[in] | value | Max number of seconds between messages the "publish only" client is going to send. |
void cc_mqttsn_gw_session_set_retry_count | ( | CC_MqttsnSessionHandle | session, |
unsigned | value | ||
) |
Set number of retry attempts to perform before abandoning attempt to send unacknowledged message.
Some messages, may require acknowledgement by the client and/or broker. The amount of retry attempts before abandoning the attempt to deliver the message may be specified using this function. The default value is 3.
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
[in] | value | Number of retry attempts. |
void cc_mqttsn_gw_session_set_retry_period | ( | CC_MqttsnSessionHandle | session, |
unsigned | value | ||
) |
Set retry period to wait between resending unacknowledged message to the client and/or broker.
Some messages, may require acknowledgement by the client and/or broker. The delay (in seconds) between such attempts to resend the message may be specified using this function. The default value is 10 seconds.
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
[in] | value | Number of seconds to wait before making an attempt to resend. |
void cc_mqttsn_gw_session_set_send_data_to_broker_cb | ( | CC_MqttsnSessionHandle | session, |
CC_MqttsnSessionBrokerSendDataReqCb | cb, | ||
void * | data | ||
) |
Set the callback to be invoked when new data needs to be sent to the broker.
This is a must have callback, without it the object can not be started (see cc_mqttsn_gw_session_start()).
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
[in] | cb | Pointer to callback function |
[in] | data | Pointer to any user data, will be passed back as first parameter to the callback. |
void cc_mqttsn_gw_session_set_send_data_to_client_cb | ( | CC_MqttsnSessionHandle | session, |
CC_MqttsnSessionClientSendDataReqCb | cb, | ||
void * | data | ||
) |
Set the callback to be invoked when new data needs to be sent to the client.
This is a must have callback, without it the object can not be started (see cc_mqttsn_gw_session_start()).
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
[in] | cb | Pointer to callback function |
[in] | data | Pointer to any user data, will be passed back as first parameter to the callback. |
void cc_mqttsn_gw_session_set_sleeping_client_msg_limit | ( | CC_MqttsnSessionHandle | session, |
unsigned long long | value | ||
) |
Provide limit to number pending messages being accumulated for the sleeping client.
When client is known to be in "ASLEEP" state, the gateway must accumulate all the messages the broker sends until client wakes up or explicitly requests to send them. This function may be used to limit amount of such messages to prevent acquiring lots of RAM by the gateway application.
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
[in] | value | Max number of pending messages. |
void cc_mqttsn_gw_session_set_term_req_cb | ( | CC_MqttsnSessionHandle | session, |
CC_MqttsnSessionTermReqCb | cb, | ||
void * | data | ||
) |
Set the callback to be invoked when the Session needs to be terminated and the calling Session object deleted.
This is a must have callback, without it the object can not be started (see cc_mqttsn_gw_session_start()).
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
[in] | cb | Pointer to callback function |
[in] | data | Pointer to any user data, will be passed back as first parameter to the callback. |
void cc_mqttsn_gw_session_set_tick_req_cb | ( | CC_MqttsnSessionHandle | session, |
CC_MqttsnSessionTickReqCb | cb, | ||
void * | data | ||
) |
Set the callback to be invoked when new time measurement is required.
This is a must have callback, without it the object can not be started (see cc_mqttsn_gw_session_start()).
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
[in] | cb | Pointer to callback function |
[in] | data | Pointer to any user data, will be passed back as first parameter to the callback. |
bool cc_mqttsn_gw_session_set_topic_id_alloc_range | ( | CC_MqttsnSessionHandle | session, |
unsigned short | minTopicId, | ||
unsigned short | maxTopicId | ||
) |
Limit range of topic IDs allocated for newly registered topics.
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
[in] | minTopicId | Min topic ID. |
[in] | maxTopicId | Max topic ID. |
bool cc_mqttsn_gw_session_start | ( | CC_MqttsnSessionHandle | session | ) |
Start the Session's object's operation.
The function will check whether all necessary callbacks have been set.
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
void cc_mqttsn_gw_session_stop | ( | CC_MqttsnSessionHandle | session | ) |
Stop the operation of the Session object.
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
void cc_mqttsn_gw_session_tick | ( | CC_MqttsnSessionHandle | session | ) |
Notify the Session object about requested time period expiry.
This function needs to be called from the driving code after the requested time measurement has expired.
[in] | session | Handle returned by cc_mqttsn_gw_session_alloc() function. |
void cc_mqttsn_gw_set_advertise_broadcast_req_cb | ( | CC_MqttsnGatewayHandle | gw, |
CC_MqttsnGwBroadcastReqCb | cb, | ||
void * | data | ||
) |
Set callback that requests to send serialised ADVERTISE message.
[in] | gw | Handle returned by cc_mqttsn_gw_alloc() function. |
[in] | cb | Pointer to callback function |
[in] | data | Any user data, to be passed as first parameter to the callback |
void cc_mqttsn_gw_set_advertise_period | ( | CC_MqttsnGatewayHandle | gw, |
unsigned short | value | ||
) |
Set the advertise period.
[in] | gw | Handle returned by cc_mqttsn_gw_alloc() function. |
[in] | value | Advertise period in seconds. |
void cc_mqttsn_gw_set_id | ( | CC_MqttsnGatewayHandle | gw, |
unsigned char | id | ||
) |
Set the numeric gateway ID.
[in] | gw | Handle returned by cc_mqttsn_gw_alloc() function. |
[in] | id | Numeric gateway ID. |
void cc_mqttsn_gw_set_tick_req_cb | ( | CC_MqttsnGatewayHandle | gw, |
CC_MqttsnGwTickReqCb | cb, | ||
void * | data | ||
) |
Set callback that requests to perform time measurement.
The Gateway object will invoke the callback to request time measurement. When requested time expires, the driving code is responsible to call cc_mqttsn_gw_tick().
[in] | gw | Handle returned by cc_mqttsn_gw_alloc() function. |
[in] | cb | Pointer to callback function |
[in] | data | Any user data, to be passed as first parameter to the callback |
bool cc_mqttsn_gw_start | ( | CC_MqttsnGatewayHandle | gw | ) |
Start operation of the Gateway object.
The function check whether all callbacks and proper advertise period were set properly and start the operation if everything is in place. If start is successful, the callbacks of requesting data send as well as data measurement request will be invoked.
[in] | gw | Handle returned by cc_mqttsn_gw_alloc() function. |
void cc_mqttsn_gw_stop | ( | CC_MqttsnGatewayHandle | gw | ) |
Stop operation of the Gateway object.
[in] | gw | Handle returned by cc_mqttsn_gw_alloc() function. |
void cc_mqttsn_gw_tick | ( | CC_MqttsnGatewayHandle | gw | ) |
Notify the Gateway object about requested time expiry.
Invocation of this function will cause invocation of the send data request callback as well as new time measurement request.
[in] | gw | Handle returned by cc_mqttsn_gw_alloc() function. |