MQTT abstraction layer.
More...
#include "esp_err.h"
#include "mqtt_client.h"
Go to the source code of this file.
MQTT abstraction layer.
- Author
- Abanoub Salah
- Features:
- Thread-safe publish interface
- Connection state tracking
- Topic abstraction
- Designed to decouple application logic from ESP-MQTT.
◆ mqtt_bridge_notify_cb_t
| typedef void(* mqtt_bridge_notify_cb_t) (bool) |
State change notify callback typedef
◆ mqtt_bridge_deinit()
De-init MQTT bridge.
- Parameters
-
| mqtt_bridge_ptr | Pointer to MQTT bridge instance |
◆ mqtt_bridge_init()
Initialize MQTT bridge.
Initialize MQTT bridge by initiating MQTT client, register to events and start client
- Parameters
-
| mqtt_bridge_ptr | Pointer to MQTT bridge instance |
| config_ptr | Pointer to MQTT bridge configuration instance |
- Returns
- esp_err_t Initialize result
- Return values
-
| ESP_OK | Initialize success |
| ESP_FAIL | Initialize fail |
| ESP_ERR_INVALID_ARG | Provided invalid argument(s) |
| ESP_ERR_NO_MEM | No available memory for resource allocation |
◆ mqtt_bridge_is_connected()
| bool mqtt_bridge_is_connected |
( |
const mqtt_bridge_t * |
mqtt_bridge_ptr | ) |
|
Get MQTT connection status.
- Parameters
-
| mqtt_bridge_ptr | Pointer to MQTT bridge instance |
- Returns
- bool true if connected false otherwise
- Note
- If mqtt_bridge_ptr is not valid 'false' is returned
◆ mqtt_bridge_publish()
| esp_err_t mqtt_bridge_publish |
( |
const mqtt_bridge_t * |
mqtt_bridge_ptr, |
|
|
const char * |
topic_ptr, |
|
|
const char * |
data_ptr, |
|
|
size_t |
length, |
|
|
int32_t |
qos |
|
) |
| |
Publish to MQTT topic.
- Parameters
-
| mqtt_bridge_ptr | Pointer to MQTT bridge instance |
| topic_ptr | Pointer to topic |
| data_ptr | Pointer to data to be published |
| length | Length of data |
| qos | Message QoS |
- Returns
- esp_err_t Publish result
- Return values
-
| ESP_OK | Publish success |
| ESP_FAIL | Publish fail |
| ESP_ERR_INVALID_ARG | Provided invalid argument(s) |
| ESP_ERR_TIMEOUT | Timed out waiting for resource |