|
ESPHome 2026.2.1
|
Base class for BLE GATT clients that connect to remote devices. More...
#include <esp32_ble_tracker.h>
Public Member Functions | |
| virtual bool | gattc_event_handler (esp_gattc_cb_event_t event, esp_gatt_if_t gattc_if, esp_ble_gattc_cb_param_t *param)=0 |
| virtual void | gap_event_handler (esp_gap_ble_cb_event_t event, esp_ble_gap_cb_param_t *param)=0 |
| virtual void | connect ()=0 |
| virtual void | disconnect ()=0 |
| 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 | |
| virtual void | on_scan_end () |
| virtual bool | parse_device (const ESPBTDevice &device)=0 |
| virtual bool | parse_devices (const BLEScanResult *scan_results, size_t count) |
| virtual AdvertisementParserType | get_advertisement_parser_type () |
| void | set_parent (ESP32BLETracker *parent) |
Data Fields | |
| uint8_t | app_id |
Protected Member Functions | |
| void | set_state_internal_ (ClientState st) |
| Set state without IDLE handling - use for direct state transitions. | |
Protected Attributes | |
| bool | want_disconnect_ {false} |
Protected Attributes inherited from esphome::esp32_ble_tracker::ESPBTDeviceListener | |
| ESP32BLETracker * | parent_ {nullptr} |
Base class for BLE GATT clients that connect to remote devices.
ESP32BLETracker::loop() needs to know when client states change to avoid expensive polling. Rather than checking all clients every iteration (~7000/min), we use a version counter owned by ESP32BLETracker that clients increment on state changes. The tracker compares versions to skip work when nothing changed.
Ownership: ESP32BLETracker owns state_version_. Clients hold a non-owning pointer (tracker_state_version_) set during register_client(). Clients increment the counter through this pointer when their state changes. The pointer may be null if the client is not registered with a tracker.
Definition at line 232 of file esp32_ble_tracker.h.
|
inline |
Definition at line 240 of file esp32_ble_tracker.h.
|
pure virtual |
Implemented in esphome::esp32_ble_client::BLEClientBase.
|
pure virtual |
Implemented in esphome::esp32_ble_client::BLEClientBase.
|
inline |
Definition at line 239 of file esp32_ble_tracker.h.
|
pure virtual |
|
pure virtual |
|
inlinevirtual |
Set the client state with IDLE handling (clears want_disconnect_).
Notifies the tracker of state change for loop optimization.
Reimplemented in esphome::ble_client::BLEClient, and esphome::esp32_ble_client::BLEClientBase.
Definition at line 244 of file esp32_ble_tracker.h.
|
inlineprotected |
Set state without IDLE handling - use for direct state transitions.
Increments the tracker's state version counter to signal that loop() should do full processing on the next iteration.
Definition at line 264 of file esp32_ble_tracker.h.
|
inline |
Called by ESP32BLETracker::register_client() to enable state change notifications.
The pointer must remain valid for the lifetime of the client (guaranteed since ESP32BLETracker is a singleton that outlives all clients).
Definition at line 255 of file esp32_ble_tracker.h.
|
inline |
Definition at line 250 of file esp32_ble_tracker.h.
| uint8_t esphome::esp32_ble_tracker::ESPBTClient::app_id |
Definition at line 258 of file esp32_ble_tracker.h.
|
protected |
Definition at line 276 of file esp32_ble_tracker.h.