mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-16 15:36:12 -04:00
Fix retroactive pairing test
PiperOrigin-RevId: 532853830
This commit is contained in:
committed by
Copybara-Service
parent
60ba057230
commit
1c9dd093f1
@@ -565,6 +565,11 @@ bool BleV2Medium::GattServer::RemoveCharacteristicSubscription(
|
||||
return false;
|
||||
}
|
||||
|
||||
bool BleV2Medium::GattServer::HasCharacteristic(
|
||||
const api::ble_v2::GattCharacteristic& characteristic) {
|
||||
return characteristics_.find(characteristic) != characteristics_.end();
|
||||
}
|
||||
|
||||
void BleV2Medium::GattServer::Stop() {
|
||||
NEARBY_LOGS(INFO) << "G3 Ble GattServer Stop";
|
||||
characteristics_.clear();
|
||||
@@ -611,13 +616,12 @@ BleV2Medium::GattClient::GetCharacteristic(const Uuid& service_uuid,
|
||||
}
|
||||
BleV2Medium::GattServer* gatt_server =
|
||||
static_cast<BleV2Medium::GattServer*>(*borrowed);
|
||||
absl::StatusOr<ByteArray> value = gatt_server->ReadCharacteristic(
|
||||
peripheral_, characteristic, /*offset=*/0);
|
||||
if (!value.ok()) {
|
||||
if (!gatt_server->HasCharacteristic(characteristic)) {
|
||||
NEARBY_LOGS(WARNING)
|
||||
<< "G3 Ble GattClient GetCharacteristic, can't read characteristic=("
|
||||
<< "G3 Ble GattClient GetCharacteristic, characteristic=("
|
||||
<< characteristic.service_uuid.Get16BitAsString() << ","
|
||||
<< std::string(characteristic.uuid) << ")" << value.status();
|
||||
<< std::string(characteristic.uuid)
|
||||
<< ") not registered on GATT server";
|
||||
return std::nullopt;
|
||||
}
|
||||
NEARBY_LOGS(INFO)
|
||||
|
||||
@@ -274,6 +274,9 @@ class BleV2Medium : public api::ble_v2::BleMedium {
|
||||
const BleV2Peripheral& remote_device,
|
||||
const api::ble_v2::GattCharacteristic& characteristic);
|
||||
|
||||
bool HasCharacteristic(
|
||||
const api::ble_v2::GattCharacteristic& characteristic);
|
||||
|
||||
private:
|
||||
using SubscriberKey =
|
||||
std::pair<const BleV2Peripheral*, api::ble_v2::GattCharacteristic>;
|
||||
|
||||
Reference in New Issue
Block a user