Network Services API  2.30.00.10
Data Structures | Macros | Typedefs | Enumerations | Functions
mqttclient.h File Reference
#include <string.h>
#include <stdbool.h>
#include <ti/net/mqtt/common/mqtt_common.h>
Include dependency graph for mqttclient.h:

Go to the source code of this file.

Data Structures

struct  MQTTClient_OperationMetaDataCB
 
struct  MQTTClient_RecvMetaDataCB
 
struct  MQTTClient_ConnParams
 
struct  MQTTClient_Params
 
struct  MQTTClient_SubscribeParams
 
struct  MQTTClient_UnsubscribeParams
 
struct  MQTTClient_Will
 

Macros

#define MQTTCLIENT_ERR_NETWORK   MQTT_PACKET_ERR_NETWORK
 
#define MQTTCLIENT_ERR_TIMEOUT   MQTT_PACKET_ERR_TIMEOUT
 
#define MQTTCLIENT_ERR_NET_OPS   MQTT_PACKET_ERR_NET_OPS
 
#define MQTTCLIENT_ERR_FNPARAM   MQTT_PACKET_ERR_FNPARAM
 
#define MQTTCLIENT_ERR_PKT_AVL   MQTT_PACKET_ERR_PKT_AVL
 
#define MQTTCLIENT_ERR_PKT_LEN   MQTT_PACKET_ERR_PKT_LEN
 
#define MQTTCLIENT_ERR_NOTCONN   MQTT_PACKET_ERR_NOTCONN
 
#define MQTTCLIENT_ERR_BADCALL   MQTT_PACKET_ERR_BADCALL
 
#define MQTTCLIENT_ERR_CONTENT   MQTT_PACKET_ERR_CONTENT
 
#define MQTTCLIENT_ERR_LIBQUIT   MQTT_PACKET_ERR_LIBQUIT
 
#define MQTTCLIENT_ERR_REMLSTN   MQTT_PACKET_ERR_REMLSTN
 
#define MQTTCLIENT_OPERATION_CONNACK   MQTT_CONNACK
 
#define MQTTCLIENT_OPERATION_EVT_PUBACK   MQTT_PUBACK
 
#define MQTTCLIENT_OPERATION_PUBCOMP   MQTT_PUBCOMP
 
#define MQTTCLIENT_OPERATION_SUBACK   MQTT_SUBACK
 
#define MQTTCLIENT_OPERATION_UNSUBACK   MQTT_UNSUBACK
 
#define MQTTCLIENT_NETCONN_IP4   MQTT_DEV_NETCONN_OPT_IP4
 
#define MQTTCLIENT_NETCONN_IP6   MQTT_DEV_NETCONN_OPT_IP6
 
#define MQTTCLIENT_NETCONN_URL   MQTT_DEV_NETCONN_OPT_URL
 
#define MQTTCLIENT_NETCONN_SEC   MQTT_DEV_NETCONN_OPT_SEC
 
#define MQTTCLIENT_NETCONN_SKIP_DOMAIN_NAME_VERIFICATION   MQTT_DEV_NETCONN_OPT_SKIP_DOMAIN_NAME_VERIFICATION
 
#define MQTTCLIENT_NETCONN_SKIP_CERTIFICATE_CATALOG_VERIFICATION   MQTT_DEV_NETCONN_OPT_SKIP_CERTIFICATE_CATALOG_VERIFICATION
 
#define MQTTCLIENT_NETCONN_SKIP_DATE_VERIFICATION   MQTT_DEV_NETCONN_OPT_SKIP_DATE_VERIFICATION
 

Typedefs

typedef struct MQTTClient_OperationMetaDataCB MQTTClient_OperationMetaDataCB
 
typedef struct MQTTClient_RecvMetaDataCB MQTTClient_RecvMetaDataCB
 
typedef struct MQTTClient_ConnParams MQTTClient_ConnParams
 
typedef struct MQTTClient_Params MQTTClient_Params
 
typedef void(* MQTTClient_CallBack) (int32_t event, void *metaData, uint32_t metaDateLen, void *data, uint32_t dataLen)
 
typedef void * MQTTClient_Handle
 
typedef struct MQTTClient_SubscribeParams MQTTClient_SubscribeParams
 
typedef struct MQTTClient_UnsubscribeParams MQTTClient_UnsubscribeParams
 
typedef struct MQTTClient_Will MQTTClient_Will
 

Enumerations

enum  MQTTClient_Option {
  MQTTClient_USER_NAME = 0,
  MQTTClient_PASSWORD = 1,
  MQTTClient_WILL_PARAM = 2,
  MQTTClient_CALLBACKS = 3,
  MQTTClient_KEEPALIVE_TIME = 4,
  MQTTClient_CLEAN_CONNECT = 5,
  MQTTClient_MAX_PARAM = 6
}
 
enum  MQTTClient_EventCB {
  MQTTClient_RECV_CB_EVENT = 0,
  MQTTClient_OPERATION_CB_EVENT = 1,
  MQTTClient_DISCONNECT_CB_EVENT = 2
}
 

Functions

MQTTClient_Handle MQTTClient_create (MQTTClient_CallBack defaultCallback, MQTTClient_Params *params)
 
int16_t MQTTClient_delete (MQTTClient_Handle handle)
 
int16_t MQTTClient_run (MQTTClient_Handle handle)
 
int16_t MQTTClient_connect (MQTTClient_Handle handle)
 
int16_t MQTTClient_disconnect (MQTTClient_Handle handle)
 
int16_t MQTTClient_publish (MQTTClient_Handle handle, char *topic, uint16_t topicLen, char *msg, uint16_t msgLen, uint32_t flags)
 
int16_t MQTTClient_subscribe (MQTTClient_Handle handle, MQTTClient_SubscribeParams *value, uint8_t numberOfTopics)
 
int16_t MQTTClient_unsubscribe (MQTTClient_Handle handle, MQTTClient_UnsubscribeParams *value, uint8_t numberOfTopics)
 
int16_t MQTTClient_set (MQTTClient_Handle handle, uint16_t option, void *value, uint16_t valueLength)
 
int16_t MQTTClient_get (MQTTClient_Handle handle, uint16_t option, void *value, uint16_t valueLength)
 

Typedef Documentation

§ MQTTClient_OperationMetaDataCB

§ MQTTClient_RecvMetaDataCB

§ MQTTClient_ConnParams

Secure Socket Parameters to open a secure connection

§ MQTTClient_Params

§ MQTTClient_CallBack

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

§ MQTTClient_Handle

typedef void* MQTTClient_Handle

§ MQTTClient_SubscribeParams

§ MQTTClient_UnsubscribeParams

§ MQTTClient_Will

Enumeration Type Documentation

§ MQTTClient_Option

Enumerator
MQTTClient_USER_NAME 
MQTTClient_PASSWORD 
MQTTClient_WILL_PARAM 
MQTTClient_CALLBACKS 
MQTTClient_KEEPALIVE_TIME 
MQTTClient_CLEAN_CONNECT 
MQTTClient_MAX_PARAM 

§ MQTTClient_EventCB

Enumerator
MQTTClient_RECV_CB_EVENT 
MQTTClient_OPERATION_CB_EVENT 
MQTTClient_DISCONNECT_CB_EVENT 

Function Documentation

§ MQTTClient_create()

MQTTClient_Handle MQTTClient_create ( MQTTClient_CallBack  defaultCallback,
MQTTClient_Params params 
)

Creates the SL MQTT Implementation. A caller must call this function in order the create and initialize the MQTT implementation prior to using its services.

Parameters
[in]defaultCallbackasync event handler
[in]paramsparameters
Returns
Success Handle or Failure NULL

§ MQTTClient_delete()

int16_t MQTTClient_delete ( MQTTClient_Handle  handle)

This function deletes an MQTT Client instance. It closes the connection if it exists and releases all resources.

Parameters
[in]handleto the client context
Returns
Success (0) or Failure (-1)

§ MQTTClient_run()

int16_t MQTTClient_run ( MQTTClient_Handle  handle)

MQTT client state machine This function need to be called from the context created by the user in case of OS environment.

Parameters
[in]handleto the client context
Returns
Success (0) or Failure (Negative number)

§ MQTTClient_connect()

int16_t MQTTClient_connect ( MQTTClient_Handle  handle)

Function connects MQTT client to a broker

Parameters
[in]handleto the client context
Returns
Success (0) or Failure (Negative number)

§ MQTTClient_disconnect()

int16_t MQTTClient_disconnect ( MQTTClient_Handle  handle)

DISCONNECT from the server. The caller must use this service to close the connection with the server.

Parameters
[in]handleto the client context
Returns
Success (0) or Failure (Negative number)

§ MQTTClient_publish()

int16_t MQTTClient_publish ( MQTTClient_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)

§ MQTTClient_subscribe()

int16_t MQTTClient_subscribe ( MQTTClient_Handle  handle,
MQTTClient_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 NULL 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)

§ MQTTClient_unsubscribe()

int16_t MQTTClient_unsubscribe ( MQTTClient_Handle  handle,
MQTTClient_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 NULL terminated strings.
[in]numberOfTopicscount number of topics to be unsubscribed
Returns
Success(transaction Message ID) or Failure(Negative number)

§ MQTTClient_set()

int16_t MQTTClient_set ( MQTTClient_Handle  handle,
uint16_t  option,
void *  value,
uint16_t  valueLength 
)

Setting client parameters. This function can set different parameters to the client. Will message params, user name and password, keep alive time and clean/persistent session.

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)
See also
MQTTClient_Will

§ MQTTClient_get()

int16_t MQTTClient_get ( MQTTClient_Handle  handle,
uint16_t  option,
void *  value,
uint16_t  valueLength 
)

Getting client parameters. This function can get different parameters from the client. Will message params, user name and password, keep alive time and clean/persistent session.

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)
See also
MQTTClient_Will
© Copyright 1995-2018, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale