Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "device/bluetooth/bluetooth_low_energy_discovery_manager_mac.h" | 5 #include "device/bluetooth/bluetooth_low_energy_discovery_manager_mac.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/mac/mac_util.h" | 9 #include "base/mac/mac_util.h" |
| 10 #include "base/mac/sdk_forward_declarations.h" | 10 #include "base/mac/sdk_forward_declarations.h" |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 services = [NSMutableArray array]; | 57 services = [NSMutableArray array]; |
| 58 for (auto& service_uuid : services_uuids_) { | 58 for (auto& service_uuid : services_uuids_) { |
| 59 NSString* uuidString = | 59 NSString* uuidString = |
| 60 base::SysUTF8ToNSString(service_uuid.canonical_value().c_str()); | 60 base::SysUTF8ToNSString(service_uuid.canonical_value().c_str()); |
| 61 CBUUID* uuid = [CBUUID UUIDWithString:uuidString]; | 61 CBUUID* uuid = [CBUUID UUIDWithString:uuidString]; |
| 62 [services addObject:uuid]; | 62 [services addObject:uuid]; |
| 63 } | 63 } |
| 64 }; | 64 }; |
| 65 | 65 |
| 66 VLOG(1) << "TryStartDiscovery scanForPeripheralsWithServices"; | 66 VLOG(1) << "TryStartDiscovery scanForPeripheralsWithServices"; |
| 67 [central_manager_ scanForPeripheralsWithServices:services options:nil]; | 67 // Start a scan with the Allow Duplicates option so that we get notified |
| 68 // of each new advertisement packet. | |
|
scheib
2016/08/06 00:21:41
Good, but follow through with why we need to see e
ortuno
2016/08/08 22:56:39
Done.
| |
| 69 [central_manager_ | |
| 70 scanForPeripheralsWithServices:services | |
| 71 options:@{ | |
| 72 CBCentralManagerScanOptionAllowDuplicatesKey : | |
| 73 @YES | |
| 74 }]; | |
| 68 pending_ = false; | 75 pending_ = false; |
| 69 } | 76 } |
| 70 | 77 |
| 71 void BluetoothLowEnergyDiscoveryManagerMac::StopDiscovery() { | 78 void BluetoothLowEnergyDiscoveryManagerMac::StopDiscovery() { |
| 72 VLOG(1) << "StopDiscovery"; | 79 VLOG(1) << "StopDiscovery"; |
| 73 if (discovering_ && !pending_) { | 80 if (discovering_ && !pending_) { |
| 74 [central_manager_ stopScan]; | 81 [central_manager_ stopScan]; |
| 75 } | 82 } |
| 76 discovering_ = false; | 83 discovering_ = false; |
| 77 } | 84 } |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 95 } | 102 } |
| 96 | 103 |
| 97 BluetoothLowEnergyDiscoveryManagerMac::BluetoothLowEnergyDiscoveryManagerMac( | 104 BluetoothLowEnergyDiscoveryManagerMac::BluetoothLowEnergyDiscoveryManagerMac( |
| 98 Observer* observer) | 105 Observer* observer) |
| 99 : observer_(observer) { | 106 : observer_(observer) { |
| 100 DCHECK(BluetoothAdapterMac::IsLowEnergyAvailable()); | 107 DCHECK(BluetoothAdapterMac::IsLowEnergyAvailable()); |
| 101 discovering_ = false; | 108 discovering_ = false; |
| 102 } | 109 } |
| 103 | 110 |
| 104 } // namespace device | 111 } // namespace device |
| OLD | NEW |