Modbus Vault v1.0
Loading...
Searching...
No Matches
mqtt_bridge.h File Reference

MQTT abstraction layer. More...

#include "esp_err.h"
#include "mqtt_client.h"
Include dependency graph for mqtt_bridge.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  mqtt_bridge_config_t
 MQTT bridge configuration structure. More...
 
struct  mqtt_bridge_t
 MQTT bridge type structure. More...
 

Typedefs

typedef void(* mqtt_bridge_notify_cb_t) (bool)
 

Functions

esp_err_t mqtt_bridge_init (mqtt_bridge_t *mqtt_bridge_ptr, const mqtt_bridge_config_t *config_ptr)
 Initialize MQTT bridge.
 
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.
 
bool mqtt_bridge_is_connected (const mqtt_bridge_t *mqtt_bridge_ptr)
 Get MQTT connection status.
 
void mqtt_bridge_deinit (mqtt_bridge_t *mqtt_bridge_ptr)
 De-init MQTT bridge.
 

Detailed Description

MQTT abstraction layer.

Author
Abanoub Salah
  • Features:
    • Thread-safe publish interface
    • Connection state tracking
    • Topic abstraction
  • Designed to decouple application logic from ESP-MQTT.

Typedef Documentation

◆ mqtt_bridge_notify_cb_t

typedef void(* mqtt_bridge_notify_cb_t) (bool)

State change notify callback typedef

Function Documentation

◆ mqtt_bridge_deinit()

void mqtt_bridge_deinit ( mqtt_bridge_t mqtt_bridge_ptr)

De-init MQTT bridge.

Parameters
mqtt_bridge_ptrPointer to MQTT bridge instance
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mqtt_bridge_init()

esp_err_t mqtt_bridge_init ( mqtt_bridge_t mqtt_bridge_ptr,
const mqtt_bridge_config_t config_ptr 
)

Initialize MQTT bridge.

Initialize MQTT bridge by initiating MQTT client, register to events and start client

Parameters
mqtt_bridge_ptrPointer to MQTT bridge instance
config_ptrPointer to MQTT bridge configuration instance
Returns
esp_err_t Initialize result
Return values
ESP_OKInitialize success
ESP_FAILInitialize fail
ESP_ERR_INVALID_ARGProvided invalid argument(s)
ESP_ERR_NO_MEMNo available memory for resource allocation
Here is the call graph for this function:
Here is the caller graph for this function:

◆ mqtt_bridge_is_connected()

bool mqtt_bridge_is_connected ( const mqtt_bridge_t mqtt_bridge_ptr)

Get MQTT connection status.

Parameters
mqtt_bridge_ptrPointer to MQTT bridge instance
Returns
bool true if connected false otherwise
Note
If mqtt_bridge_ptr is not valid 'false' is returned
Here is the caller graph for this function:

◆ 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_ptrPointer to MQTT bridge instance
topic_ptrPointer to topic
data_ptrPointer to data to be published
lengthLength of data
qosMessage QoS
Returns
esp_err_t Publish result
Return values
ESP_OKPublish success
ESP_FAILPublish fail
ESP_ERR_INVALID_ARGProvided invalid argument(s)
ESP_ERR_TIMEOUTTimed out waiting for resource
Here is the call graph for this function:
Here is the caller graph for this function: