Simple MQTT client. More...
#include <picofuse/net/types.h>#include <stdbool.h>#include <stddef.h>

Go to the source code of this file.
Data Structures | |
| struct | net_mqtt_config_t |
| MQTT connection options. More... | |
| struct | net_mqtt_sent_t |
| Payload for a net_mqtt_event_sent event. More... | |
| struct | net_mqtt_subscribed_t |
| Payload for a net_mqtt_event_subscribed event. More... | |
| struct | net_mqtt_unsubscribed_t |
| Payload for a net_mqtt_event_unsubscribed event. More... | |
| struct | net_mqtt_received_t |
| Payload for a net_mqtt_event_received event. More... | |
| struct | net_mqtt_error_t |
| Payload for a net_mqtt_event_error event. More... | |
| struct | net_mqtt_event_t |
| A single MQTT client event. More... | |
Macros | |
| #define | NET_MQTT_PORT 1883 |
| Standard MQTT port. | |
| #define | NET_MQTT_TOPIC_CAPACITY 8 |
| Maximum number of simultaneously active net_mqtt_subscribe() topic filters, per handle. | |
| #define | NET_MQTT_TOPIC_FILTER_SIZE 128 |
| Maximum length, in bytes including the terminating NUL, of a topic filter passed to net_mqtt_subscribe()/net_mqtt_unsubscribe(). More... | |
Typedefs | |
| typedef struct net_mqtt_t | net_mqtt_t |
| Opaque handle identifying an MQTT client instance. More... | |
| typedef void(* | net_mqtt_event_callback_t) (net_mqtt_t *mqtt, const net_mqtt_event_t *event, void *userdata) |
| Called for every event on an MQTT client instance. More... | |
Enumerations | |
| enum | net_mqtt_qos_t { net_mqtt_qos_0, net_mqtt_qos_1, net_mqtt_qos_2 } |
| Delivery guarantee for a published or subscribed message. More... | |
| enum | net_mqtt_event_type_t { net_mqtt_event_connected, net_mqtt_event_disconnected, net_mqtt_event_sent, net_mqtt_event_subscribed, net_mqtt_event_unsubscribed, net_mqtt_event_received, net_mqtt_event_error } |
| Event payload tag for net_mqtt_event_t. More... | |
| enum | net_mqtt_error_kind_t { net_mqtt_error_write_failed, net_mqtt_error_malformed, net_mqtt_error_unexpected, net_mqtt_error_timeout, net_mqtt_error_refused } |
| Coarse category for a net_mqtt_event_error event. More... | |
| enum | net_mqtt_error_action_t { net_mqtt_action_none, net_mqtt_action_publish, net_mqtt_action_subscribe, net_mqtt_action_unsubscribe, net_mqtt_action_receive, net_mqtt_action_ping } |
| Which operation a net_mqtt_event_error event happened during. More... | |
Functions | |
Lifecycle | |
| void | net_mqtt_default_config (net_mqtt_config_t *config) |
| Fill an MQTT config struct with safe defaults. More... | |
| net_mqtt_t * | net_mqtt_init (const net_addr_t *addr, uint16_t port, uint32_t timeout_ms, const net_mqtt_config_t *config) |
| Initialize an MQTT client instance. More... | |
| void | net_mqtt_set_callback (net_mqtt_t *mqtt, net_mqtt_event_callback_t callback, void *userdata) |
| Register the callback for events on an MQTT client instance. More... | |
| void | net_mqtt_deinit (net_mqtt_t *mqtt) |
| Release a handle from net_mqtt_init(). More... | |
Connection | |
| bool | net_mqtt_connect (net_mqtt_t *mqtt) |
| Open the MQTT connection. More... | |
| void | net_mqtt_disconnect (net_mqtt_t *mqtt) |
| Close the MQTT connection. More... | |
Publish | |
| uint32_t | net_mqtt_publish (net_mqtt_t *mqtt, const char *topic, const void *payload, size_t payload_len, net_mqtt_qos_t qos, bool retain) |
| Stage a message to publish to a topic, waiting for room to do so. More... | |
Subscribe | |
| uint32_t | net_mqtt_subscribe (net_mqtt_t *mqtt, const char *topic, net_mqtt_qos_t qos) |
| Stage a subscription to a topic filter, waiting for room to do so. More... | |
| bool | net_mqtt_unsubscribe (net_mqtt_t *mqtt, uint32_t topic_id) |
| Stage removal of a confirmed subscription, waiting for room to do so. More... | |
Functions | |
| const char * | net_mqtt_topic_to_string (net_mqtt_t *mqtt, uint32_t topic_id) |
| Look up the topic filter behind a confirmed subscription. More... | |
| size_t | net_mqtt_error_to_string (const net_mqtt_error_t *error, char *buf, size_t buf_size) |
| Format a net_mqtt_event_error payload as a human-readable string. More... | |
Simple MQTT client.
Definition in file mqtt.h.