TizenRT Public API  v2.0 M2
MQTT Client

Provides APIs for MQTT Client. More...

Files

file  mqtt_api.h
 APIs for MQTT Client(Subscriber/Publisher)
 

Data Structures

struct  _mqtt_msg_s
 Structure of MQTT message. More...
 
struct  _mqtt_tls_param_s
 Structure of MQTT security information. More...
 
struct  _mqtt_client_config_s
 Structure of MQTT client configuration. More...
 
struct  _mqtt_client_s
 Structure of MQTT client object. More...
 

Enumerations

Functions

mqtt_client_tmqtt_init_client (mqtt_client_config_t *config)
 mqtt_init_client() initializes MQTT client More...
 
int mqtt_deinit_client (mqtt_client_t *handle)
 mqtt_deinit_client() de-initializes MQTT client More...
 
int mqtt_connect (mqtt_client_t *handle, char *addr, int port, int keep_alive)
 mqtt_connect() connects to a MQTT broker More...
 
int mqtt_disconnect (mqtt_client_t *handle)
 mqtt_disconnect() disconnects from a MQTT broker More...
 
int mqtt_publish (mqtt_client_t *handle, char *topic, char *data, uint32_t data_len, uint8_t qos, uint8_t retain)
 mqtt_publish() pusblishes message to a MQTT broker on the given topic More...
 
int mqtt_subscribe (mqtt_client_t *handle, char *topic, uint8_t qos)
 mqtt_subscribe() subscribes for the specified topic with MQTT broker More...
 
int mqtt_unsubscribe (mqtt_client_t *handle, char *topic)
 mqtt_unsubscribe() unsubscribes from the specified topic More...
 

Detailed Description

Provides APIs for MQTT Client.

Enumeration Type Documentation

This enumeration describes the state of the MQTT client.

Definition at line 59 of file mqtt_api.h.

This enumeration describes the state of the MQTT connection result.

Definition at line 69 of file mqtt_api.h.

Function Documentation

int mqtt_connect ( mqtt_client_t handle,
char *  addr,
int  port,
int  keep_alive 
)

mqtt_connect() connects to a MQTT broker

#include <network/mqtt/mqtt_api.h>

Parameters
[in]handlethe handle of MQTT client object
[in]addrMQTT broker address
[in]portMQTT broker port
[in]keep_aliveMQTT keep-alive time in second
Returns
On success, 0 is returned. On failure, a negative value is returned.
Since
TizenRT v1.1
int mqtt_deinit_client ( mqtt_client_t handle)

mqtt_deinit_client() de-initializes MQTT client

#include <network/mqtt/mqtt_api.h>

Parameters
[in]handlethe handle of MQTT client object
Returns
On success, 0 is returned. On failure, a negative value is returned.
Since
TizenRT v1.1
int mqtt_disconnect ( mqtt_client_t handle)

mqtt_disconnect() disconnects from a MQTT broker

#include <network/mqtt/mqtt_api.h>

Parameters
[in]handlethe handle of MQTT client object
Returns
On success, 0 is returned. On failure, a negative value is returned.
Since
TizenRT v1.1
mqtt_client_t* mqtt_init_client ( mqtt_client_config_t config)

mqtt_init_client() initializes MQTT client

#include <network/mqtt/mqtt_api.h>

Parameters
[in]configthe information of MQTT client object configuration
Returns
On success, the handle of MQTT client object is returned. On failure, NULL is returned.
Since
TizenRT v1.1
int mqtt_publish ( mqtt_client_t handle,
char *  topic,
char *  data,
uint32_t  data_len,
uint8_t  qos,
uint8_t  retain 
)

mqtt_publish() pusblishes message to a MQTT broker on the given topic

#include <network/mqtt/mqtt_api.h>

Parameters
[in]handlethe handle of MQTT client object
[in]topicthe topic on which the message to be published
[in]datathe message to publish
[in]data_lenthe length of message
[in]qosthe Quality of Service to be used for the message. QoS value should be 0,1 or 2.
[in]retainthe flag to make the message retained.
Returns
On success, 0 is returned. On failure, a negative value is returned.
Since
TizenRT v1.1
int mqtt_subscribe ( mqtt_client_t handle,
char *  topic,
uint8_t  qos 
)

mqtt_subscribe() subscribes for the specified topic with MQTT broker

#include <network/mqtt/mqtt_api.h>

Parameters
[in]handlethe handle of MQTT client object
[in]topicthe topic on which the message to be unsubscribed
[in]qosthe Quality of Service for the subscription. QoS value should be 0,1 or 2.
Returns
On success, 0 is returned. On failure, a negative value is returned.
Since
TizenRT v1.1
int mqtt_unsubscribe ( mqtt_client_t handle,
char *  topic 
)

mqtt_unsubscribe() unsubscribes from the specified topic

#include <network/mqtt/mqtt_api.h>

Parameters
[in]handlethe handle of MQTT client object
[in]topicthe topic on which the message to be unsubscribed
Returns
On success, 0 is returned. On failure, a negative value is returned.
Since
TizenRT v1.1