29 #ifndef __MQTT_API_H__ 30 #define __MQTT_API_H__ 35 #include <tinyara/config.h> 38 #define EXTERN extern "C" 47 #define MQTT_DEFAULT_BROKER_PORT 1883 48 #define MQTT_SECURITY_BROKER_PORT 8883 49 #define MQTT_DEFAULT_KEEP_ALIVE_TIME 60 50 #define MQTT_PROTOCOL_VERSION_31 3 51 #define MQTT_PROTOCOL_VERSION_311 4 60 MQTT_CLIENT_STATE_NOT_CONNECTED = 0,
61 MQTT_CLIENT_STATE_CONNECTED,
62 MQTT_CLIENT_STATE_CONNECT_REQUEST,
63 MQTT_CLIENT_STATE_DISCONNECT_REQUEST,
70 MQTT_CONN_ACCEPTED = 0,
71 MQTT_CONN_REFUSED_UNACCEPTABLE_PROTOCOL_VER,
72 MQTT_CONN_REFUSED_ID_REJECTED,
73 MQTT_CONN_REFUSED_BROKER_UNAVAILABLE,
74 MQTT_CONN_REFUSED_BAD_USER_NAME_OR_PASSWORD,
75 MQTT_CONN_REFUSED_NOT_AUTHORIZED,
99 const unsigned char *ca_cert;
100 const unsigned char *cert;
101 const unsigned char *key;
129 void (*
on_subscribe)(
void *client,
int msg_id,
int qos_count,
const int *granted_qos);
int mqtt_disconnect(mqtt_client_t *handle)
mqtt_disconnect() disconnects from a MQTT broker
Structure of MQTT client configuration.
int mqtt_deinit_client(mqtt_client_t *handle)
mqtt_deinit_client() de-initializes MQTT client
void(* on_connect)(void *client, int result)
int mqtt_connect(mqtt_client_t *handle, char *addr, int port, int keep_alive)
mqtt_connect() connects to a MQTT broker
mqtt_client_t * mqtt_init_client(mqtt_client_config_t *config)
mqtt_init_client() initializes MQTT client
mqtt_client_config_t * config
mqtt_connection_result_e
This enumeration describes the state of the MQTT connection result.
void(* on_disconnect)(void *client, int result)
Structure of MQTT message.
void(* on_unsubscribe)(void *client, int msg_id)
Structure of MQTT client object.
void(* on_message)(void *client, mqtt_msg_t *msg)
void(* on_publish)(void *client, int msg_id)
mqtt_client_state_e
This enumeration describes the state of the MQTT client.
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
void(* on_subscribe)(void *client, int msg_id, int qos_count, const int *granted_qos)
int mqtt_subscribe(mqtt_client_t *handle, char *topic, uint8_t qos)
mqtt_subscribe() subscribes for the specified topic with MQTT broker
int mqtt_unsubscribe(mqtt_client_t *handle, char *topic)
mqtt_unsubscribe() unsubscribes from the specified topic
Structure of MQTT security information.