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_central_manager_delegate.h" | 5 #include "device/bluetooth/bluetooth_low_energy_central_manager_delegate.h" |
6 | 6 |
7 #include "device/bluetooth/bluetooth_adapter_mac.h" | 7 #include "device/bluetooth/bluetooth_adapter_mac.h" |
8 #include "device/bluetooth/bluetooth_low_energy_discovery_manager_mac.h" | 8 #include "device/bluetooth/bluetooth_low_energy_discovery_manager_mac.h" |
9 | 9 |
10 namespace device { | 10 namespace device { |
(...skipping 15 matching lines...) Expand all Loading... |
26 int rssi) { | 26 int rssi) { |
27 discovery_manager_->DiscoveredPeripheral(peripheral, advertisementData, | 27 discovery_manager_->DiscoveredPeripheral(peripheral, advertisementData, |
28 rssi); | 28 rssi); |
29 } | 29 } |
30 | 30 |
31 virtual void UpdatedState() { | 31 virtual void UpdatedState() { |
32 discovery_manager_->TryStartDiscovery(); | 32 discovery_manager_->TryStartDiscovery(); |
33 adapter_->LowEnergyCentralManagerUpdatedState(); | 33 adapter_->LowEnergyCentralManagerUpdatedState(); |
34 } | 34 } |
35 | 35 |
| 36 virtual void DidConnectPeripheral(CBPeripheral* peripheral) { |
| 37 adapter_->DidConnectPeripheral(peripheral); |
| 38 } |
| 39 |
| 40 virtual void DidFailToConnectPeripheral(CBPeripheral* peripheral, |
| 41 NSError* error) { |
| 42 adapter_->DidFailToConnectPeripheral(peripheral, error); |
| 43 } |
| 44 |
| 45 virtual void DidDisconnectPeripheral(CBPeripheral* peripheral, |
| 46 NSError* error) { |
| 47 adapter_->DidDisconnectPeripheral(peripheral, error); |
| 48 } |
| 49 |
36 private: | 50 private: |
37 BluetoothLowEnergyDiscoveryManagerMac* discovery_manager_; | 51 BluetoothLowEnergyDiscoveryManagerMac* discovery_manager_; |
38 BluetoothAdapterMac* adapter_; | 52 BluetoothAdapterMac* adapter_; |
39 }; | 53 }; |
40 | 54 |
41 } // namespace device | 55 } // namespace device |
42 | 56 |
43 @implementation BluetoothLowEnergyCentralManagerDelegate | 57 @implementation BluetoothLowEnergyCentralManagerDelegate |
44 | 58 |
45 - (id)initWithDiscoveryManager: | 59 - (id)initWithDiscoveryManager: |
(...skipping 12 matching lines...) Expand all Loading... |
58 RSSI:(NSNumber*)RSSI { | 72 RSSI:(NSNumber*)RSSI { |
59 // Notifies the discovery of a device. | 73 // Notifies the discovery of a device. |
60 bridge_->DiscoveredPeripheral(peripheral, advertisementData, [RSSI intValue]); | 74 bridge_->DiscoveredPeripheral(peripheral, advertisementData, [RSSI intValue]); |
61 } | 75 } |
62 | 76 |
63 - (void)centralManagerDidUpdateState:(CBCentralManager*)central { | 77 - (void)centralManagerDidUpdateState:(CBCentralManager*)central { |
64 // Notifies when the powered state of the central manager changed. | 78 // Notifies when the powered state of the central manager changed. |
65 bridge_->UpdatedState(); | 79 bridge_->UpdatedState(); |
66 } | 80 } |
67 | 81 |
| 82 - (void)centralManager:(CBCentralManager*)central |
| 83 didConnectPeripheral:(CBPeripheral*)peripheral { |
| 84 bridge_->DidConnectPeripheral(peripheral); |
| 85 } |
| 86 |
| 87 - (void)centralManager:(CBCentralManager*)central |
| 88 didFailToConnectPeripheral:(CBPeripheral*)peripheral |
| 89 error:(nullable NSError*)error { |
| 90 bridge_->DidFailToConnectPeripheral(peripheral, error); |
| 91 } |
| 92 |
| 93 - (void)centralManager:(CBCentralManager*)central |
| 94 didDisconnectPeripheral:(CBPeripheral*)peripheral |
| 95 error:(nullable NSError*)error { |
| 96 bridge_->DidDisconnectPeripheral(peripheral, error); |
| 97 } |
| 98 |
68 @end | 99 @end |
OLD | NEW |