1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-14 17:22:20 +01:00

[bluetooth_proxy] Batch BLE service discovery messages for 67% reduction in API traffic

This commit is contained in:
J. Nick Koston
2025-07-30 14:46:13 -10:00
parent a4ebcc691a
commit 12cd1ec525

View File

@@ -78,8 +78,9 @@ void BluetoothConnection::send_service_for_discovery_() {
resp.address = this->address_; resp.address = this->address_;
// Process up to 3 services in this iteration // Process up to 3 services in this iteration
static constexpr int MAX_SERVICES_PER_BATCH = 3; uint8_t services_to_process =
int services_to_process = std::min(MAX_SERVICES_PER_BATCH, this->service_count_ - this->send_service_); std::min(MAX_SERVICES_PER_BATCH, static_cast<uint8_t>(this->service_count_ - this->send_service_));
uint8_t services_processed = 0;
resp.services.reserve(services_to_process); resp.services.reserve(services_to_process);
for (int service_idx = 0; service_idx < services_to_process; service_idx++) { for (int service_idx = 0; service_idx < services_to_process; service_idx++) {