4.8.0.0R6
Software Development Kit
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules
MQTT Client

Functions

int ltrx_mqtt_client_connect (struct ltrx_mqtt_client *lmc)
 Establish client connection to MQTT broker. More...
 
struct ltrx_mqtt_client * ltrx_mqtt_client_create (uint32_t command_timeout_ms, size_t sendbuf_size, size_t recvbuf_size)
 Create a MQTT client instance. More...
 
int ltrx_mqtt_client_destroy (struct ltrx_mqtt_client *lmc)
 Destroy a MQTT client instance. More...
 
int ltrx_mqtt_client_disconnect (struct ltrx_mqtt_client *lmc)
 Disconnect client connection from MQTT broker. More...
 
bool ltrx_mqtt_client_is_connected (struct ltrx_mqtt_client *lmc)
 Test MQTT connection. More...
 
int ltrx_mqtt_client_publish (struct ltrx_mqtt_client *lmc, const char *topic, struct ltrx_mqtt_message *msg)
 Publish a message to the MQTT broker. More...
 
int ltrx_mqtt_client_set_cleansession (struct ltrx_mqtt_client *lmc, bool cleansession)
 Set cleansession flag for a MQTT client instance. More...
 
int ltrx_mqtt_client_set_connect_info (struct ltrx_mqtt_client *lmc, const struct ltrx_mqtt_client_connect_info *lmcci)
 Set connection info for a MQTT client instance. More...
 
int ltrx_mqtt_client_set_keepalive_interval (struct ltrx_mqtt_client *lmc, uint16_t keepalive_interval_sec)
 Set keepalive interval for a MQTT client instance. More...
 
int ltrx_mqtt_client_set_log_verbosity (struct ltrx_mqtt_client *lmc, uint8_t verbosity)
 Set logging level for a MQTT client instance. More...
 
int ltrx_mqtt_client_set_lwt (struct ltrx_mqtt_client *lmc, const char *topic, struct ltrx_mqtt_message *msg)
 Set Last Will and Testament for a MQTT client instance. More...
 
int ltrx_mqtt_client_set_network_info (struct ltrx_mqtt_client *lmc, struct ltrx_mqtt_client_network_info *lmcni)
 Set network info for a MQTT client instance. More...
 
int ltrx_mqtt_client_subscribe (struct ltrx_mqtt_client *lmc, const char *topic_filter, int max_qos, void(*callback)(struct ltrx_mqtt_message_data *))
 Subscribe to message topic(s) from a MQTT broker. More...
 
int ltrx_mqtt_client_unsubscribe (struct ltrx_mqtt_client *lmc, const char *topic_filter)
 Unsubscribe from message topic(s) from a MQTT broker. More...
 

Detailed Description

MQTT Client is compliant with MQTT 3.1.1.

Function Documentation

int ltrx_mqtt_client_connect ( struct ltrx_mqtt_client *  lmc)

Establish client connection to MQTT broker.

Return values
enumltrx_mqtt_client_return_code
Parameters
[in]lmcPointer to a MQTT client instance
struct ltrx_mqtt_client* ltrx_mqtt_client_create ( uint32_t  command_timeout_ms,
size_t  sendbuf_size,
size_t  recvbuf_size 
)

Create a MQTT client instance.

Return values
non-NULLPointer to the new MQTT client instance.
NULLFailed.
Parameters
[in]command_timeout_msTimeout in ms to wait for ACK of sent command.
[in]sendbuf_sizeSize of send buffer in bytes.
[in]recvbuf_sizeSize of receive buffer in bytes.
int ltrx_mqtt_client_destroy ( struct ltrx_mqtt_client *  lmc)

Destroy a MQTT client instance.

Return values
enumltrx_mqtt_client_return_code
Parameters
[in]lmcPointer to a MQTT client instance
int ltrx_mqtt_client_disconnect ( struct ltrx_mqtt_client *  lmc)

Disconnect client connection from MQTT broker.

Return values
enumltrx_mqtt_client_return_code
Parameters
[in]lmcPointer to a MQTT client instance
bool ltrx_mqtt_client_is_connected ( struct ltrx_mqtt_client *  lmc)

Test MQTT connection.

Return values
trueif connected
Parameters
[in]lmcPointer to a MQTT client instance
int ltrx_mqtt_client_publish ( struct ltrx_mqtt_client *  lmc,
const char *  topic,
struct ltrx_mqtt_message msg 
)

Publish a message to the MQTT broker.

Return values
enumltrx_mqtt_client_return_code
Parameters
[in]lmcPointer to a MQTT client instance
[in]topicThe message topic
[in]msgThe message info
int ltrx_mqtt_client_set_cleansession ( struct ltrx_mqtt_client *  lmc,
bool  cleansession 
)

Set cleansession flag for a MQTT client instance.

Return values
enumltrx_mqtt_client_return_code
Parameters
[in]lmcPointer to a MQTT client instance
[in]cleansessioncleansession flag.
int ltrx_mqtt_client_set_connect_info ( struct ltrx_mqtt_client *  lmc,
const struct ltrx_mqtt_client_connect_info lmcci 
)

Set connection info for a MQTT client instance.

Return values
enumltrx_mqtt_client_return_code
Parameters
[in]lmcPointer to a MQTT client instance
[in]lmcciConnection info for MQTT session.
int ltrx_mqtt_client_set_keepalive_interval ( struct ltrx_mqtt_client *  lmc,
uint16_t  keepalive_interval_sec 
)

Set keepalive interval for a MQTT client instance.

Return values
enumltrx_mqtt_client_return_code
Parameters
[in]lmcPointer to a MQTT client instance
[in]keepalive_interval_seckeepalive interval in seconds.
int ltrx_mqtt_client_set_log_verbosity ( struct ltrx_mqtt_client *  lmc,
uint8_t  verbosity 
)

Set logging level for a MQTT client instance.

Return values
enumltrx_mqtt_client_return_code
Parameters
[in]lmcPointer to a MQTT client instance
[in]verbosityRequested verbosity.
int ltrx_mqtt_client_set_lwt ( struct ltrx_mqtt_client *  lmc,
const char *  topic,
struct ltrx_mqtt_message msg 
)

Set Last Will and Testament for a MQTT client instance.

Return values
enumltrx_mqtt_client_return_code
Parameters
[in]lmcPointer to a MQTT client instance
[in]topicThe will message topic
[in]msgThe will message info
int ltrx_mqtt_client_set_network_info ( struct ltrx_mqtt_client *  lmc,
struct ltrx_mqtt_client_network_info lmcni 
)

Set network info for a MQTT client instance.

Return values
enumltrx_mqtt_client_return_code
Parameters
[in]lmcPointer to a MQTT client instance
[in]lmcniNetwork connection info for MQTT session.
int ltrx_mqtt_client_subscribe ( struct ltrx_mqtt_client *  lmc,
const char *  topic_filter,
int  max_qos,
void(*)(struct ltrx_mqtt_message_data *)  callback 
)

Subscribe to message topic(s) from a MQTT broker.

Return values
enumltrx_mqtt_client_return_code
Parameters
[in]lmcPointer to a MQTT client instance
[in]topic_filterThe message topic filter
[in]max_qosThe max qos level at which the broker can send matching messages
[in]callbackThe message handler to call when a matching message is received
int ltrx_mqtt_client_unsubscribe ( struct ltrx_mqtt_client *  lmc,
const char *  topic_filter 
)

Unsubscribe from message topic(s) from a MQTT broker.

Return values
enumltrx_mqtt_client_return_code
Parameters
[in]lmcPointer to a MQTT client instance
[in]topic_filterThe message topic filter