mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Fixed the issue start/stop BLE advertisement
PiperOrigin-RevId: 536599497
This commit is contained in:
committed by
Copybara-Service
parent
6060bc1856
commit
996f86d93f
@@ -200,7 +200,10 @@ void BleGattServer::Stop() {
|
||||
return;
|
||||
}
|
||||
|
||||
gatt_service_provider_.StopAdvertising();
|
||||
if (is_advertising_) {
|
||||
gatt_service_provider_.StopAdvertising();
|
||||
}
|
||||
|
||||
gatt_characteristic_datas_.clear();
|
||||
service_uuid_ = Uuid();
|
||||
gatt_service_provider_ = nullptr;
|
||||
@@ -413,10 +416,19 @@ bool BleGattServer::StopAdvertisement() {
|
||||
|
||||
if (gatt_service_provider_ == nullptr) {
|
||||
NEARBY_LOGS(WARNING) << __func__ << ": no GATT server is running.";
|
||||
is_advertising_ = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (gatt_service_provider_.AdvertisementStatus() ==
|
||||
GattServiceProviderAdvertisementStatus ::Stopped) {
|
||||
NEARBY_LOGS(WARNING) << __func__ << ": no GATT advertisement is running.";
|
||||
is_advertising_ = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
gatt_service_provider_.StopAdvertising();
|
||||
is_advertising_ = false;
|
||||
NEARBY_LOGS(INFO) << __func__ << ": GATT server stopped.";
|
||||
return true;
|
||||
} catch (std::exception exception) {
|
||||
|
||||
Reference in New Issue
Block a user