Network Services API  2.75.00.17
Data Structures | Typedefs | Enumerations | Functions
MQTT Server

Data Structures

struct  _MQTTServer_SubscribeParams_
 
struct  _MQTTServer_UnSubscribeParams_
 
struct  _MQTTServer_LocalAuthenticationData_
 
struct  _MQTTServer_ConnectMetaDataCB_
 
struct  _MQTTServer_RecvMetaDataCB_
 
struct  _MQTTServer_DisconnectMetaDataCB_
 
struct  _MQTTServer_ConnParams_
 
struct  MQTTServer_Params
 

Typedefs

typedef void(* MQTTServer_CallBack) (int32_t event, void *metaData, uint32_t metaDateLen, void *data, uint32_t dataLen)
 
typedef void * MQTTServer_Handle
 
typedef struct _MQTTServer_SubscribeParams_ MQTTServer_SubscribeParams
 
typedef struct _MQTTServer_UnSubscribeParams_ MQTTServer_UnSubscribeParams
 
typedef struct _MQTTServer_LocalAuthenticationData_ MQTTServer_LocalAuthenticationData
 
typedef struct _MQTTServer_ConnectMetaDataCB_ MQTTServer_ConnectMetaDataCB
 
typedef struct _MQTTServer_RecvMetaDataCB_ MQTTServer_RecvMetaDataCB
 
typedef struct _MQTTServer_DisconnectMetaDataCB_ MQTTServer_DisconnectMetaDataCB
 
typedef struct _MQTTServer_ConnParams_ MQTTServer_ConnParams
 

Enumerations

enum  MQTTServer_Option {
  MQTTServer_USER_NAME = 0,
  MQTTServer_PASSWORD = 1
}
 
enum  MQTTServer_EventCB {
  MQTTServer_RECV_CB_EVENT = 0,
  MQTTServer_CONNECT_CB_EVENT = 1,
  MQTTServer_DISCONNECT_CB_EVENT = 2
}
 

Functions

int16_t MQTTServer_delete (MQTTServer_Handle handle)
 
MQTTServer_Handle MQTTServer_create (MQTTServer_CallBack defaultCallback, MQTTServer_Params *attrib)
 
int16_t MQTTServer_run (MQTTServer_Handle handle)
 
int16_t MQTTServer_subscribe (MQTTServer_Handle handle, MQTTServer_SubscribeParams *value, uint8_t numberOfTopics)
 
int16_t MQTTServer_unsubscribe (MQTTServer_Handle handle, MQTTServer_UnSubscribeParams *value, uint8_t numberOfTopics)
 
int16_t MQTTServer_publish (MQTTServer_Handle handle, char *topic, uint16_t topicLen, char *msg, uint16_t msgLen, uint32_t flags)
 
int16_t MQTTServer_set (MQTTServer_Handle handle, uint16_t option, void *value, uint16_t valueLength)
 

Detailed Description

Library Usage

To use the MQTTServer APIs, the application should include its header file as follows:

And, add the following MQTT library to the link line:

.../source/ti/net/mqtt/{toolchain}/{isa}/mqtt_{profile}.a

Typedef Documentation

§ MQTTServer_CallBack

typedef void(* MQTTServer_CallBack) (int32_t event, void *metaData, uint32_t metaDateLen, void *data, uint32_t dataLen)

§ MQTTServer_Handle

typedef void* MQTTServer_Handle

§ MQTTServer_SubscribeParams

§ MQTTServer_UnSubscribeParams

§ MQTTServer_LocalAuthenticationData

§ MQTTServer_ConnectMetaDataCB

§ MQTTServer_RecvMetaDataCB

§ MQTTServer_DisconnectMetaDataCB

§ MQTTServer_ConnParams

Secure Socket Parameters to open a secure connection

Enumeration Type Documentation

§ MQTTServer_Option

Enumerator
MQTTServer_USER_NAME 
MQTTServer_PASSWORD 

§ MQTTServer_EventCB

Enumerator
MQTTServer_RECV_CB_EVENT 
MQTTServer_CONNECT_CB_EVENT 
MQTTServer_DISCONNECT_CB_EVENT 

Function Documentation

§ MQTTServer_delete()

int16_t MQTTServer_delete ( MQTTServer_Handle  handle)

Delete the MQTTServer

Disconnect and remove all MQTT Server connections and data.

Parameters
[in]handleInstance of the MQTTServer
Returns
0 on success or error code on failure.
See also
MQTTServer_create()

§ MQTTServer_create()

MQTTServer_Handle MQTTServer_create ( MQTTServer_CallBack  defaultCallback,
MQTTServer_Params attrib 
)

Create an MQTTServer instance

A caller must initialize the MQTT Server implementation prior to using its services.

Parameters
[in]attribparameters
[in]defaultCallbackasync event handler
Returns
Success Handle or Failure NULL
See also
MQTTServer_delete()

§ MQTTServer_run()

int16_t MQTTServer_run ( MQTTServer_Handle  handle)

Start an MQTTServer instance

Main Task loop function that will start the MQTT server Connect and wait for data received

Parameters
[in]handleMQTTServer instance handle
Returns
Success (0) or Failure (Negative number)
See also
MQTTServer_create()

§ MQTTServer_subscribe()

int16_t MQTTServer_subscribe ( MQTTServer_Handle  handle,
MQTTServer_SubscribeParams value,
uint8_t  numberOfTopics 
)

SUBSCRIBE a set of topics. To receive data about a set of topics from the server, the app through this routine must subscribe to those topic names with the server. The caller can indicate whether the routine should block until a time, the message has been acknowledged by the server.

In case, the app has chosen not to await for the ACK from the server, the SL MQTT implementation will notify the app about the subscription through the callback routine.

Parameters
[in]handlerefers to the handle to the client context
[in]valuea pointer to a struct of subscribe parameters which hold:
Topic name to subscribe. It is a pointer to NUL terminated strings.
Qos value for the topic.
persistent session flag in order to enable or disable persistent session.
callback function which is optional - if NULL use the default callback
[in]numberOfTopicsnumber of such topics
Returns
Success(transaction Message ID) or Failure(Negative number)

§ MQTTServer_unsubscribe()

int16_t MQTTServer_unsubscribe ( MQTTServer_Handle  handle,
MQTTServer_UnSubscribeParams value,
uint8_t  numberOfTopics 
)

UNSUBSCRIBE a set of topics. The app should use this service to stop receiving data for the named topics from the server.

Parameters
[in]handlerefers to the handle to the client context
[in]valuetopics set of topics to be unsubscribed. It is an array of pointers to NUL terminated strings.
[in]numberOfTopicscount number of topics to be unsubscribed
Returns
Success(transaction Message ID) or Failure(Negative number)

§ MQTTServer_publish()

int16_t MQTTServer_publish ( MQTTServer_Handle  handle,
char *  topic,
uint16_t  topicLen,
char *  msg,
uint16_t  msgLen,
uint32_t  flags 
)

PUBLISH a named message to the server. In addition to the PUBLISH specific parameters, the caller can indicate whether the routine should block until the time, the message has been acknowledged by the server. This is applicable only for non-QoS0 messages.

In case, the app has chosen not to await for the ACK from the server, the SL MQTT implementation will notify the app about the subscription through the callback routine.

Parameters
[in]handlerefers to the handle to the client context
[in]topictopic of the data to be published. It is NULL terminated.
[in]topicLentopic length.
[in]msgbinary data to be published
[in]msgLenlength of the msg
[in]flagsQOS define MQTT_PUBLISH_QOS_0, MQTT_PUBLISH_QOS_1 or MQTT_PUBLISH_QOS_2 use MQTT_PUBLISH_RETAIN is message should be retained
Returns
Success(transaction Message ID) or Failure(Negative number)

§ MQTTServer_set()

int16_t MQTTServer_set ( MQTTServer_Handle  handle,
uint16_t  option,
void *  value,
uint16_t  valueLength 
)

Setting Server parameters. This function can set different parameters to the server. User name and password - for Clients Authentication

Parameters
[in]handlerefers to the handle to the client context
[in]optionDefine the actual option to set. Applicable values:
[in]valueSpecifies a value for the option
[in]valueLengthSpecifies the length of the value
Returns
Success(0) or Failure(Negative number)
© Copyright 1995-2020, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale