Microchip® Advanced Software Framework

mqtt.h File Reference

Data Structures

struct  mqtt_client_pool
 
struct  mqtt_config
 MQTT configuration structure. More...
 
union  mqtt_data
 Structure of the MQTT callback. More...
 
struct  mqtt_data_connected
 Structure of the MQTT_CALLBACK_CONNECTED callback. More...
 
struct  mqtt_data_disconnected
 Structure of the MQTT_CALLBACK_DISCONNECTED callback. More...
 
struct  mqtt_data_ping
 Structure of the MQTT_CALLBACK_SENT_PING callback. More...
 
struct  mqtt_data_published
 Structure of the MQTT_CALLBACK_PUBLISHED callback. More...
 
struct  mqtt_data_sock_connected
 Structure of the MQTT_CALLBACK_SOCK_CONNECTED callback. More...
 
struct  mqtt_data_subscribed
 Structure of the MQTT_CALLBACK_SUBSCRIBED callback. More...
 
struct  mqtt_data_unsubscribed
 Structure of the MQTT_CALLBACK_UNSUBSCRIBED callback. More...
 
struct  mqtt_module
 Structure of MQTT connection instance. More...
 

Typedefs

typedef void(* mqtt_callback_t )(struct mqtt_module *module_inst, int type, union mqtt_data *data)
 Callback interface of MQTT service. More...
 

Enumerations

enum  mqtt_callback_type {
  MQTT_CALLBACK_SOCK_CONNECTED,
  MQTT_CALLBACK_CONNECTED,
  MQTT_CALLBACK_PUBLISHED,
  MQTT_CALLBACK_SUBSCRIBED,
  MQTT_CALLBACK_UNSUBSCRIBED,
  MQTT_CALLBACK_DISCONNECTED,
  MQTT_CALLBACK_SENT_PING
}
 A type of MQTT callback. More...
 
enum  mqtt_conn_result {
  MQTT_CONN_RESULT_ACCEPT = 0,
  MQTT_CONN_RESULT_UNACCEPTABLE_VERSION,
  MQTT_CONN_RESULT_ID_REJECTED,
  MQTT_CONN_RESULT_SERVER_UNAVAILABLE,
  MQTT_CONN_RESULT_BAD_USER_NAME,
  MQTT_CONN_RESULT_NOT_AUTHORIZED
}
 Connect return code. More...
 

Functions

int mqtt_connect (struct mqtt_module *const module, const char *host)
 Connect to specific MQTT broker server. More...
 
int mqtt_connect_broker (struct mqtt_module *const module, uint8_t clean_session, const char *id, const char *password, const char *client_id, const char *will_topic, const char *will_msg, uint32_t will_msg_len, uint8_t will_qos, uint8_t will_retain)
 Send MQTT connect message to broker server with MQTT parameter. More...
 
int mqtt_deinit (struct mqtt_module *const module)
 Termivate MQTT service. More...
 
int mqtt_disconnect (struct mqtt_module *const module, int force_close)
 Send disconnect message to MQTT broker server and closing socket. More...
 
void mqtt_get_config_defaults (struct mqtt_config *const config)
 Get default configuration of SW timer. More...
 
int mqtt_init (struct mqtt_module *module, struct mqtt_config *config)
 Initialize MQTT service. More...
 
int mqtt_publish (struct mqtt_module *const module, const char *topic, const char *msg, uint32_t msg_len, uint8_t qos, uint8_t retain)
 Send publish message to MQTT broker server. More...
 
int mqtt_register_callback (struct mqtt_module *const module, mqtt_callback_t callback)
 Register and enable the callback. More...
 
void mqtt_socket_event_handler (SOCKET sock, uint8_t msg_type, void *msg_data)
 Event handler of socket event. More...
 
void mqtt_socket_resolve_handler (uint8_t *doamin_name, uint32_t server_ip)
 Event handler of gethostbyname. More...
 
int mqtt_subscribe (struct mqtt_module *const module, const char *topic, uint8_t qos, messageHandler msgHandler)
 Send subscribe message to MQTT broker server. More...
 
int mqtt_unregister_callback (struct mqtt_module *const module)
 Unregister callback. More...
 
int mqtt_unsubscribe (struct mqtt_module *const module, const char *topic)
 Send unsubscribe message to MQTT broker server. More...
 
int mqtt_yield (struct mqtt_module *module, int timeout_ms)
 Poll for published frames. More...
 

Variables

struct mqtt_client_pool mqttClientPool [MQTT_MAX_CLIENTS]
 Static Client Pool Allocation. More...