mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Fixed a bug in GATT client
PiperOrigin-RevId: 662666561
This commit is contained in:
committed by
Copybara-Service
parent
a5efe8b924
commit
cad1ef6bf3
@@ -1216,8 +1216,12 @@ void BleV2Medium::AdvertisementFoundHandler(
|
||||
|
||||
bool BleV2Medium::GetRemotePeripheral(const std::string& mac_address,
|
||||
GetRemotePeripheralCallback callback) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
BleV2Peripheral* peripheral = GetOrCreatePeripheral(mac_address);
|
||||
BleV2Peripheral* peripheral = nullptr;
|
||||
{
|
||||
absl::MutexLock lock(&mutex_);
|
||||
BleV2Peripheral* peripheral = GetOrCreatePeripheral(mac_address);
|
||||
}
|
||||
|
||||
if (peripheral != nullptr && peripheral->Ok()) {
|
||||
callback(*peripheral);
|
||||
return true;
|
||||
@@ -1227,8 +1231,12 @@ bool BleV2Medium::GetRemotePeripheral(const std::string& mac_address,
|
||||
|
||||
bool BleV2Medium::GetRemotePeripheral(api::ble_v2::BlePeripheral::UniqueId id,
|
||||
GetRemotePeripheralCallback callback) {
|
||||
absl::MutexLock lock(&mutex_);
|
||||
BleV2Peripheral* peripheral = GetPeripheral(id);
|
||||
BleV2Peripheral* peripheral = nullptr;
|
||||
{
|
||||
absl::MutexLock lock(&mutex_);
|
||||
BleV2Peripheral* peripheral = GetPeripheral(id);
|
||||
}
|
||||
|
||||
if (peripheral == nullptr) {
|
||||
NEARBY_LOGS(WARNING) << __func__ << ": No matched peripheral device.";
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user