ESPHome 2026.8.0-dev
Loading...
Searching...
No Matches
ble_hub.h
Go to the documentation of this file.
1// ble_hub.h
2//
3// BLEHub — the platform-neutral BLE tracker contract.
4//
5// Every BLE tracker component (esp32_ble_tracker, bk72xx_ble_tracker,
6// ln882h_ble_tracker, future chips) implements this interface; every BLE
7// consumer (sensor components, bluetooth_proxy) binds to it — in YAML via
8// `cv.use_id(BLEHub)`, which resolves whichever tracker the config declares.
9// Adding a new BLE chip therefore requires only a new tracker component that
10// implements BLEHub: no consumer, registry, or base changes.
11//
12// Chip differences are expressed as data (HubCapabilities), never as
13// platform conditionals in consumers.
14
15#pragma once
16
17#include "ble_device.h"
18
19#include <cstdint>
20#include <functional>
21
23
28 std::function<void(const uint8_t *mac, int rssi, uint8_t addr_type, const uint8_t *data, uint16_t data_len)>;
29
42
43class BLEHub {
44 public:
45 virtual ~BLEHub() = default;
46
48 virtual void register_listener(ESPBTDeviceListener *listener) = 0;
49
52
53 virtual HubCapabilities get_capabilities() const = 0;
54
56 virtual void get_adapter_mac(uint8_t out[6]) = 0;
57
58 virtual bool scan_running() = 0;
60 virtual bool scan_active() = 0;
61};
62
63} // namespace esphome::ble_device_base
virtual void set_raw_advertisement_callback(RawAdvertisementCallback cb)=0
Wire the raw-advertisement stream (bluetooth_proxy). One consumer at a time.
virtual void register_listener(ESPBTDeviceListener *listener)=0
Register a parsed-advertisement consumer (BLE sensors, automation triggers).
virtual bool scan_active()=0
True when the current/configured scan mode is active (scan requests sent).
virtual HubCapabilities get_capabilities() const =0
virtual void get_adapter_mac(uint8_t out[6])=0
Adapter MAC in printable (MSB-first) order, out[0] = MSB.
std::function< void(const uint8_t *mac, int rssi, uint8_t addr_type, const uint8_t *data, uint16_t data_len)> RawAdvertisementCallback
Callback for raw advertisements (the bluetooth_proxy path).
Definition ble_hub.h:27
What a tracker's controller/SDK can do — consumers branch on data, not #ifdefs.
Definition ble_hub.h:31
bool merges_scan_response
Controller (or tracker) delivers advertisement + scan response as one merged frame.
Definition ble_hub.h:37
bool active_scan
Controller can send scan requests (active scanning).
Definition ble_hub.h:33
bool gatt
GATT client connections are available (today: esp32 only, but a chip SDK gaining GATT support only ha...
Definition ble_hub.h:40