Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: device/bluetooth/bluetooth_low_energy_discovery_manager_mac.mm

Issue 2339253002: bluetooth: mac: add connected LE devices to chooser (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 VLOG(1) << "TryStartDiscovery scanForPeripheralsWithServices"; 66 VLOG(1) << "TryStartDiscovery scanForPeripheralsWithServices";
67 // Start a scan with the Allow Duplicates option so that we get notified 67 // Start a scan with the Allow Duplicates option so that we get notified
68 // of each new Advertisement Packet. This allows us to provide up to date 68 // of each new Advertisement Packet. This allows us to provide up to date
69 // values for RSSI, Advertised Services, Advertised Data, etc. 69 // values for RSSI, Advertised Services, Advertised Data, etc.
70 [central_manager_ 70 [central_manager_
71 scanForPeripheralsWithServices:services 71 scanForPeripheralsWithServices:services
72 options:@{ 72 options:@{
73 CBCentralManagerScanOptionAllowDuplicatesKey : 73 CBCentralManagerScanOptionAllowDuplicatesKey :
74 @YES 74 @YES
75 }]; 75 }];
76 NSArray* connectedServices;
77 if (services) {
78 connectedServices = services;
79 } else {
80 CBUUID* defaultService = [CBUUID UUIDWithString:@"1800"];
François Beaufort 2016/09/15 07:38:16 You may want to add a comment there to explain why
jlebel 2016/09/21 13:49:28 Done.
81 connectedServices = @[ defaultService ];
82 }
83 #pragma clang diagnostic push
84 #pragma clang diagnostic ignored "-Wpartial-availability"
François Beaufort 2016/09/15 07:38:16 According to https://developer.apple.com/reference
jlebel 2016/09/21 13:49:28 I think it is a terrible idea to create a fake dec
85 NSArray* peripherals = [central_manager_
86 retrieveConnectedPeripheralsWithServices:connectedServices];
87 #pragma clang diagnostic pop
88 for (CBPeripheral* peripheral in peripherals) {
89 observer_->LowEnergyDeviceUpdated(peripheral, nil, 0);
François Beaufort 2016/09/15 07:38:16 Nit: observer_->LowEnergyDeviceUpdated(peripheral
jlebel 2016/09/21 13:49:28 Done.
90 }
76 pending_ = false; 91 pending_ = false;
77 } 92 }
78 93
79 void BluetoothLowEnergyDiscoveryManagerMac::StopDiscovery() { 94 void BluetoothLowEnergyDiscoveryManagerMac::StopDiscovery() {
80 VLOG(1) << "StopDiscovery"; 95 VLOG(1) << "StopDiscovery";
81 if (discovering_ && !pending_) { 96 if (discovering_ && !pending_) {
82 [central_manager_ stopScan]; 97 [central_manager_ stopScan];
83 } 98 }
84 discovering_ = false; 99 discovering_ = false;
85 } 100 }
(...skipping 17 matching lines...) Expand all
103 } 118 }
104 119
105 BluetoothLowEnergyDiscoveryManagerMac::BluetoothLowEnergyDiscoveryManagerMac( 120 BluetoothLowEnergyDiscoveryManagerMac::BluetoothLowEnergyDiscoveryManagerMac(
106 Observer* observer) 121 Observer* observer)
107 : observer_(observer) { 122 : observer_(observer) {
108 DCHECK(BluetoothAdapterMac::IsLowEnergyAvailable()); 123 DCHECK(BluetoothAdapterMac::IsLowEnergyAvailable());
109 discovering_ = false; 124 discovering_ = false;
110 } 125 }
111 126
112 } // namespace device 127 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_low_energy_discovery_manager_mac.h ('k') | device/bluetooth/test/bluetooth_test_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698