From 2d50e07e9080268bf34f2007ea328ab7666f5035 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 8 Aug 2026 21:41:23 -0500 Subject: [PATCH] Fold the push-hub surface into the concept --- esphome/components/ble_device_base/ble_hub.h | 7 +++++-- esphome/components/bluetooth_proxy/bluetooth_proxy.cpp | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/esphome/components/ble_device_base/ble_hub.h b/esphome/components/ble_device_base/ble_hub.h index d40682b506..8e4c710bb1 100644 --- a/esphome/components/ble_device_base/ble_hub.h +++ b/esphome/components/ble_device_base/ble_hub.h @@ -99,8 +99,10 @@ struct HubCapabilities { // reports the real state back); true = applied immediately, restarting a // running scan. Honoring is advertised by HubCapabilities::scan_mode_switch. // Push hubs additionally provide set_scanner_state_callback(ScannerStateCallback) -// under USE_BLE_SCANNER_STATE_CALLBACK; the concept requires it exactly when -// that define is set. +// and get_scanner_state() under USE_BLE_SCANNER_STATE_CALLBACK; the concept +// requires both exactly when that define is set. A push hub must emit a +// transition for every accepted or refused mode request - consumers skip +// their own mode report on push builds. template concept BLEHubContract = requires(T hub, ESPBTDeviceListener *listener, RawAdvertisementCallback raw_callback, uint8_t *mac) { @@ -113,6 +115,7 @@ concept BLEHubContract = requires(T hub, ESPBTDeviceListener *listener, RawAdver { hub.request_scan_mode(true) } -> std::same_as; #ifdef USE_BLE_SCANNER_STATE_CALLBACK hub.set_scanner_state_callback(ScannerStateCallback{}); + { hub.get_scanner_state() } -> std::same_as; #endif }; diff --git a/esphome/components/bluetooth_proxy/bluetooth_proxy.cpp b/esphome/components/bluetooth_proxy/bluetooth_proxy.cpp index cb9e25762f..88d8cc1885 100644 --- a/esphome/components/bluetooth_proxy/bluetooth_proxy.cpp +++ b/esphome/components/bluetooth_proxy/bluetooth_proxy.cpp @@ -633,8 +633,7 @@ void BluetoothProxy::subscribe_api_connection(api::APIConnection *api_connection } this->api_connection_ = api_connection; #ifdef USE_BLE_SCANNER_STATE_CALLBACK - // esp32 only: get_scanner_state() is tracker-native, beyond the neutral - // contract; the push define implies the concrete tracker alias. + // get_scanner_state() is part of the push-hub surface (see BLEHubContract). this->send_bluetooth_scanner_state_(this->hub_->get_scanner_state()); #else this->send_polled_scanner_state_();