MQTT-SN Client
MQTT-SN client library.
Classes | Macros | Typedefs | Enumerations
common.h File Reference

Common definition for MQTT-SN clients. More...

Go to the source code of this file.

Classes

struct  CC_MqttsnClientHandle
 Handler used to access client specific data structures. More...
 
struct  CC_MqttsnWillInfo
 Will Information. More...
 
struct  CC_MqttsnMessageInfo
 Incoming message information. More...
 

Macros

#define CC_MQTTSN_CLIENT_MAJOR_VERSION   1U
 Major verion of the library. More...
 
#define CC_MQTTSN_CLIENT_MINOR_VERSION   0U
 Minor verion of the library. More...
 
#define CC_MQTTSN_CLIENT_PATCH_VERSION   8U
 Patch level of the library. More...
 
#define CC_MQTTSN_CLIENT_MAKE_VERSION(major_, minor_, patch_)
 Macro to create numeric version as single unsigned number. More...
 
#define CC_MQTTSN_CLIENT_VERSION   CC_MQTTSN_CLIENT_MAKE_VERSION(CC_MQTTSN_CLIENT_MAJOR_VERSION, CC_MQTTSN_CLIENT_MINOR_VERSION, CC_MQTTSN_CLIENT_PATCH_VERSION)
 Version of the library as single numeric value. More...
 

Typedefs

typedef unsigned short CC_MqttsnTopicId
 Type used to hold Topic ID value. More...
 
typedef void(* CC_MqttsnNextTickProgramFn) (void *data, unsigned duration)
 Callback used to request time measurement. More...
 
typedef unsigned(* CC_MqttsnCancelNextTickWaitFn) (void *data)
 Callback used to request termination of existing time measurement. More...
 
typedef void(* CC_MqttsnSendOutputDataFn) (void *data, const unsigned char *buf, unsigned bufLen, bool broadcast)
 Callback used to request to send data to the gateway. More...
 
typedef void(* CC_MqttsnGwStatusReportFn) (void *data, unsigned char gwId, CC_MqttsnGwStatus status)
 Callback used to report gateway status. More...
 
typedef void(* CC_MqttsnGwDisconnectReportFn) (void *data)
 Callback used to report unsolicited disconnection of the gateway. More...
 
typedef void(* CC_MqttsnAsyncOpCompleteReportFn) (void *data, CC_MqttsnAsyncOpStatus status)
 Callback used to report completion of the asynchronous operation. More...
 
typedef void(* CC_MqttsnSubscribeCompleteReportFn) (void *data, CC_MqttsnAsyncOpStatus status, CC_MqttsnQoS qos)
 Callback used to report completion of the subscribe operation. More...
 
typedef void(* CC_MqttsnMessageReportFn) (void *data, const CC_MqttsnMessageInfo *msgInfo)
 Callback used to report incoming messages. More...
 

Enumerations

enum  CC_MqttsnQoS { CC_MqttsnQoS_NoGwPublish = -1 , CC_MqttsnQoS_AtMostOnceDelivery , CC_MqttsnQoS_AtLeastOnceDelivery , CC_MqttsnQoS_ExactlyOnceDelivery }
 Quality of Service. More...
 
enum  CC_MqttsnErrorCode {
  CC_MqttsnErrorCode_Success , CC_MqttsnErrorCode_AlreadyStarted , CC_MqttsnErrorCode_NotStarted , CC_MqttsnErrorCode_Busy ,
  CC_MqttsnErrorCode_AlreadyConnected , CC_MqttsnErrorCode_NotConnected , CC_MqttsnErrorCode_NotSleeping , CC_MqttsnErrorCode_BadParam
}
 Error code returned by various API functions. More...
 
enum  CC_MqttsnGwStatus { CC_MqttsnGwStatus_Invalid , CC_MqttsnGwStatus_Available , CC_MqttsnGwStatus_TimedOut , CC_MqttsnGwStatus_Discarded }
 Status of the gateway. More...
 
enum  CC_MqttsnAsyncOpStatus {
  CC_MqttsnAsyncOpStatus_Invalid , CC_MqttsnAsyncOpStatus_Successful , CC_MqttsnAsyncOpStatus_Congestion , CC_MqttsnAsyncOpStatus_InvalidId ,
  CC_MqttsnAsyncOpStatus_NotSupported , CC_MqttsnAsyncOpStatus_NoResponse , CC_MqttsnAsyncOpStatus_Aborted
}
 Status of the asynchronous operation. More...
 

Detailed Description

Common definition for MQTT-SN clients.

Macro Definition Documentation

◆ CC_MQTTSN_CLIENT_MAJOR_VERSION

#define CC_MQTTSN_CLIENT_MAJOR_VERSION   1U

Major verion of the library.

◆ CC_MQTTSN_CLIENT_MAKE_VERSION

#define CC_MQTTSN_CLIENT_MAKE_VERSION (   major_,
  minor_,
  patch_ 
)
Value:
((static_cast<unsigned>(major_) << 24) | \
(static_cast<unsigned>(minor_) << 8) | \
(static_cast<unsigned>(patch_)))

Macro to create numeric version as single unsigned number.

◆ CC_MQTTSN_CLIENT_MINOR_VERSION

#define CC_MQTTSN_CLIENT_MINOR_VERSION   0U

Minor verion of the library.

◆ CC_MQTTSN_CLIENT_PATCH_VERSION

#define CC_MQTTSN_CLIENT_PATCH_VERSION   8U

Patch level of the library.

◆ CC_MQTTSN_CLIENT_VERSION

Version of the library as single numeric value.

Typedef Documentation

◆ CC_MqttsnAsyncOpCompleteReportFn

typedef void(* CC_MqttsnAsyncOpCompleteReportFn) (void *data, CC_MqttsnAsyncOpStatus status)

Callback used to report completion of the asynchronous operation.

Parameters
[in]dataPointer to user data object, passed as the last parameter to the request call.
[in]statusStatus of the asynchronous operation.

◆ CC_MqttsnCancelNextTickWaitFn

typedef unsigned(* CC_MqttsnCancelNextTickWaitFn) (void *data)

Callback used to request termination of existing time measurement.

The callback is set using cc_mqttsn_client_set_cancel_next_tick_wait_callback() function.

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

◆ CC_MqttsnGwDisconnectReportFn

typedef void(* CC_MqttsnGwDisconnectReportFn) (void *data)

Callback used to report unsolicited disconnection of the gateway.

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

◆ CC_MqttsnGwStatusReportFn

typedef void(* CC_MqttsnGwStatusReportFn) (void *data, unsigned char gwId, CC_MqttsnGwStatus status)

Callback used to report gateway status.

The callback is set using cc_mqttsn_client_set_gw_status_report_callback() function.

Parameters
[in]dataPointer to user data object, passed as last parameter to cc_mqttsn_client_set_gw_status_report_callback() function.
[in]gwIdID of the gateway.
[in]statusStatus of the gateway.

◆ CC_MqttsnMessageReportFn

typedef void(* CC_MqttsnMessageReportFn) (void *data, const CC_MqttsnMessageInfo *msgInfo)

Callback used to report incoming messages.

The callback is set using cc_mqttsn_client_set_message_report_callback() function. The reported data resides in internal data structures of the client library, and it can be updated right after the callback function returns.

Parameters
[in]dataPointer to user data object, passed as last parameter to cc_mqttsn_client_set_message_report_callback() function.
[in]msgInfoInformation about incoming message.

◆ CC_MqttsnNextTickProgramFn

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

Callback used to request time measurement.

The callback is set using cc_mqttsn_client_set_next_tick_program_callback() function.

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

◆ CC_MqttsnSendOutputDataFn

typedef void(* CC_MqttsnSendOutputDataFn) (void *data, const unsigned char *buf, unsigned bufLen, bool broadcast)

Callback used to request to send data to the gateway.

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

Parameters
[in]dataPointer to user data object, passed as last parameter to cc_mqttsn_client_set_send_output_data_callback() function.
[in]bufPointer to the buffer containing data to send
[in]bufLenNumber of bytes to send
[in]broadcastIndication whether data needs to be broadcasted or sent directly to the gateway.

◆ CC_MqttsnSubscribeCompleteReportFn

typedef void(* CC_MqttsnSubscribeCompleteReportFn) (void *data, CC_MqttsnAsyncOpStatus status, CC_MqttsnQoS qos)

Callback used to report completion of the subscribe operation.

Parameters
[in]dataPointer to user data object, passed as the last parameter to the subscribe request.
[in]statusStatus of the subscribe operation.
[in]qosMaximal level of quality of service, the gateway/broker is going to use to publish incoming messages.

◆ CC_MqttsnTopicId

typedef unsigned short CC_MqttsnTopicId

Type used to hold Topic ID value.

Enumeration Type Documentation

◆ CC_MqttsnAsyncOpStatus

Status of the asynchronous operation.

Enumerator
CC_MqttsnAsyncOpStatus_Invalid 

Invalid value, should never be used.

CC_MqttsnAsyncOpStatus_Successful 

The operation was successful.

CC_MqttsnAsyncOpStatus_Congestion 

The gateway/broker was busy and could not handle the request, try again.

CC_MqttsnAsyncOpStatus_InvalidId 

Publish message used invalid topic ID.

CC_MqttsnAsyncOpStatus_NotSupported 

The issued request is not supported by the gateway.

CC_MqttsnAsyncOpStatus_NoResponse 

The gateway/broker didn't respond the the request.

CC_MqttsnAsyncOpStatus_Aborted 

The operation was cancelled using cc_mqttsn_client_cancel() call.

◆ CC_MqttsnErrorCode

Error code returned by various API functions.

Enumerator
CC_MqttsnErrorCode_Success 

The requested operation was successfully started.

CC_MqttsnErrorCode_AlreadyStarted 

Returned by cc_mqttsn_client_start() function if invoked twice.

CC_MqttsnErrorCode_NotStarted 

Returned by various operations if issued prior to successful start using cc_mqttsn_client_start().

CC_MqttsnErrorCode_Busy 

The client library is in the middle of previous operation, cannot start a new one.

CC_MqttsnErrorCode_AlreadyConnected 

The client library is already connected to the gateway. Returned when cc_mqttsn_client_connect() invoked second time.

CC_MqttsnErrorCode_NotConnected 

The client library is not connected to the gateway. Returned by operations that require connection to the gateway.

CC_MqttsnErrorCode_NotSleeping 

The client is not in ASLEEP mode.

CC_MqttsnErrorCode_BadParam 

Bad parameter is passed to the function.

◆ CC_MqttsnGwStatus

Status of the gateway.

Enumerator
CC_MqttsnGwStatus_Invalid 

Invalid value, should never be used.

CC_MqttsnGwStatus_Available 

The gateway is available.

CC_MqttsnGwStatus_TimedOut 

The gateway hasn't advertised its presence in time, assumed disconnected.

CC_MqttsnGwStatus_Discarded 

The gateway info was discarded using cc_mqttsn_client_discard_gw() or cc_mqttsn_client_discard_all_gw().

◆ CC_MqttsnQoS

Quality of Service.

Enumerator
CC_MqttsnQoS_NoGwPublish 

QoS=-1. No gateway publish, used by publish only clients.

CC_MqttsnQoS_AtMostOnceDelivery 

QoS=0. At most once delivery.

CC_MqttsnQoS_AtLeastOnceDelivery 

QoS=1. At least once delivery.

CC_MqttsnQoS_ExactlyOnceDelivery 

QoS=2. Exactly once delivery.