Skip to content

Commit

Permalink
Do not notify a discovery when the peripheral is already known
Browse files Browse the repository at this point in the history
  • Loading branch information
larsblumberg committed Feb 4, 2016
1 parent 70c9874 commit 98f907c
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions SDK/BLEDiscoveryManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,8 @@ private class BLEDiscoveryManagerPrivate: NSObject, CBCentralManagerDelegate {
}

@objc func centralManager(central: CBCentralManager, didDiscoverPeripheral peripheral: CBPeripheral, advertisementData: [String : AnyObject], RSSI: NSNumber) {
#if os(OSX)
// Work around a bug in OSX with custom USB BLE module where the same device is discovered multiple times although explicitly not wanted
guard options[CBCentralManagerScanOptionAllowDuplicatesKey] === true || !deviceForPeripheral.keys.contains(peripheral) else { return }
#endif
// Prevent devices from being discovered multiple times. iOS devices in peripheral role are also discovered multiple times.
guard options[CBCentralManagerScanOptionAllowDuplicatesKey] === true || !deviceForPeripheral.keys.contains(peripheral) else { return }
guard let device = discovery.delegate?.bleDiscoveryManager(discovery, deviceWithPeripheral: peripheral, advertisementData: advertisementData) else { return }
deviceForPeripheral[peripheral] = device
unreachableDevicesDetector.didFindDevice(device)
Expand Down

0 comments on commit 98f907c

Please sign in to comment.