From baf57195e2a12f6872b9560fd0f3fbe47841a1e0 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 19 Aug 2026 09:15:17 -0500 Subject: [PATCH] Name the materializer define for what it gates USE_BLUEDROID_GATT_SERVICE_TABLE compiles the Bluedroid materializer and nothing else; the old name read like a cross-backend consumer capability (rp2 always materializes and ignores it). --- esphome/components/ble_client/__init__.py | 2 +- esphome/components/bluetooth_connection/__init__.py | 2 +- .../bluetooth_connection_bluedroid.cpp | 8 ++++---- .../bluetooth_connection/bluetooth_connection_bluedroid.h | 6 +++--- .../bluetooth_connection/gatt_service_table_bluedroid.cpp | 4 ++-- .../bluetooth_connection/gatt_service_table_bluedroid.h | 4 ++-- esphome/core/defines.h | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/esphome/components/ble_client/__init__.py b/esphome/components/ble_client/__init__.py index 06434a4384..cd33f211f0 100644 --- a/esphome/components/ble_client/__init__.py +++ b/esphome/components/ble_client/__init__.py @@ -354,7 +354,7 @@ def _request_gatt_node_build() -> None: # claim a phantom backend slot on combined proxy builds. cg.add_define("USE_BLE_GATT_CLIENT") cg.add_define("USE_BLE_GATT_BACKEND_BLUEDROID") - cg.add_define("USE_BLE_GATT_SERVICE_TABLE") + cg.add_define("USE_BLUEDROID_GATT_SERVICE_TABLE") async def register_gatt_node(var, config): diff --git a/esphome/components/bluetooth_connection/__init__.py b/esphome/components/bluetooth_connection/__init__.py index a525906889..69a250f809 100644 --- a/esphome/components/bluetooth_connection/__init__.py +++ b/esphome/components/bluetooth_connection/__init__.py @@ -255,7 +255,7 @@ async def new_gatt_backend( ble_device_base.request_gatt_client() cg.add_define(entry.define) if service_table: - cg.add_define("USE_BLE_GATT_SERVICE_TABLE") + cg.add_define("USE_BLUEDROID_GATT_SERVICE_TABLE") backend = cg.new_Pvariable(config[CONF_BACKEND_ID]) # The backend is the slot's real Component: component keys from the # connection entry (setup_priority, ...) apply to it. Consumers whose own diff --git a/esphome/components/bluetooth_connection/bluetooth_connection_bluedroid.cpp b/esphome/components/bluetooth_connection/bluetooth_connection_bluedroid.cpp index c7ff99b242..7cbc02e456 100644 --- a/esphome/components/bluetooth_connection/bluetooth_connection_bluedroid.cpp +++ b/esphome/components/bluetooth_connection/bluetooth_connection_bluedroid.cpp @@ -301,7 +301,7 @@ int BluedroidGattClient::update_connection_params(uint16_t min_interval, uint16_ void BluedroidGattClient::release_services() { this->service_total_ = 0; -#ifdef USE_BLE_GATT_SERVICE_TABLE +#ifdef USE_BLUEDROID_GATT_SERVICE_TABLE this->table_.free(); #endif // Always set: terminates any in-flight stream on every cache config. @@ -316,7 +316,7 @@ void BluedroidGattClient::release_services() { #endif } -#ifdef USE_BLE_GATT_SERVICE_TABLE +#ifdef USE_BLUEDROID_GATT_SERVICE_TABLE ble_device_base::GattServiceTable BluedroidGattClient::get_service_table() { // Lifetime: every teardown path (CLOSE_EVT, the safety timeout, stack-down, // passive DISCONNECT) routes through release_services(), so a materialized @@ -332,7 +332,7 @@ ble_device_base::GattServiceTable BluedroidGattClient::get_service_table() { } return this->table_.view(); } -#endif // USE_BLE_GATT_SERVICE_TABLE +#endif // USE_BLUEDROID_GATT_SERVICE_TABLE // ---- internals ---- @@ -380,7 +380,7 @@ void BluedroidGattClient::log_gattc_warning_(const char *operation, int code) { // ---- service streaming ---- int BluedroidGattClient::handle_search_cmpl_(esp_gatt_status_t status) { -#ifdef USE_BLE_GATT_SERVICE_TABLE +#ifdef USE_BLUEDROID_GATT_SERVICE_TABLE // Re-discovery moves the counts the table view derives offsets from; free // the stale table. this->table_.free(); diff --git a/esphome/components/bluetooth_connection/bluetooth_connection_bluedroid.h b/esphome/components/bluetooth_connection/bluetooth_connection_bluedroid.h index 5503b6026c..122ae8059b 100644 --- a/esphome/components/bluetooth_connection/bluetooth_connection_bluedroid.h +++ b/esphome/components/bluetooth_connection/bluetooth_connection_bluedroid.h @@ -76,9 +76,9 @@ class BluedroidGattClient final : public esp32_ble_tracker::ESPBTClient, public int pair(); int update_connection_params(uint16_t min_interval, uint16_t max_interval, uint16_t latency, uint16_t timeout); // On-demand table for direct consumers; the proxy streams instead, so the - // materializer compiles only under USE_BLE_GATT_SERVICE_TABLE (emitted by + // materializer compiles only under USE_BLUEDROID_GATT_SERVICE_TABLE (emitted by // direct-consumer codegen, never by the proxy). -#ifdef USE_BLE_GATT_SERVICE_TABLE +#ifdef USE_BLUEDROID_GATT_SERVICE_TABLE ble_device_base::GattServiceTable get_service_table(); #else // A direct consumer reaching this stub misconfigured its codegen @@ -113,7 +113,7 @@ class BluedroidGattClient final : public esp32_ble_tracker::ESPBTClient, public // Group 1: pointers / composed objects ble_device_base::GattClientListener *listener_{nullptr}; -#ifdef USE_BLE_GATT_SERVICE_TABLE +#ifdef USE_BLUEDROID_GATT_SERVICE_TABLE BluedroidServiceTable table_; #endif // Group 2: 4-byte types diff --git a/esphome/components/bluetooth_connection/gatt_service_table_bluedroid.cpp b/esphome/components/bluetooth_connection/gatt_service_table_bluedroid.cpp index 6bbb5cb2d7..71a487c590 100644 --- a/esphome/components/bluetooth_connection/gatt_service_table_bluedroid.cpp +++ b/esphome/components/bluetooth_connection/gatt_service_table_bluedroid.cpp @@ -1,6 +1,6 @@ #include "gatt_service_table_bluedroid.h" -#if defined(USE_ESP32_BLE) && defined(USE_BLE_GATT_CLIENT) && defined(USE_BLE_GATT_SERVICE_TABLE) +#if defined(USE_ESP32_BLE) && defined(USE_BLE_GATT_CLIENT) && defined(USE_BLUEDROID_GATT_SERVICE_TABLE) #include "esphome/core/log.h" @@ -195,4 +195,4 @@ void BluedroidServiceTable::log_walk_warning_(const char *operation, int code) { } // namespace esphome::bluetooth_connection -#endif // USE_ESP32_BLE && USE_BLE_GATT_CLIENT && USE_BLE_GATT_SERVICE_TABLE +#endif // USE_ESP32_BLE && USE_BLE_GATT_CLIENT && USE_BLUEDROID_GATT_SERVICE_TABLE diff --git a/esphome/components/bluetooth_connection/gatt_service_table_bluedroid.h b/esphome/components/bluetooth_connection/gatt_service_table_bluedroid.h index 96f4fb3815..a125c010ff 100644 --- a/esphome/components/bluetooth_connection/gatt_service_table_bluedroid.h +++ b/esphome/components/bluetooth_connection/gatt_service_table_bluedroid.h @@ -6,7 +6,7 @@ #include "esphome/core/defines.h" -#if defined(USE_ESP32_BLE) && defined(USE_BLE_GATT_CLIENT) && defined(USE_BLE_GATT_SERVICE_TABLE) +#if defined(USE_ESP32_BLE) && defined(USE_BLE_GATT_CLIENT) && defined(USE_BLUEDROID_GATT_SERVICE_TABLE) #include "esphome/components/ble_device_base/ble_gatt_client.h" #include "esphome/core/helpers.h" @@ -73,4 +73,4 @@ class BluedroidServiceTable { } // namespace esphome::bluetooth_connection -#endif // USE_ESP32_BLE && USE_BLE_GATT_CLIENT && USE_BLE_GATT_SERVICE_TABLE +#endif // USE_ESP32_BLE && USE_BLE_GATT_CLIENT && USE_BLUEDROID_GATT_SERVICE_TABLE diff --git a/esphome/core/defines.h b/esphome/core/defines.h index 8272a9e06e..096b052681 100644 --- a/esphome/core/defines.h +++ b/esphome/core/defines.h @@ -319,7 +319,7 @@ #define USE_ESP32_BLE_TRACKER #define USE_BLE_GATT_CLIENT #define USE_BLE_GATT_BACKEND_BLUEDROID -#define USE_BLE_GATT_SERVICE_TABLE +#define USE_BLUEDROID_GATT_SERVICE_TABLE #define USE_BLE_CLIENT_GATT_NODES #define USE_BLE_CLIENT_LEGACY_ENGINE #define ESPHOME_BLE_CLIENT_MAX_NODES 1