ESPHome  2024.10.2
Data Structures | Public Member Functions | Static Public Attributes | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes
esphome::mqtt::MQTTBackendESP32 Class Referencefinal

#include <mqtt_backend_esp32.h>

Inheritance diagram for esphome::mqtt::MQTTBackendESP32:
esphome::mqtt::MQTTBackend

Data Structures

struct  MqttClientDeleter
 

Public Member Functions

void set_keep_alive (uint16_t keep_alive) final
 
void set_client_id (const char *client_id) final
 
void set_clean_session (bool clean_session) final
 
void set_credentials (const char *username, const char *password) final
 
void set_will (const char *topic, uint8_t qos, bool retain, const char *payload) final
 
void set_server (network::IPAddress ip, uint16_t port) final
 
void set_server (const char *host, uint16_t port) final
 
void set_on_connect (std::function< on_connect_callback_t > &&callback) final
 
void set_on_disconnect (std::function< on_disconnect_callback_t > &&callback) final
 
void set_on_subscribe (std::function< on_subscribe_callback_t > &&callback) final
 
void set_on_unsubscribe (std::function< on_unsubscribe_callback_t > &&callback) final
 
void set_on_message (std::function< on_message_callback_t > &&callback) final
 
void set_on_publish (std::function< on_publish_user_callback_t > &&callback) final
 
bool connected () const final
 
void connect () final
 
void disconnect () final
 
bool subscribe (const char *topic, uint8_t qos) final
 
bool unsubscribe (const char *topic) final
 
bool publish (const char *topic, const char *payload, size_t length, uint8_t qos, bool retain) final
 
void loop () final
 
void set_ca_certificate (const std::string &cert)
 
void set_cl_certificate (const std::string &cert)
 
void set_cl_key (const std::string &key)
 
void set_skip_cert_cn_check (bool skip_check)
 
- Public Member Functions inherited from esphome::mqtt::MQTTBackend
virtual bool publish (const MQTTMessage &message)
 

Static Public Attributes

static const size_t MQTT_BUFFER_SIZE = 4096
 

Protected Types

using ClientHandler_ = std::unique_ptr< esp_mqtt_client, MqttClientDeleter >
 

Protected Member Functions

bool initialize_ ()
 
void mqtt_event_handler_ (const Event &event)
 

Static Protected Member Functions

static void mqtt_event_handler (void *handler_args, esp_event_base_t base, int32_t event_id, void *event_data)
 static - Dispatch event to instance method More...
 

Protected Attributes

ClientHandler_ handler_
 
bool is_connected_ {false}
 
bool is_initalized_ {false}
 
esp_mqtt_client_config_t mqtt_cfg_ {}
 
std::string host_
 
uint16_t port_
 
std::string username_
 
std::string password_
 
std::string lwt_topic_
 
std::string lwt_message_
 
uint8_t lwt_qos_
 
bool lwt_retain_
 
std::string client_id_
 
uint16_t keep_alive_
 
bool clean_session_
 
optional< std::string > ca_certificate_
 
optional< std::string > cl_certificate_
 
optional< std::string > cl_key_
 
bool skip_cert_cn_check_ {false}
 
CallbackManager< on_connect_callback_ton_connect_
 
CallbackManager< on_disconnect_callback_ton_disconnect_
 
CallbackManager< on_subscribe_callback_ton_subscribe_
 
CallbackManager< on_unsubscribe_callback_ton_unsubscribe_
 
CallbackManager< on_message_callback_ton_message_
 
CallbackManager< on_publish_user_callback_ton_publish_
 
std::queue< Eventmqtt_events_
 

Additional Inherited Members

- Public Types inherited from esphome::mqtt::MQTTBackend
using on_connect_callback_t = void(bool session_present)
 
using on_disconnect_callback_t = void(MQTTClientDisconnectReason reason)
 
using on_subscribe_callback_t = void(uint16_t packet_id, uint8_t qos)
 
using on_unsubscribe_callback_t = void(uint16_t packet_id)
 
using on_message_callback_t = void(const char *topic, const char *payload, size_t len, size_t index, size_t total)
 
using on_publish_user_callback_t = void(uint16_t packet_id)
 

Detailed Description

Definition at line 45 of file mqtt_backend_esp32.h.

Member Typedef Documentation

◆ ClientHandler_

using esphome::mqtt::MQTTBackendESP32::ClientHandler_ = std::unique_ptr<esp_mqtt_client, MqttClientDeleter>
protected

Definition at line 140 of file mqtt_backend_esp32.h.

Member Function Documentation

◆ connect()

void esphome::mqtt::MQTTBackendESP32::connect ( )
inlinefinalvirtual

Implements esphome::mqtt::MQTTBackend.

Definition at line 95 of file mqtt_backend_esp32.h.

◆ connected()

bool esphome::mqtt::MQTTBackendESP32::connected ( ) const
inlinefinalvirtual

Implements esphome::mqtt::MQTTBackend.

Definition at line 93 of file mqtt_backend_esp32.h.

◆ disconnect()

void esphome::mqtt::MQTTBackendESP32::disconnect ( )
inlinefinalvirtual

Implements esphome::mqtt::MQTTBackend.

Definition at line 102 of file mqtt_backend_esp32.h.

◆ initialize_()

bool esphome::mqtt::MQTTBackendESP32::initialize_ ( )
protected

Definition at line 15 of file mqtt_backend_esp32.cpp.

◆ loop()

void esphome::mqtt::MQTTBackendESP32::loop ( )
finalvirtual

Reimplemented from esphome::mqtt::MQTTBackend.

Definition at line 110 of file mqtt_backend_esp32.cpp.

◆ mqtt_event_handler()

void esphome::mqtt::MQTTBackendESP32::mqtt_event_handler ( void *  handler_args,
esp_event_base_t  base,
int32_t  event_id,
void *  event_data 
)
staticprotected

static - Dispatch event to instance method

Definition at line 181 of file mqtt_backend_esp32.cpp.

◆ mqtt_event_handler_()

void esphome::mqtt::MQTTBackendESP32::mqtt_event_handler_ ( const Event event)
protected

Definition at line 120 of file mqtt_backend_esp32.cpp.

◆ publish()

bool esphome::mqtt::MQTTBackendESP32::publish ( const char *  topic,
const char *  payload,
size_t  length,
uint8_t  qos,
bool  retain 
)
inlinefinalvirtual

Implements esphome::mqtt::MQTTBackend.

Definition at line 112 of file mqtt_backend_esp32.h.

◆ set_ca_certificate()

void esphome::mqtt::MQTTBackendESP32::set_ca_certificate ( const std::string &  cert)
inline

Definition at line 127 of file mqtt_backend_esp32.h.

◆ set_cl_certificate()

void esphome::mqtt::MQTTBackendESP32::set_cl_certificate ( const std::string &  cert)
inline

Definition at line 128 of file mqtt_backend_esp32.h.

◆ set_cl_key()

void esphome::mqtt::MQTTBackendESP32::set_cl_key ( const std::string &  key)
inline

Definition at line 129 of file mqtt_backend_esp32.h.

◆ set_clean_session()

void esphome::mqtt::MQTTBackendESP32::set_clean_session ( bool  clean_session)
inlinefinalvirtual

Implements esphome::mqtt::MQTTBackend.

Definition at line 51 of file mqtt_backend_esp32.h.

◆ set_client_id()

void esphome::mqtt::MQTTBackendESP32::set_client_id ( const char *  client_id)
inlinefinalvirtual

Implements esphome::mqtt::MQTTBackend.

Definition at line 50 of file mqtt_backend_esp32.h.

◆ set_credentials()

void esphome::mqtt::MQTTBackendESP32::set_credentials ( const char *  username,
const char *  password 
)
inlinefinalvirtual

Implements esphome::mqtt::MQTTBackend.

Definition at line 53 of file mqtt_backend_esp32.h.

◆ set_keep_alive()

void esphome::mqtt::MQTTBackendESP32::set_keep_alive ( uint16_t  keep_alive)
inlinefinalvirtual

Implements esphome::mqtt::MQTTBackend.

Definition at line 49 of file mqtt_backend_esp32.h.

◆ set_on_connect()

void esphome::mqtt::MQTTBackendESP32::set_on_connect ( std::function< on_connect_callback_t > &&  callback)
inlinefinalvirtual

Implements esphome::mqtt::MQTTBackend.

Definition at line 75 of file mqtt_backend_esp32.h.

◆ set_on_disconnect()

void esphome::mqtt::MQTTBackendESP32::set_on_disconnect ( std::function< on_disconnect_callback_t > &&  callback)
inlinefinalvirtual

Implements esphome::mqtt::MQTTBackend.

Definition at line 78 of file mqtt_backend_esp32.h.

◆ set_on_message()

void esphome::mqtt::MQTTBackendESP32::set_on_message ( std::function< on_message_callback_t > &&  callback)
inlinefinalvirtual

Implements esphome::mqtt::MQTTBackend.

Definition at line 87 of file mqtt_backend_esp32.h.

◆ set_on_publish()

void esphome::mqtt::MQTTBackendESP32::set_on_publish ( std::function< on_publish_user_callback_t > &&  callback)
inlinefinalvirtual

Implements esphome::mqtt::MQTTBackend.

Definition at line 90 of file mqtt_backend_esp32.h.

◆ set_on_subscribe()

void esphome::mqtt::MQTTBackendESP32::set_on_subscribe ( std::function< on_subscribe_callback_t > &&  callback)
inlinefinalvirtual

Implements esphome::mqtt::MQTTBackend.

Definition at line 81 of file mqtt_backend_esp32.h.

◆ set_on_unsubscribe()

void esphome::mqtt::MQTTBackendESP32::set_on_unsubscribe ( std::function< on_unsubscribe_callback_t > &&  callback)
inlinefinalvirtual

Implements esphome::mqtt::MQTTBackend.

Definition at line 84 of file mqtt_backend_esp32.h.

◆ set_server() [1/2]

void esphome::mqtt::MQTTBackendESP32::set_server ( network::IPAddress  ip,
uint16_t  port 
)
inlinefinalvirtual

Implements esphome::mqtt::MQTTBackend.

Definition at line 67 of file mqtt_backend_esp32.h.

◆ set_server() [2/2]

void esphome::mqtt::MQTTBackendESP32::set_server ( const char *  host,
uint16_t  port 
)
inlinefinalvirtual

Implements esphome::mqtt::MQTTBackend.

Definition at line 71 of file mqtt_backend_esp32.h.

◆ set_skip_cert_cn_check()

void esphome::mqtt::MQTTBackendESP32::set_skip_cert_cn_check ( bool  skip_check)
inline

Definition at line 130 of file mqtt_backend_esp32.h.

◆ set_will()

void esphome::mqtt::MQTTBackendESP32::set_will ( const char *  topic,
uint8_t  qos,
bool  retain,
const char *  payload 
)
inlinefinalvirtual

Implements esphome::mqtt::MQTTBackend.

Definition at line 59 of file mqtt_backend_esp32.h.

◆ subscribe()

bool esphome::mqtt::MQTTBackendESP32::subscribe ( const char *  topic,
uint8_t  qos 
)
inlinefinalvirtual

Implements esphome::mqtt::MQTTBackend.

Definition at line 107 of file mqtt_backend_esp32.h.

◆ unsubscribe()

bool esphome::mqtt::MQTTBackendESP32::unsubscribe ( const char *  topic)
inlinefinalvirtual

Implements esphome::mqtt::MQTTBackend.

Definition at line 110 of file mqtt_backend_esp32.h.

Field Documentation

◆ ca_certificate_

optional<std::string> esphome::mqtt::MQTTBackendESP32::ca_certificate_
protected

Definition at line 159 of file mqtt_backend_esp32.h.

◆ cl_certificate_

optional<std::string> esphome::mqtt::MQTTBackendESP32::cl_certificate_
protected

Definition at line 160 of file mqtt_backend_esp32.h.

◆ cl_key_

optional<std::string> esphome::mqtt::MQTTBackendESP32::cl_key_
protected

Definition at line 161 of file mqtt_backend_esp32.h.

◆ clean_session_

bool esphome::mqtt::MQTTBackendESP32::clean_session_
protected

Definition at line 158 of file mqtt_backend_esp32.h.

◆ client_id_

std::string esphome::mqtt::MQTTBackendESP32::client_id_
protected

Definition at line 156 of file mqtt_backend_esp32.h.

◆ handler_

ClientHandler_ esphome::mqtt::MQTTBackendESP32::handler_
protected

Definition at line 141 of file mqtt_backend_esp32.h.

◆ host_

std::string esphome::mqtt::MQTTBackendESP32::host_
protected

Definition at line 148 of file mqtt_backend_esp32.h.

◆ is_connected_

bool esphome::mqtt::MQTTBackendESP32::is_connected_ {false}
protected

Definition at line 143 of file mqtt_backend_esp32.h.

◆ is_initalized_

bool esphome::mqtt::MQTTBackendESP32::is_initalized_ {false}
protected

Definition at line 144 of file mqtt_backend_esp32.h.

◆ keep_alive_

uint16_t esphome::mqtt::MQTTBackendESP32::keep_alive_
protected

Definition at line 157 of file mqtt_backend_esp32.h.

◆ lwt_message_

std::string esphome::mqtt::MQTTBackendESP32::lwt_message_
protected

Definition at line 153 of file mqtt_backend_esp32.h.

◆ lwt_qos_

uint8_t esphome::mqtt::MQTTBackendESP32::lwt_qos_
protected

Definition at line 154 of file mqtt_backend_esp32.h.

◆ lwt_retain_

bool esphome::mqtt::MQTTBackendESP32::lwt_retain_
protected

Definition at line 155 of file mqtt_backend_esp32.h.

◆ lwt_topic_

std::string esphome::mqtt::MQTTBackendESP32::lwt_topic_
protected

Definition at line 152 of file mqtt_backend_esp32.h.

◆ MQTT_BUFFER_SIZE

const size_t esphome::mqtt::MQTTBackendESP32::MQTT_BUFFER_SIZE = 4096
static

Definition at line 47 of file mqtt_backend_esp32.h.

◆ mqtt_cfg_

esp_mqtt_client_config_t esphome::mqtt::MQTTBackendESP32::mqtt_cfg_ {}
protected

Definition at line 146 of file mqtt_backend_esp32.h.

◆ mqtt_events_

std::queue<Event> esphome::mqtt::MQTTBackendESP32::mqtt_events_
protected

Definition at line 171 of file mqtt_backend_esp32.h.

◆ on_connect_

CallbackManager<on_connect_callback_t> esphome::mqtt::MQTTBackendESP32::on_connect_
protected

Definition at line 165 of file mqtt_backend_esp32.h.

◆ on_disconnect_

CallbackManager<on_disconnect_callback_t> esphome::mqtt::MQTTBackendESP32::on_disconnect_
protected

Definition at line 166 of file mqtt_backend_esp32.h.

◆ on_message_

CallbackManager<on_message_callback_t> esphome::mqtt::MQTTBackendESP32::on_message_
protected

Definition at line 169 of file mqtt_backend_esp32.h.

◆ on_publish_

CallbackManager<on_publish_user_callback_t> esphome::mqtt::MQTTBackendESP32::on_publish_
protected

Definition at line 170 of file mqtt_backend_esp32.h.

◆ on_subscribe_

CallbackManager<on_subscribe_callback_t> esphome::mqtt::MQTTBackendESP32::on_subscribe_
protected

Definition at line 167 of file mqtt_backend_esp32.h.

◆ on_unsubscribe_

CallbackManager<on_unsubscribe_callback_t> esphome::mqtt::MQTTBackendESP32::on_unsubscribe_
protected

Definition at line 168 of file mqtt_backend_esp32.h.

◆ password_

std::string esphome::mqtt::MQTTBackendESP32::password_
protected

Definition at line 151 of file mqtt_backend_esp32.h.

◆ port_

uint16_t esphome::mqtt::MQTTBackendESP32::port_
protected

Definition at line 149 of file mqtt_backend_esp32.h.

◆ skip_cert_cn_check_

bool esphome::mqtt::MQTTBackendESP32::skip_cert_cn_check_ {false}
protected

Definition at line 162 of file mqtt_backend_esp32.h.

◆ username_

std::string esphome::mqtt::MQTTBackendESP32::username_
protected

Definition at line 150 of file mqtt_backend_esp32.h.


The documentation for this class was generated from the following files: