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

Implementation of the mqtt bridge. More...

#include "mqtt_bridge.h"
#include "esp_log.h"
#include "esp_timer.h"
#include "metrics.h"
Include dependency graph for mqtt_bridge.c:

Functions

static void mqtt_event_handler (void *args_void_ptr, esp_event_base_t base, int32_t event_id, void *event_data_void_ptr)
 MQTT event handler.
 
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 *const mqtt_bridge_ptr)
 Get MQTT connection status.
 
void mqtt_bridge_deinit (mqtt_bridge_t *mqtt_bridge_ptr)
 De-init MQTT bridge.
 

Variables

static const char * TAG = "MQTT_BRIDGE"
 

Detailed Description

Implementation of the mqtt bridge.

  • Initiate ESP MQTT using provided configuration
  • Facilitate while connected
  • Calls registered callback on MQTT connect/disconnect event

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:

◆ mqtt_event_handler()

static void mqtt_event_handler ( void *  args_void_ptr,
esp_event_base_t  base,
int32_t  event_id,
void *  event_data_void_ptr 
)
static

MQTT event handler.

Handles MQTT connect/disconnect events

Parameters
args_void_ptrVoid pointer to handler arguments
baseESP event base
event_idEvent id
event_data_void_ptrVoid pointer to event data
Here is the caller graph for this function:

Variable Documentation

◆ TAG

const char* TAG = "MQTT_BRIDGE"
static

MQTT Bridge TAG name