ESPHome 2026.8.0b4
Loading...
Searching...
No Matches
esphome::bluetooth_connection::BluedroidGattClient Class Referencefinal

#include <bluetooth_connection_bluedroid.h>

Inheritance diagram for esphome::bluetooth_connection::BluedroidGattClient:
esphome::esp32_ble_tracker::ESPBTClient esphome::Component esphome::esp32_ble_tracker::ESPBTDeviceListener esphome::ble_device_base::ESPBTDeviceListener

Public Types

enum class  SearchState : uint8_t {
  NONE , PRESTARTED , PRESTART_DONE , CLAIMED ,
  REPORT_PENDING
}
 

Public Member Functions

void setup () override
 
void loop () override
 
void dump_config () override
 
float get_setup_priority () const override
 
void set_listener (ble_device_base::GattClientListener *listener)
 
bool gattc_event_handler (esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param) override
 
void gap_event_handler (esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param) override
 
void connect () override
 
void disconnect () override
 
bool wants_parsed_advertisements () override
 
void on_scan_end () override
 
bool parse_device (const ble_device_base::ESPBTDevice &device) override
 
int connect (uint64_t address, uint8_t addr_type)
 
int gatt_disconnect ()
 
bool cancel_gatt_disconnect ()
 
int discover_services ()
 
int read_characteristic (uint16_t handle)
 
int write_characteristic (uint16_t handle, const uint8_t *data, uint16_t len, bool response)
 
int read_descriptor (uint16_t handle)
 
int write_descriptor (uint16_t handle, const uint8_t *data, uint16_t len)
 
int notify_characteristic (uint16_t handle, bool enable)
 
int pair ()
 
int update_connection_params (uint16_t min_interval, uint16_t max_interval, uint16_t latency, uint16_t timeout)
 
ble_device_base::GattServiceTable get_service_table ()
 
void release_services ()
 
void stream_service_batch (BluetoothConnection &conn)
 In-place service streamer (the proxy wrapper detects and prefers it): builds one api response batch directly from Bluedroid's cached database, so the streaming peak is the response itself - the old esp32 model.
 
void set_connection_type (ble_device_base::ConnectionType ct)
 
- Public Member Functions inherited from esphome::esp32_ble_tracker::ESPBTClient
bool disconnect_pending () const
 
void cancel_pending_disconnect ()
 
virtual void set_state (ClientState st)
 Set the client state with IDLE handling (clears want_disconnect_).
 
ClientState state () const
 
void set_tracker_state_version (uint8_t *version)
 Called by ESP32BLETracker::register_client() to enable state change notifications.
 
- Public Member Functions inherited from esphome::esp32_ble_tracker::ESPBTDeviceListener
bool parse_device (const ble_device_base::ESPBTDevice &device) override
 
void set_parent (ESP32BLETracker *parent)
 
- Public Member Functions inherited from esphome::ble_device_base::ESPBTDeviceListener
virtual ~ESPBTDeviceListener ()=default
 
- Public Member Functions inherited from esphome::Component
float get_actual_setup_priority () const
 
void set_setup_priority (float priority)
 
void call ()
 
virtual void on_shutdown ()
 
virtual void on_safe_shutdown ()
 
virtual bool teardown ()
 Called during teardown to allow component to gracefully finish operations.
 
virtual void on_powerdown ()
 Called after teardown is complete to power down hardware.
 
uint8_t get_component_state () const
 
void reset_to_construction_state ()
 Reset this component back to the construction state to allow setup to run again.
 
bool is_in_loop_state () const
 Check if this component has completed setup and is in the loop state.
 
bool is_idle () const
 Check if this component is idle.
 
void mark_failed ()
 Mark this component as failed.
 
void mark_failed (const LogString *message)
 
void disable_loop ()
 Disable this component's loop.
 
void enable_loop ()
 Enable this component's loop.
 
void enable_loop_soon_any_context ()
 Thread and ISR-safe version of enable_loop() that can be called from any context.
 
bool is_failed () const
 
bool is_ready () const
 
virtual bool can_proceed ()
 
bool status_has_warning () const
 
bool status_has_error () const
 
void status_set_warning ()
 
void status_set_warning (const char *message)
 
void status_set_warning (const LogString *message)
 
void status_set_error ()
 
void status_set_error (const LogString *message)
 
void status_clear_warning ()
 
void status_clear_error ()
 
void status_momentary_warning (const char *name, uint32_t length=5000)
 Set warning status flag and automatically clear it after a timeout.
 
void status_momentary_error (const char *name, uint32_t length=5000)
 Set error status flag and automatically clear it after a timeout.
 
bool has_overridden_loop () const
 
const LogString * get_component_log_str () const ESPHOME_ALWAYS_INLINE
 Get the integration where this component was declared as a LogString for logging.
 
bool should_warn_of_blocking (uint32_t blocking_time, uint32_t &threshold_ms_out)
 

Static Public Attributes

static constexpr uint16_t UNSET_CONN_ID = 0xFFFF
 

Protected Member Functions

bool check_addr_ (const esp_bd_addr_t &addr) const
 
void tracker_connect_ ()
 
void handle_open_evt_ (esp_ble_gattc_cb_param_t *param)
 
void handle_disconnect_evt_ (esp_ble_gattc_cb_param_t *param)
 
int handle_search_cmpl_ (esp_gatt_status_t status)
 
void deliver_pending_search_ ()
 
void unconditional_disconnect_ ()
 
void set_idle_ ()
 
void set_disconnecting_ ()
 
esp_err_t update_conn_params_ (uint16_t min_interval, uint16_t max_interval, uint16_t latency, uint16_t timeout, const char *param_type)
 
int check_and_log_error_ (const char *operation, esp_err_t err)
 
void log_gattc_warning_ (const char *operation, int code)
 
- Protected Member Functions inherited from esphome::esp32_ble_tracker::ESPBTClient
void set_state_internal_ (ClientState st)
 Set state without IDLE handling - use for direct state transitions.
 
- Protected Member Functions inherited from esphome::Component
friend void::setup ()
 
friend void::original_setup ()
 
void set_component_source_ (uint8_t index)
 Set where this component was loaded from for some debug messages.
 
virtual void call_setup ()
 
void call_dump_config_ ()
 
void enable_loop_slow_path_ ()
 
void set_component_state_ (uint8_t state)
 Helper to set component state (clears state bits and sets new state)
 
bool set_status_flag_ (uint8_t flag)
 Helper to set a status LED flag on both this component and the app.
 
void set_interval (const char *name, uint32_t interval, std::function< void()> &&f)
 Set an interval function with a const char* name.
 
void set_interval (uint32_t id, uint32_t interval, std::function< void()> &&f)
 Set an interval function with a numeric ID (zero heap allocation).
 
void set_interval (InternalSchedulerID id, uint32_t interval, std::function< void()> &&f)
 
void set_interval (uint32_t interval, std::function< void()> &&f)
 
bool cancel_interval (const char *name)
 Cancel an interval function.
 
bool cancel_interval (uint32_t id)
 
bool cancel_interval (InternalSchedulerID id)
 
void set_timeout (const char *name, uint32_t timeout, std::function< void()> &&f)
 Set a timeout function with a const char* name.
 
void set_timeout (uint32_t id, uint32_t timeout, std::function< void()> &&f)
 Set a timeout function with a numeric ID (zero heap allocation).
 
void set_timeout (InternalSchedulerID id, uint32_t timeout, std::function< void()> &&f)
 
void set_timeout (uint32_t timeout, std::function< void()> &&f)
 
bool cancel_timeout (const char *name)
 Cancel a timeout function.
 
bool cancel_timeout (uint32_t id)
 
bool cancel_timeout (InternalSchedulerID id)
 
void defer (const char *name, std::function< void()> &&f)
 Defer a callback to the next loop() call with a const char* name.
 
void defer (std::function< void()> &&f)
 Defer a callback to the next loop() call.
 
void defer (uint32_t id, std::function< void()> &&f)
 Defer a callback with a numeric ID (zero heap allocation)
 
bool cancel_defer (const char *name)
 Cancel a defer callback using the specified name, name must not be empty.
 
bool cancel_defer (uint32_t id)
 
void status_clear_warning_slow_path_ ()
 
void status_clear_error_slow_path_ ()
 

Protected Attributes

ble_device_base::GattClientListenerlistener_ {nullptr}
 
uint32_t disconnecting_started_ {0}
 
esp_bd_addr_t remote_bda_ {}
 
uint16_t conn_id_ {UNSET_CONN_ID}
 
uint16_t service_total_ {0}
 
esp_gatt_if_t gattc_if_ {ESP_GATT_IF_NONE}
 
uint8_t remote_addr_type_ {0}
 
esp32_ble_tracker::ConnectionType connection_type_ {esp32_ble_tracker::ConnectionType::V3_WITHOUT_CACHE}
 
uint8_t connection_index_ {0}
 
bool services_released_: 1 {false}
 
bool seen_mtu_: 1 {false}
 
bool mtu_failed_: 1 {false}
 
SearchState search_state_: 4 {SearchState::NONE}
 
uint8_t search_status_ {0}
 
- Protected Attributes inherited from esphome::esp32_ble_tracker::ESPBTClient
bool want_disconnect_ {false}
 
- Protected Attributes inherited from esphome::esp32_ble_tracker::ESPBTDeviceListener
ESP32BLETrackerparent_ {nullptr}
 
- Protected Attributes inherited from esphome::Component
uint8_t component_source_index_ {0}
 Index into component source PROGMEM lookup table (0 = not set)
 
uint8_t warn_if_blocking_over_ {WARN_IF_BLOCKING_OVER_CS}
 Warn threshold in centiseconds (max 2550ms)
 
uint8_t component_state_ {0x00}
 State of this component - each bit has a purpose: Bits 0-2: Component state (0x00=CONSTRUCTION, 0x01=SETUP, 0x02=LOOP, 0x03=FAILED, 0x04=LOOP_DONE) Bit 3: STATUS_LED_WARNING Bit 4: STATUS_LED_ERROR Bit 5: Has overridden loop() (set at registration time) Bits 6-7: Unused - reserved for future expansion.
 
volatile bool pending_enable_loop_ {false}
 ISR-safe flag for enable_loop_soon_any_context.
 
ComponentRuntimeStats runtime_stats_
 

Additional Inherited Members

- Data Fields inherited from esphome::esp32_ble_tracker::ESPBTClient
uint8_t app_id
 

Detailed Description

Definition at line 32 of file bluetooth_connection_bluedroid.h.

Member Enumeration Documentation

◆ SearchState

Enumerator
NONE 
PRESTARTED 
PRESTART_DONE 
CLAIMED 
REPORT_PENDING 

Definition at line 37 of file bluetooth_connection_bluedroid.h.

Member Function Documentation

◆ cancel_gatt_disconnect()

bool esphome::bluetooth_connection::BluedroidGattClient::cancel_gatt_disconnect ( )

Definition at line 197 of file bluetooth_connection_bluedroid.cpp.

◆ check_addr_()

bool esphome::bluetooth_connection::BluedroidGattClient::check_addr_ ( const esp_bd_addr_t & addr) const
protected

Definition at line 317 of file bluetooth_connection_bluedroid.cpp.

◆ check_and_log_error_()

int esphome::bluetooth_connection::BluedroidGattClient::check_and_log_error_ ( const char * operation,
esp_err_t err )
protected

Definition at line 347 of file bluetooth_connection_bluedroid.cpp.

◆ connect() [1/2]

void esphome::bluetooth_connection::BluedroidGattClient::connect ( )
overridevirtual

◆ connect() [2/2]

int esphome::bluetooth_connection::BluedroidGattClient::connect ( uint64_t address,
uint8_t addr_type )

Definition at line 99 of file bluetooth_connection_bluedroid.cpp.

◆ deliver_pending_search_()

void esphome::bluetooth_connection::BluedroidGattClient::deliver_pending_search_ ( )
protected

Definition at line 387 of file bluetooth_connection_bluedroid.cpp.

◆ disconnect()

void esphome::bluetooth_connection::BluedroidGattClient::disconnect ( )
overridevirtual

◆ discover_services()

int esphome::bluetooth_connection::BluedroidGattClient::discover_services ( )

Definition at line 208 of file bluetooth_connection_bluedroid.cpp.

◆ dump_config()

void esphome::bluetooth_connection::BluedroidGattClient::dump_config ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 90 of file bluetooth_connection_bluedroid.cpp.

◆ gap_event_handler()

void esphome::bluetooth_connection::BluedroidGattClient::gap_event_handler ( esp_gap_ble_cb_event_t event,
esp_ble_gap_cb_param_t * param )
overridevirtual

◆ gatt_disconnect()

int esphome::bluetooth_connection::BluedroidGattClient::gatt_disconnect ( )

Definition at line 152 of file bluetooth_connection_bluedroid.cpp.

◆ gattc_event_handler()

bool esphome::bluetooth_connection::BluedroidGattClient::gattc_event_handler ( esp_gattc_cb_event_t event,
esp_gatt_if_t gattc_if,
esp_ble_gattc_cb_param_t * param )
overridevirtual

◆ get_service_table()

ble_device_base::GattServiceTable esphome::bluetooth_connection::BluedroidGattClient::get_service_table ( )
inline

Definition at line 79 of file bluetooth_connection_bluedroid.h.

◆ get_setup_priority()

float esphome::bluetooth_connection::BluedroidGattClient::get_setup_priority ( ) const
inlineoverridevirtual

Reimplemented from esphome::Component.

Definition at line 48 of file bluetooth_connection_bluedroid.h.

◆ handle_disconnect_evt_()

void esphome::bluetooth_connection::BluedroidGattClient::handle_disconnect_evt_ ( esp_ble_gattc_cb_param_t * param)
protected

Definition at line 597 of file bluetooth_connection_bluedroid.cpp.

◆ handle_open_evt_()

void esphome::bluetooth_connection::BluedroidGattClient::handle_open_evt_ ( esp_ble_gattc_cb_param_t * param)
protected

Definition at line 542 of file bluetooth_connection_bluedroid.cpp.

◆ handle_search_cmpl_()

int esphome::bluetooth_connection::BluedroidGattClient::handle_search_cmpl_ ( esp_gatt_status_t status)
protected

Definition at line 360 of file bluetooth_connection_bluedroid.cpp.

◆ log_gattc_warning_()

void esphome::bluetooth_connection::BluedroidGattClient::log_gattc_warning_ ( const char * operation,
int code )
protected

Definition at line 354 of file bluetooth_connection_bluedroid.cpp.

◆ loop()

void esphome::bluetooth_connection::BluedroidGattClient::loop ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 46 of file bluetooth_connection_bluedroid.cpp.

◆ notify_characteristic()

int esphome::bluetooth_connection::BluedroidGattClient::notify_characteristic ( uint16_t handle,
bool enable )

Definition at line 276 of file bluetooth_connection_bluedroid.cpp.

◆ on_scan_end()

void esphome::bluetooth_connection::BluedroidGattClient::on_scan_end ( )
inlineoverridevirtual

◆ pair()

int esphome::bluetooth_connection::BluedroidGattClient::pair ( )

Definition at line 289 of file bluetooth_connection_bluedroid.cpp.

◆ parse_device()

bool esphome::bluetooth_connection::BluedroidGattClient::parse_device ( const ble_device_base::ESPBTDevice & device)
inlineoverridevirtual

◆ read_characteristic()

int esphome::bluetooth_connection::BluedroidGattClient::read_characteristic ( uint16_t handle)

Definition at line 237 of file bluetooth_connection_bluedroid.cpp.

◆ read_descriptor()

int esphome::bluetooth_connection::BluedroidGattClient::read_descriptor ( uint16_t handle)

Definition at line 257 of file bluetooth_connection_bluedroid.cpp.

◆ release_services()

void esphome::bluetooth_connection::BluedroidGattClient::release_services ( )

Definition at line 301 of file bluetooth_connection_bluedroid.cpp.

◆ set_connection_type()

void esphome::bluetooth_connection::BluedroidGattClient::set_connection_type ( ble_device_base::ConnectionType ct)
inline

Definition at line 89 of file bluetooth_connection_bluedroid.h.

◆ set_disconnecting_()

void esphome::bluetooth_connection::BluedroidGattClient::set_disconnecting_ ( )
protected

Definition at line 328 of file bluetooth_connection_bluedroid.cpp.

◆ set_idle_()

void esphome::bluetooth_connection::BluedroidGattClient::set_idle_ ( )
protected

Definition at line 321 of file bluetooth_connection_bluedroid.cpp.

◆ set_listener()

void esphome::bluetooth_connection::BluedroidGattClient::set_listener ( ble_device_base::GattClientListener * listener)
inline

Definition at line 51 of file bluetooth_connection_bluedroid.h.

◆ setup()

void esphome::bluetooth_connection::BluedroidGattClient::setup ( )
overridevirtual

Reimplemented from esphome::Component.

Definition at line 41 of file bluetooth_connection_bluedroid.cpp.

◆ stream_service_batch()

void esphome::bluetooth_connection::BluedroidGattClient::stream_service_batch ( BluetoothConnection & conn)

In-place service streamer (the proxy wrapper detects and prefers it): builds one api response batch directly from Bluedroid's cached database, so the streaming peak is the response itself - the old esp32 model.

Definition at line 402 of file bluetooth_connection_bluedroid.cpp.

◆ tracker_connect_()

void esphome::bluetooth_connection::BluedroidGattClient::tracker_connect_ ( )
protected

Definition at line 114 of file bluetooth_connection_bluedroid.cpp.

◆ unconditional_disconnect_()

void esphome::bluetooth_connection::BluedroidGattClient::unconditional_disconnect_ ( )
protected

Definition at line 179 of file bluetooth_connection_bluedroid.cpp.

◆ update_conn_params_()

esp_err_t esphome::bluetooth_connection::BluedroidGattClient::update_conn_params_ ( uint16_t min_interval,
uint16_t max_interval,
uint16_t latency,
uint16_t timeout,
const char * param_type )
protected

Definition at line 335 of file bluetooth_connection_bluedroid.cpp.

◆ update_connection_params()

int esphome::bluetooth_connection::BluedroidGattClient::update_connection_params ( uint16_t min_interval,
uint16_t max_interval,
uint16_t latency,
uint16_t timeout )

Definition at line 296 of file bluetooth_connection_bluedroid.cpp.

◆ wants_parsed_advertisements()

bool esphome::bluetooth_connection::BluedroidGattClient::wants_parsed_advertisements ( )
inlineoverridevirtual

Reimplemented from esphome::esp32_ble_tracker::ESPBTClient.

Definition at line 59 of file bluetooth_connection_bluedroid.h.

◆ write_characteristic()

int esphome::bluetooth_connection::BluedroidGattClient::write_characteristic ( uint16_t handle,
const uint8_t * data,
uint16_t len,
bool response )

Definition at line 245 of file bluetooth_connection_bluedroid.cpp.

◆ write_descriptor()

int esphome::bluetooth_connection::BluedroidGattClient::write_descriptor ( uint16_t handle,
const uint8_t * data,
uint16_t len )

Definition at line 266 of file bluetooth_connection_bluedroid.cpp.

Field Documentation

◆ conn_id_

uint16_t esphome::bluetooth_connection::BluedroidGattClient::conn_id_ {UNSET_CONN_ID}
protected

Definition at line 115 of file bluetooth_connection_bluedroid.h.

◆ connection_index_

uint8_t esphome::bluetooth_connection::BluedroidGattClient::connection_index_ {0}
protected

Definition at line 123 of file bluetooth_connection_bluedroid.h.

◆ connection_type_

esp32_ble_tracker::ConnectionType esphome::bluetooth_connection::BluedroidGattClient::connection_type_ {esp32_ble_tracker::ConnectionType::V3_WITHOUT_CACHE}
protected

Definition at line 122 of file bluetooth_connection_bluedroid.h.

◆ disconnecting_started_

uint32_t esphome::bluetooth_connection::BluedroidGattClient::disconnecting_started_ {0}
protected

Definition at line 109 of file bluetooth_connection_bluedroid.h.

◆ gattc_if_

esp_gatt_if_t esphome::bluetooth_connection::BluedroidGattClient::gattc_if_ {ESP_GATT_IF_NONE}
protected

Definition at line 119 of file bluetooth_connection_bluedroid.h.

◆ listener_

ble_device_base::GattClientListener* esphome::bluetooth_connection::BluedroidGattClient::listener_ {nullptr}
protected

Definition at line 107 of file bluetooth_connection_bluedroid.h.

◆ mtu_failed_

bool esphome::bluetooth_connection::BluedroidGattClient::mtu_failed_
protected

Definition at line 131 of file bluetooth_connection_bluedroid.h.

◆ remote_addr_type_

uint8_t esphome::bluetooth_connection::BluedroidGattClient::remote_addr_type_ {0}
protected

Definition at line 121 of file bluetooth_connection_bluedroid.h.

◆ remote_bda_

esp_bd_addr_t esphome::bluetooth_connection::BluedroidGattClient::remote_bda_ {}
protected

Definition at line 112 of file bluetooth_connection_bluedroid.h.

◆ search_state_

SearchState esphome::bluetooth_connection::BluedroidGattClient::search_state_
protected

Definition at line 135 of file bluetooth_connection_bluedroid.h.

◆ search_status_

uint8_t esphome::bluetooth_connection::BluedroidGattClient::search_status_ {0}
protected

Definition at line 137 of file bluetooth_connection_bluedroid.h.

◆ seen_mtu_

bool esphome::bluetooth_connection::BluedroidGattClient::seen_mtu_
protected

Definition at line 129 of file bluetooth_connection_bluedroid.h.

◆ service_total_

uint16_t esphome::bluetooth_connection::BluedroidGattClient::service_total_ {0}
protected

Definition at line 116 of file bluetooth_connection_bluedroid.h.

◆ services_released_

bool esphome::bluetooth_connection::BluedroidGattClient::services_released_
protected

Definition at line 126 of file bluetooth_connection_bluedroid.h.

◆ UNSET_CONN_ID

uint16_t esphome::bluetooth_connection::BluedroidGattClient::UNSET_CONN_ID = 0xFFFF
staticconstexpr

Definition at line 34 of file bluetooth_connection_bluedroid.h.


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