Lightweight MQTT 3.1.1 client for IoT pub/sub messaging.
More...
|
|
typedef uint8_t | ove_mqtt_qos_t |
| | MQTT QoS level.
|
| |
| typedef void(* | ove_mqtt_msg_cb) (const char *topic, size_t topic_len, const void *payload, size_t payload_len, void *user_data) |
| | MQTT message callback.
|
| |
|
| int | ove_mqtt_client_init (ove_mqtt_client_t *client, ove_mqtt_client_storage_t *storage) |
| | Initialise an MQTT client from caller-supplied storage.
|
| |
| void | ove_mqtt_client_deinit (ove_mqtt_client_t client) |
| | De-initialise an MQTT client.
|
| |
| int | ove_mqtt_connect (ove_mqtt_client_t client, const ove_mqtt_config_t *cfg) |
| | Connect to an MQTT broker.
|
| |
| void | ove_mqtt_disconnect (ove_mqtt_client_t client) |
| | Disconnect from the MQTT broker.
|
| |
| int | ove_mqtt_publish (ove_mqtt_client_t client, const char *topic, const void *payload, size_t payload_len, ove_mqtt_qos_t qos) |
| | Publish a message.
|
| |
| int | ove_mqtt_subscribe (ove_mqtt_client_t client, const char *topic, ove_mqtt_qos_t qos) |
| | Subscribe to a topic.
|
| |
| int | ove_mqtt_unsubscribe (ove_mqtt_client_t client, const char *topic) |
| | Unsubscribe from a topic.
|
| |
| int | ove_mqtt_loop (ove_mqtt_client_t client, uint64_t timeout_ns) |
| | Process incoming packets and send keep-alive pings.
|
| |
| int | ove_mqtt_client_create (ove_mqtt_client_t *client) |
| | Heap-allocate and initialise an MQTT client.
|
| |
| void | ove_mqtt_client_destroy (ove_mqtt_client_t client) |
| | Destroy a heap-allocated MQTT client.
|
| |
Lightweight MQTT 3.1.1 client for IoT pub/sub messaging.
Supports CONNECT, PUBLISH (QoS 0/1), SUBSCRIBE, keep-alive, and optional TLS. Uses the oveRTOS socket layer for transport.
- Note
- Requires
CONFIG_OVE_NET_MQTT (implies CONFIG_OVE_NET). When disabled every function is replaced by a no-op stub.
◆ OVE_MQTT_QOS0
◆ OVE_MQTT_QOS1
◆ ove_mqtt_msg_cb
| typedef void(* ove_mqtt_msg_cb) (const char *topic, size_t topic_len, const void *payload, size_t payload_len, void *user_data) |
MQTT message callback.
- Parameters
-
| [in] | topic | Topic string (not NUL-terminated). |
| [in] | topic_len | Topic length in bytes. |
| [in] | payload | Message payload. |
| [in] | payload_len | Payload length in bytes. |
| [in] | user_data | Opaque pointer supplied at connect time. |
◆ ove_mqtt_client_init()
| int ove_mqtt_client_init |
( |
ove_mqtt_client_t * |
client, |
|
|
ove_mqtt_client_storage_t * |
storage |
|
) |
| |
Initialise an MQTT client from caller-supplied storage.
- Parameters
-
| [out] | client | Handle written on success. |
| [in] | storage | Caller-allocated storage. |
- Returns
- OVE_OK on success, negative error code on failure.
◆ ove_mqtt_client_deinit()
De-initialise an MQTT client.
- Parameters
-
◆ ove_mqtt_connect()
Connect to an MQTT broker.
- Parameters
-
| [in] | client | MQTT client handle. |
| [in] | cfg | Connection configuration. |
- Returns
- OVE_OK on success, negative error code on failure.
◆ ove_mqtt_disconnect()
Disconnect from the MQTT broker.
- Parameters
-
| [in] | client | MQTT client handle. |
◆ ove_mqtt_publish()
Publish a message.
- Parameters
-
| [in] | client | MQTT client handle. |
| [in] | topic | Topic string (NUL-terminated). |
| [in] | payload | Message payload. |
| [in] | payload_len | Payload length in bytes. |
| [in] | qos | QoS level. |
- Returns
- OVE_OK on success, negative error code on failure.
◆ ove_mqtt_subscribe()
Subscribe to a topic.
- Parameters
-
| [in] | client | MQTT client handle. |
| [in] | topic | Topic filter (NUL-terminated). |
| [in] | qos | Maximum QoS level. |
- Returns
- OVE_OK on success, negative error code on failure.
◆ ove_mqtt_unsubscribe()
Unsubscribe from a topic.
- Parameters
-
| [in] | client | MQTT client handle. |
| [in] | topic | Topic filter (NUL-terminated). |
- Returns
- OVE_OK on success, negative error code on failure.
◆ ove_mqtt_loop()
Process incoming packets and send keep-alive pings.
Must be called periodically (typically in a loop or timer).
- Parameters
-
| [in] | client | MQTT client handle. |
| [in] | timeout_ns | Maximum time to wait for incoming data. |
- Returns
- OVE_OK on success, negative error code on failure.
◆ ove_mqtt_client_create()
Heap-allocate and initialise an MQTT client.
- Parameters
-
| [out] | client | Handle written on success. |
- Returns
- OVE_OK on success, negative error code on failure.
◆ ove_mqtt_client_destroy()
Destroy a heap-allocated MQTT client.
- Parameters
-