Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing BLE Bug #3000

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion internal/platform/implementation/apple/ble_medium.mm
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,17 @@
data.service_data[CPPUUIDFromObjC(key)] = ByteArrayFromNSData(serviceData[key]);
}

// Add the peripheral to the map if we haven't discovered it yet.
// Always add the peripheral to the map. We may have discovered it before, but it's possible that
// the MAC address has rotated, so we should always hold on to the latest peripheral object.
// See: b/375176623
auto ble_peripheral = std::make_unique<BlePeripheral>(peripheral);
auto unique_id = ble_peripheral->GetUniqueId();
auto it = peripherals_.find(unique_id);
if (it == peripherals_.end()) {

peripherals_[unique_id] = std::move(ble_peripheral);
} else {
peripherals_[unique_id]->peripheral_ = peripheral;
}
if (scanning_cb_.advertisement_found_cb) {
scanning_cb_.advertisement_found_cb(*peripherals_[unique_id], data);
Expand Down
3 changes: 2 additions & 1 deletion internal/platform/implementation/apple/ble_peripheral.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ class BlePeripheral : public api::ble_v2::BlePeripheral {
// Returns the CoreBluetooth peripheral object.
id<GNCPeripheral> GetPeripheral() const;

private:
id<GNCPeripheral> peripheral_;

private:
api::ble_v2::BlePeripheral::UniqueId unique_id_;
};

Expand Down
Loading