From ef0d2ed139028e74fa70852ed0ae7094dd8edf78 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 8 Aug 2026 23:53:17 -0500 Subject: [PATCH] Rename the proxy-surface predicate in the proxy TUs --- .../bluetooth_proxy/bluetooth_proxy.cpp | 18 +++++++++--------- .../bluetooth_proxy/bluetooth_proxy.h | 14 +++++++------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/esphome/components/bluetooth_proxy/bluetooth_proxy.cpp b/esphome/components/bluetooth_proxy/bluetooth_proxy.cpp index 3c4e11ff26..69dea6860f 100644 --- a/esphome/components/bluetooth_proxy/bluetooth_proxy.cpp +++ b/esphome/components/bluetooth_proxy/bluetooth_proxy.cpp @@ -106,7 +106,7 @@ void BluetoothProxy::on_raw_advertisement_(const ble_device_base::RawAdvertiseme } } -#ifdef BLUETOOTH_CONNECTION_HAS_GATT +#ifdef BLUETOOTH_CONNECTION_SERVES_PROXY void BluetoothProxy::log_connection_request_ignored_(BluetoothConnection *connection, ClientState state) { ESP_LOGW(TAG, "[%d] [%s] Connection request ignored, state: %s", connection->get_connection_index(), connection->address_str(), ble_device_base::client_state_to_string(state)); @@ -115,7 +115,7 @@ void BluetoothProxy::log_connection_request_ignored_(BluetoothConnection *connec void BluetoothProxy::log_connection_info_(BluetoothConnection *connection, const char *message) { ESP_LOGI(TAG, "[%d] [%s] Connecting %s", connection->get_connection_index(), connection->address_str(), message); } -#endif // BLUETOOTH_CONNECTION_HAS_GATT +#endif // BLUETOOTH_CONNECTION_SERVES_PROXY void BluetoothProxy::log_not_connected_gatt_(const char *action, const char *type) { ESP_LOGW(TAG, "Cannot %s GATT %s, not connected", action, type); @@ -139,7 +139,7 @@ void BluetoothProxy::dump_config() { this->get_bluetooth_mac_address_pretty(mac_str); const char *mac_out = mac_str[0] != '\0' ? mac_str : "unavailable (adapter not up yet)"; const char *scan_mode = this->configured_scan_active_ ? "active" : "passive"; -#ifdef BLUETOOTH_CONNECTION_HAS_GATT +#ifdef BLUETOOTH_CONNECTION_SERVES_PROXY ESP_LOGCONFIG(TAG, "Bluetooth Proxy:\n" " Active: %s\n" @@ -157,7 +157,7 @@ void BluetoothProxy::dump_config() { #endif } -#ifdef BLUETOOTH_CONNECTION_HAS_GATT +#ifdef BLUETOOTH_CONNECTION_SERVES_PROXY // maybe_unused: in a passive proxy (active: false) MAX is 0, the body is removed, and connection is unused. void BluetoothProxy::register_connection([[maybe_unused]] BluetoothConnection *connection) { @@ -433,7 +433,7 @@ void BluetoothProxy::bluetooth_set_connection_params(const api::BluetoothSetConn this->api_connection_->send_message(resp); } -#endif // BLUETOOTH_CONNECTION_HAS_GATT +#endif // BLUETOOTH_CONNECTION_SERVES_PROXY #ifdef USE_ESP32 @@ -476,7 +476,7 @@ void BluetoothProxy::bluetooth_scanner_set_mode(bool active) { #endif // USE_ESP32 void BluetoothProxy::loop() { -#ifdef BLUETOOTH_CONNECTION_HAS_GATT +#ifdef BLUETOOTH_CONNECTION_SERVES_PROXY // Stream pending service-discovery batches every iteration; the streamer // handles a vanished API connection itself. for (uint8_t i = 0; i < this->connection_count_; i++) { @@ -491,7 +491,7 @@ void BluetoothProxy::loop() { this->last_advertisement_flush_time_ = now; if (!api::global_api_server->is_connected() || this->api_connection_ == nullptr) { -#ifdef BLUETOOTH_CONNECTION_HAS_GATT +#ifdef BLUETOOTH_CONNECTION_SERVES_PROXY // The API subscriber is gone: tear down any connections it left behind // (disconnect() on an already-disconnecting backend is a no-op). for (uint8_t i = 0; i < this->connection_count_; i++) { @@ -515,7 +515,7 @@ void BluetoothProxy::loop() { this->flush_pending_advertisements_(); } -#ifndef BLUETOOTH_CONNECTION_HAS_GATT +#ifndef BLUETOOTH_CONNECTION_SERVES_PROXY // Advertisement-only proxy. GATT client connections are excluded at compile // time (no connection backend on this platform, or active: false), so every @@ -587,7 +587,7 @@ void BluetoothProxy::bluetooth_set_connection_params(const api::BluetoothSetConn this->api_connection_->send_message(resp); } -#endif // !BLUETOOTH_CONNECTION_HAS_GATT +#endif // !BLUETOOTH_CONNECTION_SERVES_PROXY void BluetoothProxy::subscribe_api_connection(api::APIConnection *api_connection, uint32_t flags) { if (this->api_connection_ != nullptr && this->api_connection_ != api_connection) { diff --git a/esphome/components/bluetooth_proxy/bluetooth_proxy.h b/esphome/components/bluetooth_proxy/bluetooth_proxy.h index 267e29d12e..ab6687deb9 100644 --- a/esphome/components/bluetooth_proxy/bluetooth_proxy.h +++ b/esphome/components/bluetooth_proxy/bluetooth_proxy.h @@ -28,7 +28,7 @@ using bluetooth_connection::conn_err_t; using bluetooth_connection::GATT_NOT_CONNECTED; using bluetooth_connection::INIT_SENDING_SERVICES; -#ifdef BLUETOOTH_CONNECTION_HAS_GATT +#ifdef BLUETOOTH_CONNECTION_SERVES_PROXY using BluetoothConnection = bluetooth_connection::BluetoothConnection; using ClientState = ble_device_base::ClientState; #endif @@ -60,7 +60,7 @@ enum BluetoothProxySubscriptionFlag : uint32_t { }; class BluetoothProxy final : public Component { -#ifdef BLUETOOTH_CONNECTION_HAS_GATT +#ifdef BLUETOOTH_CONNECTION_SERVES_PROXY // Allow the connection to update connections_free_response_ friend bluetooth_connection::BluetoothConnection; #endif @@ -71,9 +71,9 @@ class BluetoothProxy final : public Component { void setup() override; void loop() override; -#ifdef BLUETOOTH_CONNECTION_HAS_GATT +#ifdef BLUETOOTH_CONNECTION_SERVES_PROXY void register_connection(BluetoothConnection *connection); -#endif // BLUETOOTH_CONNECTION_HAS_GATT +#endif // BLUETOOTH_CONNECTION_SERVES_PROXY #ifndef USE_ESP32 // Run after the hub's setup() (the trackers use AFTER_WIFI): setup() below // snapshots scan_active()/scan_running() and installs the raw callback, and @@ -191,7 +191,7 @@ class BluetoothProxy final : public Component { } void log_advertisement_flush_(); -#ifdef BLUETOOTH_CONNECTION_HAS_GATT +#ifdef BLUETOOTH_CONNECTION_SERVES_PROXY BluetoothConnection *get_connection_(uint64_t address, bool reserve); void log_connection_request_ignored_(BluetoothConnection *connection, ClientState state); void log_connection_info_(BluetoothConnection *connection, const char *message); @@ -199,7 +199,7 @@ class BluetoothProxy final : public Component { void log_not_connected_gatt_(const char *action, const char *type); void handle_gatt_not_connected_(uint64_t address, uint16_t handle, const char *action, const char *type); -#ifdef BLUETOOTH_CONNECTION_HAS_GATT +#ifdef BLUETOOTH_CONNECTION_SERVES_PROXY /// Keep the pre-allocated connections-free message in step when a /// connection slot changes address (0 = free). Called from the connection /// classes' set_address(). @@ -239,7 +239,7 @@ class BluetoothProxy final : public Component { // Group 1: Pointers (4 bytes each, naturally aligned) api::APIConnection *api_connection_{nullptr}; -#ifdef BLUETOOTH_CONNECTION_HAS_GATT +#ifdef BLUETOOTH_CONNECTION_SERVES_PROXY // Group 2: Fixed-size array of connection pointers std::array connections_{}; #endif