From 12cd1ec52590ae19c613dc9578f6c25ef245cda3 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Wed, 30 Jul 2025 14:46:13 -1000 Subject: [PATCH] [bluetooth_proxy] Batch BLE service discovery messages for 67% reduction in API traffic --- esphome/components/bluetooth_proxy/bluetooth_connection.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/esphome/components/bluetooth_proxy/bluetooth_connection.cpp b/esphome/components/bluetooth_proxy/bluetooth_connection.cpp index e761fd3496..3c1b198ee4 100644 --- a/esphome/components/bluetooth_proxy/bluetooth_connection.cpp +++ b/esphome/components/bluetooth_proxy/bluetooth_connection.cpp @@ -78,8 +78,9 @@ void BluetoothConnection::send_service_for_discovery_() { resp.address = this->address_; // Process up to 3 services in this iteration - static constexpr int MAX_SERVICES_PER_BATCH = 3; - int services_to_process = std::min(MAX_SERVICES_PER_BATCH, this->service_count_ - this->send_service_); + uint8_t services_to_process = + std::min(MAX_SERVICES_PER_BATCH, static_cast(this->service_count_ - this->send_service_)); + uint8_t services_processed = 0; resp.services.reserve(services_to_process); for (int service_idx = 0; service_idx < services_to_process; service_idx++) {