From b9afa119a030ab935d2a460d6ebf5e76932c4b90 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 18 Jul 2025 14:22:29 -1000 Subject: [PATCH] preen --- .../bluetooth_proxy/bluetooth_connection.cpp | 1 - .../bluetooth_proxy/bluetooth_connection.h | 12 +++++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/esphome/components/bluetooth_proxy/bluetooth_connection.cpp b/esphome/components/bluetooth_proxy/bluetooth_connection.cpp index 3bf8711714..d88eb5d632 100644 --- a/esphome/components/bluetooth_proxy/bluetooth_connection.cpp +++ b/esphome/components/bluetooth_proxy/bluetooth_connection.cpp @@ -13,7 +13,6 @@ namespace bluetooth_proxy { static const char *const TAG = "bluetooth_proxy.connection"; -// Helper function from bluetooth_proxy.cpp static std::vector get_128bit_uuid_vec(esp_bt_uuid_t uuid_source) { esp_bt_uuid_t uuid = espbt::ESPBTUUID::from_uuid(uuid_source).as_128bit().get_uuid(); return std::vector{((uint64_t) uuid.uuid.uuid128[15] << 56) | ((uint64_t) uuid.uuid.uuid128[14] << 48) | diff --git a/esphome/components/bluetooth_proxy/bluetooth_connection.h b/esphome/components/bluetooth_proxy/bluetooth_connection.h index 4c4eff0919..18e32f4402 100644 --- a/esphome/components/bluetooth_proxy/bluetooth_connection.h +++ b/esphome/components/bluetooth_proxy/bluetooth_connection.h @@ -29,7 +29,17 @@ class BluetoothConnection : public esp32_ble_client::BLEClientBase { friend class BluetoothProxy; void send_service_for_discovery_(); - void reset_connection_(); + void reset_connection_() { + // Important: If we were in the middle of sending services, we do NOT send + // send_gatt_services_done() here. This ensures the client knows that + // the service discovery was interrupted and can retry. The client + // (aioesphomeapi) implements a 30-second timeout (DEFAULT_BLE_TIMEOUT) + // to detect incomplete service discovery rather than relying on us to + // tell them about a partial list. + this->set_address(0); + this->send_service_ = DONE_SENDING_SERVICES; + this->proxy_->send_connections_free(); + } // Memory optimized layout for 32-bit systems // Group 1: Pointers (4 bytes each, naturally aligned)