From e3302b720b36e9603cdf83844b158dfb9d353be6 Mon Sep 17 00:00:00 2001 From: Francis Tsui Date: Sat, 8 Mar 2025 11:02:15 -0800 Subject: [PATCH] Improve Gatt advertising reliability. PiperOrigin-RevId: 734925395 --- internal/platform/implementation/windows/ble_gatt_server.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/internal/platform/implementation/windows/ble_gatt_server.cc b/internal/platform/implementation/windows/ble_gatt_server.cc index 117068bf..d61e1ea4 100644 --- a/internal/platform/implementation/windows/ble_gatt_server.cc +++ b/internal/platform/implementation/windows/ble_gatt_server.cc @@ -442,13 +442,15 @@ bool BleGattServer::StartAdvertisement(const ByteArray& service_data, // Wait for the advertising to start. int wait_milliseconds = 0; while (gatt_service_provider_.AdvertisementStatus() != - GattServiceProviderAdvertisementStatus::Started) { + GattServiceProviderAdvertisementStatus::Started && + gatt_service_provider_.AdvertisementStatus() != + GattServiceProviderAdvertisementStatus:: + StartedWithoutAllAdvertisementData) { absl::SleepFor(absl::Milliseconds(kGattServerCheckIntervalInMills)); wait_milliseconds += kGattServerCheckIntervalInMills; if (absl::Milliseconds(wait_milliseconds) > kGattServerTimeout) { LOG(ERROR) << __func__ << ": Failed to start GATT advertising due to timeout."; - return false; } }