mirror of
https://github.com/esphome/esphome.git
synced 2026-08-24 15:16:20 +00:00
Fold the push-hub surface into the concept
This commit is contained in:
@@ -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<typename T>
|
||||
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<bool>;
|
||||
#ifdef USE_BLE_SCANNER_STATE_CALLBACK
|
||||
hub.set_scanner_state_callback(ScannerStateCallback{});
|
||||
{ hub.get_scanner_state() } -> std::same_as<ScannerState>;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
@@ -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_();
|
||||
|
||||
Reference in New Issue
Block a user