mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Improve Gatt advertising reliability.
PiperOrigin-RevId: 734925395
This commit is contained in:
committed by
Copybara-Service
parent
ff64bb5314
commit
e3302b720b
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user