MQTT-SN Gateway Library
Library that allows implementation of MQTT-SN gateway.
Classes | Typedefs | Functions
gateway_all.h File Reference

C interface for MQTT-SN Gateway library. More...

Go to the source code of this file.

Classes

struct  CC_MqttsnGatewayHandle
 Handle for gateway object used in all cc_mqttsn_gw_* functions. More...
 
struct  CC_MqttsnSessionHandle
 Handle for session object used in all cc_mqttsn_gw_session_* functions. More...
 
struct  CC_MqttsnPredefinedTopicInfo
 Info about single predefined topic. More...
 
struct  CC_MqttsnAuthInfo
 Authentication infor for a single client. More...
 
struct  CC_MqttsnConfigHandle
 Handle for configuration object used in all cc_mqttsn_gw_config_* functions. More...
 

Typedefs

typedef void(* CC_MqttsnGwTickReqCb) (void *userData, unsigned duration)
 Type of callback function, to be used to request time measurement for the Gateway object. More...
 
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. More...
 
typedef void(* CC_MqttsnSessionTickReqCb) (void *userData, unsigned duration)
 Type of callback, used to request new time measurement. More...
 
typedef unsigned(* CC_MqttsnSessionCancelTickReqCb) (void *userData)
 Type of callback, used to cancel existing time measurement. More...
 
typedef void(* CC_MqttsnSessionSendDataReqCb) (void *userData, const unsigned char *buf, unsigned bufLen)
 Type of callback, used to request delivery of serialised message to the client or broker. More...
 
typedef void(* CC_MqttsnSessionTermReqCb) (void *userData)
 Type of callback, used to request session termination. More...
 
typedef void(* CC_MqttsnSessionBrokerReconnectReqCb) (void *userData)
 Type of callback used to request reconnection to the broker. More...
 
typedef void(* CC_MqttsnSessionClientConnectReportCb) (void *userData, const char *clientId)
 Type of callback used to report client ID of the newly connected MQTT-SN client. More...
 
typedef void(* CC_MqttsnSessionAuthInfoReqCb) (void *userData, 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. More...
 

Functions

CC_MqttsnGatewayHandle cc_mqttsn_gw_alloc (void)
 Allocate Gateway object. More...
 
void cc_mqttsn_gw_free (CC_MqttsnGatewayHandle gw)
 Free allocated Gateway object. More...
 
void cc_mqttsn_gw_set_advertise_period (CC_MqttsnGatewayHandle gw, unsigned short value)
 Set the advertise period. More...
 
void cc_mqttsn_gw_set_id (CC_MqttsnGatewayHandle gw, unsigned char id)
 Set the numeric gateway ID. More...
 
void cc_mqttsn_gw_set_tick_req_cb (CC_MqttsnGatewayHandle gw, CC_MqttsnGwTickReqCb cb, void *data)
 Set callback that requests to perform time measurement. More...
 
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. More...
 
bool cc_mqttsn_gw_start (CC_MqttsnGatewayHandle gw)
 Start operation of the Gateway object. More...
 
void cc_mqttsn_gw_stop (CC_MqttsnGatewayHandle gw)
 Stop operation of the Gateway object. More...
 
void cc_mqttsn_gw_tick (CC_MqttsnGatewayHandle gw)
 Notify the Gateway object about requested time expiry. More...
 
CC_MqttsnSessionHandle cc_mqttsn_gw_session_alloc (void)
 Allocate Session object. More...
 
void cc_mqttsn_gw_session_free (CC_MqttsnSessionHandle session)
 Free allocated Session object. More...
 
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. More...
 
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. More...
 
void cc_mqttsn_gw_session_set_send_data_to_client_cb (CC_MqttsnSessionHandle session, CC_MqttsnSessionSendDataReqCb cb, void *data)
 Set the callback to be invoked when new data needs to be sent to the client. More...
 
void cc_mqttsn_gw_session_set_send_data_to_broker_cb (CC_MqttsnSessionHandle session, CC_MqttsnSessionSendDataReqCb cb, void *data)
 Set the callback to be invoked when new data needs to be sent to the broker. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
void cc_mqttsn_gw_session_set_id (CC_MqttsnSessionHandle session, unsigned char id)
 Set gateway numeric ID to be reported when requested. More...
 
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. More...
 
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. More...
 
void cc_mqttsn_gw_session_set_sleeping_client_msg_limit (CC_MqttsnSessionHandle session, unsigned value)
 Provide limit to number pending messages being accumulated for the sleeping client. More...
 
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. More...
 
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. More...
 
bool cc_mqttsn_gw_session_start (CC_MqttsnSessionHandle session)
 Start the Session's object's operation. More...
 
void cc_mqttsn_gw_session_stop (CC_MqttsnSessionHandle session)
 Stop the operation of the Session object. More...
 
void cc_mqttsn_gw_session_tick (CC_MqttsnSessionHandle session)
 Notify the Session object about requested time period expiry. More...
 
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. More...
 
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. More...
 
void cc_mqttsn_gw_session_broker_connected (CC_MqttsnSessionHandle session, bool connected)
 Notify the Session object about broker being connected / disconnected. More...
 
bool cc_mqttsn_gw_session_add_predefined_topic (CC_MqttsnSessionHandle session, const char *topic, unsigned short topicId)
 Add predefined topic string and ID information. More...
 
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. More...
 
CC_MqttsnConfigHandle cc_mqttsn_gw_config_alloc (void)
 Allocate Config object. More...
 
void cc_mqttsn_gw_config_free (CC_MqttsnConfigHandle config)
 Free allocated Config object. More...
 
void cc_mqttsn_gw_config_parse (CC_MqttsnConfigHandle config, const char *str)
 Parse configuration contents from string. More...
 
bool cc_mqttsn_gw_config_read (CC_MqttsnConfigHandle config, const char *filename)
 Read configuration file. More...
 
unsigned char cc_mqttsn_gw_config_id (CC_MqttsnConfigHandle config)
 Get gateway numeric ID. More...
 
unsigned short cc_mqttsn_gw_config_advertise_period (CC_MqttsnConfigHandle config)
 Get advertise period. More...
 
unsigned cc_mqttsn_gw_config_retry_period (CC_MqttsnConfigHandle config)
 Get retry period. More...
 
unsigned cc_mqttsn_gw_config_retry_count (CC_MqttsnConfigHandle config)
 Get number of retry attempts. More...
 
const char * cc_mqttsn_gw_config_default_client_id (CC_MqttsnConfigHandle config)
 Get default client ID. More...
 
unsigned cc_mqttsn_gw_config_pub_only_keep_alive (CC_MqttsnConfigHandle config)
 Get keep alive period for publish only clients. More...
 
unsigned cc_mqttsn_gw_config_sleeping_client_msg_limit (CC_MqttsnConfigHandle config)
 Get limit for max number of messages to accumulate for sleeping clients. More...
 
unsigned cc_mqttsn_gw_config_available_predefined_topics (CC_MqttsnConfigHandle config)
 Get number of available predefined topic IDs. More...
 
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. More...
 
unsigned cc_mqttsn_gw_config_available_auth_infos (CC_MqttsnConfigHandle config)
 Get number of available authenticatin infos for all the clients. More...
 
unsigned cc_mqttsn_gw_config_get_auth_infos (CC_MqttsnConfigHandle config, CC_MqttsnAuthInfo *buf, unsigned bufLen)
 Read clients' authentication information into a buffer. More...
 
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. More...
 
const char * cc_mqttsn_gw_config_broker_address (CC_MqttsnConfigHandle config)
 Get TCP/IP address of the broker. More...
 
unsigned short cc_mqttsn_gw_config_broker_port (CC_MqttsnConfigHandle config)
 Get TCP/IP port of the broker. More...
 
unsigned cc_mqttsn_gw_config_values_count (CC_MqttsnConfigHandle config, const char *key)
 Get number of available configuration values for the provided key. More...
 
const char * cc_mqttsn_gw_config_get_value (CC_MqttsnConfigHandle config, const char *key, unsigned idx)
 Get the available value for the configuration key. More...
 

Detailed Description

C interface for MQTT-SN Gateway library.

Typedef Documentation

◆ CC_MqttsnGwBroadcastReqCb

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().

Parameters
[in]userDataUser data passed as the last parameter to the setting function.
[in]bufPointer to the buffer of data, that needs to be sent.
[in]bufLenNumber of bytes in the buffer.
Note
The provided buffer resides in private data structres of the Gateway object and can be updated right after the callback function returns. The driving code may require to copy the buffer to its own data structures and preserve it intact until send over I/O link is complete.

◆ CC_MqttsnGwTickReqCb

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.

Parameters
[in]userDataUser data passed as the last parameter to the setting function.
[in]durationRequested time measurement duration in milliseconds.

◆ CC_MqttsnSessionAuthInfoReqCb

typedef void(* CC_MqttsnSessionAuthInfoReqCb) (void *userData, 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.

Parameters
[in]userDataUser data passed as the last parameter to the setting function.
[in]clientIdClient ID
[out]usernameUsername string
[out]passwordBinary password buffer
[out]passwordLenLength of the binary password

◆ CC_MqttsnSessionBrokerReconnectReqCb

typedef void(* CC_MqttsnSessionBrokerReconnectReqCb) (void *userData)

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.

Parameters
[in]userDataUser data passed as the last parameter to the setting function.

◆ CC_MqttsnSessionCancelTickReqCb

typedef unsigned(* CC_MqttsnSessionCancelTickReqCb) (void *userData)

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.

Parameters
[in]userDataUser data passed as the last parameter to the setting function.
Returns
Number of elapsed milliseconds since last timer programming request.

◆ CC_MqttsnSessionClientConnectReportCb

typedef void(* CC_MqttsnSessionClientConnectReportCb) (void *userData, 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.

Parameters
[in]userDataUser data passed as the last parameter to the setting function.
[in]clientIdClient ID

◆ CC_MqttsnSessionSendDataReqCb

typedef void(* CC_MqttsnSessionSendDataReqCb) (void *userData, const unsigned char *buf, unsigned bufLen)

Type of callback, used to request delivery of serialised message to the client or broker.

Parameters
[in]userDataUser data passed as the last parameter to the setting function.
[in]bufBuffer containing serialised message.
[in]bufLenNumber of bytes in the buffer

◆ CC_MqttsnSessionTermReqCb

typedef void(* CC_MqttsnSessionTermReqCb) (void *userData)

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.

Parameters
[in]userDataUser data passed as the last parameter to the setting function.

◆ CC_MqttsnSessionTickReqCb

typedef void(* CC_MqttsnSessionTickReqCb) (void *userData, 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.

Parameters
[in]userDataUser data passed as the last parameter to the setting function.
[in]durationNumber of milliseconds to measure.

Function Documentation

◆ cc_mqttsn_gw_alloc()

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.

Returns
Handler to the allocated Gateway object.

◆ cc_mqttsn_gw_config_advertise_period()

unsigned short cc_mqttsn_gw_config_advertise_period ( CC_MqttsnConfigHandle  config)

Get advertise period.

Default value is 900 seconds (15 minutes).

Parameters
[in]configHandle returned by cc_mqttsn_gw_config_alloc() function.
Returns
Advertise period in seconds.

◆ cc_mqttsn_gw_config_alloc()

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.

Returns
Handler to the allocated Config object.

◆ cc_mqttsn_gw_config_available_auth_infos()

unsigned cc_mqttsn_gw_config_available_auth_infos ( CC_MqttsnConfigHandle  config)

Get number of available authenticatin infos for all the clients.

Parameters
[in]configHandle returned by cc_mqttsn_gw_config_alloc() function.

◆ cc_mqttsn_gw_config_available_predefined_topics()

unsigned cc_mqttsn_gw_config_available_predefined_topics ( CC_MqttsnConfigHandle  config)

Get number of available predefined topic IDs.

Parameters
[in]configHandle returned by cc_mqttsn_gw_config_alloc() function.

◆ cc_mqttsn_gw_config_broker_address()

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

Parameters
[in]configHandle returned by cc_mqttsn_gw_config_alloc() function.

◆ cc_mqttsn_gw_config_broker_port()

unsigned short cc_mqttsn_gw_config_broker_port ( CC_MqttsnConfigHandle  config)

Get TCP/IP port of the broker.

Default value is 1883

Parameters
[in]configHandle returned by cc_mqttsn_gw_config_alloc() function.

◆ cc_mqttsn_gw_config_default_client_id()

const char* cc_mqttsn_gw_config_default_client_id ( CC_MqttsnConfigHandle  config)

Get default client ID.

Default value is empty string.

Parameters
[in]configHandle returned by cc_mqttsn_gw_config_alloc() function.
Returns
Default client ID.

◆ cc_mqttsn_gw_config_free()

void cc_mqttsn_gw_config_free ( CC_MqttsnConfigHandle  config)

Free allocated Config object.

Parameters
[in]configHandle returned by cc_mqttsn_gw_config_alloc() function.

◆ cc_mqttsn_gw_config_get_auth_infos()

unsigned cc_mqttsn_gw_config_get_auth_infos ( CC_MqttsnConfigHandle  config,
CC_MqttsnAuthInfo buf,
unsigned  bufLen 
)

Read clients' authentication information into a buffer.

Parameters
[in]configHandle returned by cc_mqttsn_gw_config_alloc() function.
[out]bufBuffer to write information into
[in]bufLenMax number of element to write into the buffer.
Returns
Actual number of elements that have been written into a buffer.

◆ cc_mqttsn_gw_config_get_predefined_topics()

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.

Parameters
[in]configHandle returned by cc_mqttsn_gw_config_alloc() function.
[out]bufBuffer to write information into
[in]bufLenMax number of element to write into the buffer.
Returns
Actual number of elements that have been written into a buffer.

◆ cc_mqttsn_gw_config_get_value()

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.

◆ cc_mqttsn_gw_config_id()

unsigned char cc_mqttsn_gw_config_id ( CC_MqttsnConfigHandle  config)

Get gateway numeric ID.

Default value is 0.

Parameters
[in]configHandle returned by cc_mqttsn_gw_config_alloc() function.
Returns
Numeric gateway ID.

◆ cc_mqttsn_gw_config_parse()

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.

Parameters
[in]configHandle returned by cc_mqttsn_gw_config_alloc() function.
[in]strPointer to the string buffer, containing configuration.

◆ cc_mqttsn_gw_config_pub_only_keep_alive()

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.

Parameters
[in]configHandle returned by cc_mqttsn_gw_config_alloc() function.
Returns
Keep alive period for publish only clients.

◆ cc_mqttsn_gw_config_read()

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.

Parameters
[in]configHandle returned by cc_mqttsn_gw_config_alloc() function.
[in]filenamePath to the file.

◆ cc_mqttsn_gw_config_retry_count()

unsigned cc_mqttsn_gw_config_retry_count ( CC_MqttsnConfigHandle  config)

Get number of retry attempts.

Default value is 3.

Parameters
[in]configHandle returned by cc_mqttsn_gw_config_alloc() function.
Returns
Number of retry attempts

◆ cc_mqttsn_gw_config_retry_period()

unsigned cc_mqttsn_gw_config_retry_period ( CC_MqttsnConfigHandle  config)

Get retry period.

Default value is 10 seconds.

Parameters
[in]configHandle returned by cc_mqttsn_gw_config_alloc() function.
Returns
Retry period in seconds

◆ cc_mqttsn_gw_config_sleeping_client_msg_limit()

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.

Parameters
[in]configHandle returned by cc_mqttsn_gw_config_alloc() function.
Returns
Max number of accumulated messages for sleeping clients.

◆ cc_mqttsn_gw_config_topic_id_alloc_range()

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]

Parameters
[in]configHandle returned by cc_mqttsn_gw_config_alloc() function.
[out]minMinimal allowed topic ID.
[out]maxMaximal allowed topic ID.

◆ cc_mqttsn_gw_config_values_count()

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.

Parameters
[in]configHandle returned by cc_mqttsn_gw_config_alloc() function.
[in]keyKey string.

◆ cc_mqttsn_gw_free()

void cc_mqttsn_gw_free ( CC_MqttsnGatewayHandle  gw)

Free allocated Gateway object.

Parameters
[in]gwHandle returned by cc_mqttsn_gw_alloc() function.

◆ cc_mqttsn_gw_session_add_predefined_topic()

bool cc_mqttsn_gw_session_add_predefined_topic ( CC_MqttsnSessionHandle  session,
const char *  topic,
unsigned short  topicId 
)

Add predefined topic string and ID information.

Parameters
[in]sessionHandle returned by cc_mqttsn_gw_session_alloc() function.
[in]topicTopic string
[in]topicIdNumeric topic ID.
Returns
success/failure status

◆ cc_mqttsn_gw_session_alloc()

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.

Returns
Handler to the allocated Session object.

◆ cc_mqttsn_gw_session_broker_connected()

void cc_mqttsn_gw_session_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.

Parameters
[in]sessionHandle returned by cc_mqttsn_gw_session_alloc() function.
[in]connectedConnection status - true means connected, false disconnected.

◆ cc_mqttsn_gw_session_data_from_broker()

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.

Parameters
[in]sessionHandle returned by cc_mqttsn_gw_session_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_mqttsn_gw_session_data_from_client()

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.

Parameters
[in]sessionHandle returned by cc_mqttsn_gw_session_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_mqttsn_gw_session_free()

void cc_mqttsn_gw_session_free ( CC_MqttsnSessionHandle  session)

Free allocated Session object.

Parameters
[in]sessionHandle returned by cc_mqttsn_gw_session_alloc() function.

◆ cc_mqttsn_gw_session_set_auth_info_req_cb()

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.

Parameters
[in]sessionHandle returned by cc_mqttsn_gw_session_alloc() function.
[in]cbPointer to callback function
[in]dataPointer to any user data, will be passed back as first parameter to the callback.

◆ cc_mqttsn_gw_session_set_broker_reconnect_req_cb()

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()).

Parameters
[in]sessionHandle returned by cc_mqttsn_gw_session_alloc() function.
[in]cbPointer to callback function
[in]dataPointer to any user data, will be passed back as first parameter to the callback.

◆ cc_mqttsn_gw_session_set_cancel_tick_cb()

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()).

Parameters
[in]sessionHandle returned by cc_mqttsn_gw_session_alloc() function.
[in]cbPointer to callback function
[in]dataPointer to any user data, will be passed back as first parameter to the callback.

◆ cc_mqttsn_gw_session_set_client_connect_report_cb()

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.

Parameters
[in]sessionHandle returned by cc_mqttsn_gw_session_alloc() function.
[in]cbPointer to callback function
[in]dataPointer to any user data, will be passed back as first parameter to the callback.

◆ cc_mqttsn_gw_session_set_default_client_id()

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.

Parameters
[in]sessionHandle returned by cc_mqttsn_gw_session_alloc() function.
[in]clientIdDefault client ID string.

◆ cc_mqttsn_gw_session_set_id()

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.

Parameters
[in]sessionHandle returned by cc_mqttsn_gw_session_alloc() function.
[in]idGateway numeric ID.

◆ cc_mqttsn_gw_session_set_pub_only_keep_alive()

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.

Parameters
[in]sessionHandle returned by cc_mqttsn_gw_session_alloc() function.
[in]valueMax number of seconds between messages the "publish only" client is going to send.

◆ cc_mqttsn_gw_session_set_retry_count()

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.

Parameters
[in]sessionHandle returned by cc_mqttsn_gw_session_alloc() function.
[in]valueNumber of retry attempts.

◆ cc_mqttsn_gw_session_set_retry_period()

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.

Parameters
[in]sessionHandle returned by cc_mqttsn_gw_session_alloc() function.
[in]valueNumber of seconds to wait before making an attempt to resend.

◆ cc_mqttsn_gw_session_set_send_data_to_broker_cb()

void cc_mqttsn_gw_session_set_send_data_to_broker_cb ( CC_MqttsnSessionHandle  session,
CC_MqttsnSessionSendDataReqCb  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()).

Parameters
[in]sessionHandle returned by cc_mqttsn_gw_session_alloc() function.
[in]cbPointer to callback function
[in]dataPointer to any user data, will be passed back as first parameter to the callback.

◆ cc_mqttsn_gw_session_set_send_data_to_client_cb()

void cc_mqttsn_gw_session_set_send_data_to_client_cb ( CC_MqttsnSessionHandle  session,
CC_MqttsnSessionSendDataReqCb  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()).

Parameters
[in]sessionHandle returned by cc_mqttsn_gw_session_alloc() function.
[in]cbPointer to callback function
[in]dataPointer to any user data, will be passed back as first parameter to the callback.

◆ cc_mqttsn_gw_session_set_sleeping_client_msg_limit()

void cc_mqttsn_gw_session_set_sleeping_client_msg_limit ( CC_MqttsnSessionHandle  session,
unsigned  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.

Parameters
[in]sessionHandle returned by cc_mqttsn_gw_session_alloc() function.
[in]valueMax number of pending messages.

◆ cc_mqttsn_gw_session_set_term_req_cb()

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()).

Parameters
[in]sessionHandle returned by cc_mqttsn_gw_session_alloc() function.
[in]cbPointer to callback function
[in]dataPointer to any user data, will be passed back as first parameter to the callback.

◆ cc_mqttsn_gw_session_set_tick_req_cb()

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()).

Parameters
[in]sessionHandle returned by cc_mqttsn_gw_session_alloc() function.
[in]cbPointer to callback function
[in]dataPointer to any user data, will be passed back as first parameter to the callback.

◆ cc_mqttsn_gw_session_set_topic_id_alloc_range()

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.

Parameters
[in]sessionHandle returned by cc_mqttsn_gw_session_alloc() function.
[in]minTopicIdMin topic ID.
[in]maxTopicIdMax topic ID.
Returns
success/failure status

◆ cc_mqttsn_gw_session_start()

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.

Parameters
[in]sessionHandle returned by cc_mqttsn_gw_session_alloc() function.
Returns
true if the operation has been successfully started, false in case some necessary callback hasn't been set.

◆ cc_mqttsn_gw_session_stop()

void cc_mqttsn_gw_session_stop ( CC_MqttsnSessionHandle  session)

Stop the operation of the Session object.

Parameters
[in]sessionHandle returned by cc_mqttsn_gw_session_alloc() function.

◆ cc_mqttsn_gw_session_tick()

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.

Parameters
[in]sessionHandle returned by cc_mqttsn_gw_session_alloc() function.

◆ cc_mqttsn_gw_set_advertise_broadcast_req_cb()

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.

Parameters
[in]gwHandle returned by cc_mqttsn_gw_alloc() function.
[in]cbPointer to callback function
[in]dataAny user data, to be passed as first parameter to the callback

◆ cc_mqttsn_gw_set_advertise_period()

void cc_mqttsn_gw_set_advertise_period ( CC_MqttsnGatewayHandle  gw,
unsigned short  value 
)

Set the advertise period.

Parameters
[in]gwHandle returned by cc_mqttsn_gw_alloc() function.
[in]valueAdvertise period in seconds.

◆ cc_mqttsn_gw_set_id()

void cc_mqttsn_gw_set_id ( CC_MqttsnGatewayHandle  gw,
unsigned char  id 
)

Set the numeric gateway ID.

Parameters
[in]gwHandle returned by cc_mqttsn_gw_alloc() function.
[in]idNumeric gateway ID.

◆ cc_mqttsn_gw_set_tick_req_cb()

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().

Parameters
[in]gwHandle returned by cc_mqttsn_gw_alloc() function.
[in]cbPointer to callback function
[in]dataAny user data, to be passed as first parameter to the callback

◆ cc_mqttsn_gw_start()

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.

Parameters
[in]gwHandle returned by cc_mqttsn_gw_alloc() function.
Returns
true if the operation was successfully started, false otherwise.

◆ cc_mqttsn_gw_stop()

void cc_mqttsn_gw_stop ( CC_MqttsnGatewayHandle  gw)

Stop operation of the Gateway object.

Parameters
[in]gwHandle returned by cc_mqttsn_gw_alloc() function.

◆ cc_mqttsn_gw_tick()

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.

Parameters
[in]gwHandle returned by cc_mqttsn_gw_alloc() function.