ESPHome  2024.10.2
Public Types | Public Member Functions
esphome::mqtt::MQTTBackend Class Referenceabstract

#include <mqtt_backend.h>

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

Public Types

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)
 

Public Member Functions

virtual void set_keep_alive (uint16_t keep_alive)=0
 
virtual void set_client_id (const char *client_id)=0
 
virtual void set_clean_session (bool clean_session)=0
 
virtual void set_credentials (const char *username, const char *password)=0
 
virtual void set_will (const char *topic, uint8_t qos, bool retain, const char *payload)=0
 
virtual void set_server (network::IPAddress ip, uint16_t port)=0
 
virtual void set_server (const char *host, uint16_t port)=0
 
virtual void set_on_connect (std::function< on_connect_callback_t > &&callback)=0
 
virtual void set_on_disconnect (std::function< on_disconnect_callback_t > &&callback)=0
 
virtual void set_on_subscribe (std::function< on_subscribe_callback_t > &&callback)=0
 
virtual void set_on_unsubscribe (std::function< on_unsubscribe_callback_t > &&callback)=0
 
virtual void set_on_message (std::function< on_message_callback_t > &&callback)=0
 
virtual void set_on_publish (std::function< on_publish_user_callback_t > &&callback)=0
 
virtual bool connected () const =0
 
virtual void connect ()=0
 
virtual void disconnect ()=0
 
virtual bool subscribe (const char *topic, uint8_t qos)=0
 
virtual bool unsubscribe (const char *topic)=0
 
virtual bool publish (const char *topic, const char *payload, size_t length, uint8_t qos, bool retain)=0
 
virtual bool publish (const MQTTMessage &message)
 
virtual void loop ()
 

Detailed Description

Definition at line 31 of file mqtt_backend.h.

Member Typedef Documentation

◆ on_connect_callback_t

using esphome::mqtt::MQTTBackend::on_connect_callback_t = void(bool session_present)

Definition at line 33 of file mqtt_backend.h.

◆ on_disconnect_callback_t

Definition at line 34 of file mqtt_backend.h.

◆ on_message_callback_t

using esphome::mqtt::MQTTBackend::on_message_callback_t = void(const char *topic, const char *payload, size_t len, size_t index, size_t total)

Definition at line 37 of file mqtt_backend.h.

◆ on_publish_user_callback_t

Definition at line 38 of file mqtt_backend.h.

◆ on_subscribe_callback_t

using esphome::mqtt::MQTTBackend::on_subscribe_callback_t = void(uint16_t packet_id, uint8_t qos)

Definition at line 35 of file mqtt_backend.h.

◆ on_unsubscribe_callback_t

Definition at line 36 of file mqtt_backend.h.

Member Function Documentation

◆ connect()

virtual void esphome::mqtt::MQTTBackend::connect ( )
pure virtual

◆ connected()

virtual bool esphome::mqtt::MQTTBackend::connected ( ) const
pure virtual

◆ disconnect()

virtual void esphome::mqtt::MQTTBackend::disconnect ( )
pure virtual

◆ loop()

virtual void esphome::mqtt::MQTTBackend::loop ( )
inlinevirtual

Reimplemented in esphome::mqtt::MQTTBackendESP32.

Definition at line 66 of file mqtt_backend.h.

◆ publish() [1/2]

virtual bool esphome::mqtt::MQTTBackend::publish ( const char *  topic,
const char *  payload,
size_t  length,
uint8_t  qos,
bool  retain 
)
pure virtual

◆ publish() [2/2]

virtual bool esphome::mqtt::MQTTBackend::publish ( const MQTTMessage message)
inlinevirtual

Definition at line 60 of file mqtt_backend.h.

◆ set_clean_session()

virtual void esphome::mqtt::MQTTBackend::set_clean_session ( bool  clean_session)
pure virtual

◆ set_client_id()

virtual void esphome::mqtt::MQTTBackend::set_client_id ( const char *  client_id)
pure virtual

◆ set_credentials()

virtual void esphome::mqtt::MQTTBackend::set_credentials ( const char *  username,
const char *  password 
)
pure virtual

◆ set_keep_alive()

virtual void esphome::mqtt::MQTTBackend::set_keep_alive ( uint16_t  keep_alive)
pure virtual

◆ set_on_connect()

virtual void esphome::mqtt::MQTTBackend::set_on_connect ( std::function< on_connect_callback_t > &&  callback)
pure virtual

◆ set_on_disconnect()

virtual void esphome::mqtt::MQTTBackend::set_on_disconnect ( std::function< on_disconnect_callback_t > &&  callback)
pure virtual

◆ set_on_message()

virtual void esphome::mqtt::MQTTBackend::set_on_message ( std::function< on_message_callback_t > &&  callback)
pure virtual

◆ set_on_publish()

virtual void esphome::mqtt::MQTTBackend::set_on_publish ( std::function< on_publish_user_callback_t > &&  callback)
pure virtual

◆ set_on_subscribe()

virtual void esphome::mqtt::MQTTBackend::set_on_subscribe ( std::function< on_subscribe_callback_t > &&  callback)
pure virtual

◆ set_on_unsubscribe()

virtual void esphome::mqtt::MQTTBackend::set_on_unsubscribe ( std::function< on_unsubscribe_callback_t > &&  callback)
pure virtual

◆ set_server() [1/2]

virtual void esphome::mqtt::MQTTBackend::set_server ( network::IPAddress  ip,
uint16_t  port 
)
pure virtual

◆ set_server() [2/2]

virtual void esphome::mqtt::MQTTBackend::set_server ( const char *  host,
uint16_t  port 
)
pure virtual

◆ set_will()

virtual void esphome::mqtt::MQTTBackend::set_will ( const char *  topic,
uint8_t  qos,
bool  retain,
const char *  payload 
)
pure virtual

◆ subscribe()

virtual bool esphome::mqtt::MQTTBackend::subscribe ( const char *  topic,
uint8_t  qos 
)
pure virtual

◆ unsubscribe()

virtual bool esphome::mqtt::MQTTBackend::unsubscribe ( const char *  topic)
pure virtual

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