Documentation

Documentation

Includes

lwip/apps/mqtt_opts.h

#include "lwip/apps/mqtt_opts.h"
#include "lwip/apps/mqtt_opts.h"

lwip/err.h

#include "lwip/err.h"
#include "lwip/err.h"

lwip/ip_addr.h

#include "lwip/ip_addr.h"
#include "lwip/ip_addr.h"

lwip/prot/iana.h

#include "lwip/prot/iana.h"
#include "lwip/prot/iana.h"

Macros

Marco LWIP_HDR_APPS_MQTT_CLIENT_H

#define LWIP_HDR_APPS_MQTT_CLIENT_H


      

Marco MQTT_PORT

#define MQTT_PORT    LWIP_IANA_PORT_MQTT
/** @ingroup mqtt
 * Default MQTT port (non-TLS) */

Marco MQTT_TLS_PORT

#define MQTT_TLS_PORT LWIP_IANA_PORT_SECURE_MQTT
/** @ingroup mqtt
 * Default MQTT TLS port */

Marco mqtt_subscribe(client, topic, qos, cb, arg)

#define mqtt_subscribe(client, topic, qos, cb, arg) mqtt_sub_unsub(client, topic, qos, cb, arg, 1)
/** @ingroup mqtt
 *Subscribe to topic */

Marco mqtt_unsubscribe(client, topic, cb, arg)

#define mqtt_unsubscribe(client, topic, cb, arg) mqtt_sub_unsub(client, topic, 0, cb, arg, 0)
/** @ingroup mqtt
 *  Unsubscribe to topic */

Functions

Func mqtt_client_connect

err_t mqtt_client_connect(mqtt_client_t *client, const ip_addr_t *ipaddr, u16_t port, mqtt_connection_cb_t cb, void *arg,
                  const struct mqtt_connect_client_info_t *client_info);


      

Func mqtt_disconnect

void mqtt_disconnect(mqtt_client_t *client);


      

Func mqtt_client_new

mqtt_client_t *mqtt_client_new(void);


      

Func mqtt_client_free

void mqtt_client_free(mqtt_client_t* client);


      

Func mqtt_client_is_connected

u8_t mqtt_client_is_connected(mqtt_client_t *client);


      

Func mqtt_set_inpub_callback

void mqtt_set_inpub_callback(mqtt_client_t *client, mqtt_incoming_publish_cb_t,
                            mqtt_incoming_data_cb_t data_cb, void *arg);


      

Func mqtt_sub_unsub

err_t mqtt_sub_unsub(mqtt_client_t *client, const char *topic, u8_t qos, mqtt_request_cb_t cb, void *arg, u8_t sub);


      

Func mqtt_publish

err_t mqtt_publish(mqtt_client_t *client, const char *topic, const void *payload, u16_t payload_length, u8_t qos, u8_t retain,
                                   mqtt_request_cb_t cb, void *arg);

      

Vars

Variable altcp_tls_config

struct altcp_tls_config;

      

Consts

Types

Typedefs

Typedef mqtt_client_t

typedef struct mqtt_client_s mqtt_client_t;


      

Typedef mqtt_connection_status_t;

typedef enum
{
 /** Accepted */
 MQTT_CONNECT_ACCEPTED                = 0,
 /** Refused protocol version */
 MQTT_CONNECT_REFUSED_PROTOCOL_VERSION = 1,
 /** Refused identifier */
 MQTT_CONNECT_REFUSED_IDENTIFIER      = 2,
 /** Refused server */
 MQTT_CONNECT_REFUSED_SERVER          = 3,
 /** Refused user credentials */
 MQTT_CONNECT_REFUSED_USERNAME_PASS   = 4,
 /** Refused not authorized */
 MQTT_CONNECT_REFUSED_NOT_AUTHORIZED_ = 5,
 /** Disconnected */
 MQTT_CONNECT_DISCONNECTED            = 256,
 /** Timeout */
 MQTT_CONNECT_TIMEOUT                 = 257
} mqtt_connection_status_t;
/**
 * @ingroup mqtt
 * Connection status codes */

Typedef mqtt_connection_cb_t

typedef void (*mqtt_connection_cb_t)(mqtt_client_t *client, void *arg, mqtt_connection_status_t status);
/**
 * @ingroup mqtt
 * Function prototype for mqtt connection status callback. Called when
 * client has connected to the server after initiating a mqtt connection attempt by
 * calling mqtt_client_connect() or when connection is closed by server or an error
 *
 * @param client MQTT client itself
 * @param arg Additional argument to pass to the callback function
 * @param status Connect result code or disconnection notification @see mqtt_connection_status_t
 *
 */

Typedef mqtt_incoming_data_cb_t

typedef void (*mqtt_incoming_data_cb_t)(void *arg, const u8_t *data, u16_t len, u8_t flags);
/** 
 * @ingroup mqtt
 * Function prototype for MQTT incoming publish data callback function. Called when data
 * arrives to a subscribed topic @see mqtt_subscribe
 *
 * @param arg Additional argument to pass to the callback function
 * @param data User data, pointed object, data may not be referenced after callback return,
          NULL is passed when all publish data are delivered
 * @param len Length of publish data fragment
 * @param flags MQTT_DATA_FLAG_LAST set when this call contains the last part of data from publish message
 *
 */

Typedef mqtt_incoming_publish_cb_t

typedef void (*mqtt_incoming_publish_cb_t)(void *arg, const char *topic, u32_t tot_len);
/** 
 * @ingroup mqtt
 * Function prototype for MQTT incoming publish function. Called when an incoming publish
 * arrives to a subscribed topic @see mqtt_subscribe
 *
 * @param arg Additional argument to pass to the callback function
 * @param topic Zero terminated Topic text string, topic may not be referenced after callback return
 * @param tot_len Total length of publish data, if set to 0 (no publish payload) data callback will not be invoked
 */

Typedef mqtt_request_cb_t

typedef void (*mqtt_request_cb_t)(void *arg, err_t err);
/**
 * @ingroup mqtt
 * Function prototype for mqtt request callback. Called when a subscribe, unsubscribe
 * or publish request has completed
 * @param arg Pointer to user data supplied when invoking request
 * @param err ERR_OK on success
 *            ERR_TIMEOUT if no response was received within timeout,
 *            ERR_ABRT if (un)subscribe was denied
 */