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 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_ |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_ |
7 | 7 |
8 #if defined(OS_IOS) | 8 #if defined(OS_IOS) |
9 #import <CoreBluetooth/CoreBluetooth.h> | 9 #import <CoreBluetooth/CoreBluetooth.h> |
10 #else // !defined(OS_IOS) | 10 #else // !defined(OS_IOS) |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
71 void Forget(const base::Closure& callback, | 71 void Forget(const base::Closure& callback, |
72 const ErrorCallback& error_callback) override; | 72 const ErrorCallback& error_callback) override; |
73 void ConnectToService( | 73 void ConnectToService( |
74 const BluetoothUUID& uuid, | 74 const BluetoothUUID& uuid, |
75 const ConnectToServiceCallback& callback, | 75 const ConnectToServiceCallback& callback, |
76 const ConnectToServiceErrorCallback& error_callback) override; | 76 const ConnectToServiceErrorCallback& error_callback) override; |
77 void ConnectToServiceInsecurely( | 77 void ConnectToServiceInsecurely( |
78 const device::BluetoothUUID& uuid, | 78 const device::BluetoothUUID& uuid, |
79 const ConnectToServiceCallback& callback, | 79 const ConnectToServiceCallback& callback, |
80 const ConnectToServiceErrorCallback& error_callback) override; | 80 const ConnectToServiceErrorCallback& error_callback) override; |
81 void CreateGattConnection( | |
82 const GattConnectionCallback& callback, | |
83 const ConnectErrorCallback& error_callback) override; | |
84 | 81 |
85 // BluetoothDeviceMac override. | 82 // BluetoothDeviceMac override. |
86 NSDate* GetLastUpdateTime() const override; | 83 NSDate* GetLastUpdateTime() const override; |
87 | 84 |
88 protected: | 85 protected: |
89 // BluetoothDevice override. | 86 // BluetoothDevice override. |
90 std::string GetDeviceName() const override; | 87 std::string GetDeviceName() const override; |
91 void CreateGattConnectionImpl() override; | 88 void CreateGattConnectionImpl() override; |
92 void DisconnectGatt() override; | 89 void DisconnectGatt() override; |
93 | 90 |
94 // Updates information about the device. | 91 // Updates information about the device. |
95 virtual void Update(CBPeripheral* peripheral, | 92 virtual void Update(CBPeripheral* peripheral, |
96 NSDictionary* advertisement_data, | 93 NSDictionary* advertisement_data, |
97 int rssi); | 94 int rssi); |
98 | 95 |
99 static std::string GetPeripheralIdentifier(CBPeripheral* peripheral); | 96 static std::string GetPeripheralIdentifier(CBPeripheral* peripheral); |
100 | 97 |
101 // Hashes and truncates the peripheral identifier to deterministically | 98 // Hashes and truncates the peripheral identifier to deterministically |
102 // construct an address. The use of fake addresses is a temporary fix before | 99 // construct an address. The use of fake addresses is a temporary fix before |
103 // we switch to using bluetooth identifiers throughout Chrome. | 100 // we switch to using bluetooth identifiers throughout Chrome. |
104 // http://crbug.com/507824 | 101 // http://crbug.com/507824 |
105 static std::string GetPeripheralHashAddress(CBPeripheral* peripheral); | 102 static std::string GetPeripheralHashAddress(CBPeripheral* peripheral); |
106 | 103 |
107 private: | 104 private: |
108 friend class BluetoothAdapterMac; | 105 friend class BluetoothAdapterMac; |
109 friend class BluetoothAdapterMacTest; | 106 friend class BluetoothAdapterMacTest; |
107 friend class BluetoothTestMac; | |
108 | |
109 // Returns the Bluetooth adapter. | |
110 BluetoothAdapterMac* GetMacAdapter(); | |
111 | |
112 // Returns the CoreBluetooth Peripheral. | |
113 CBPeripheral* GetPeripheral(); | |
114 | |
115 // Callback used when the CoreBluetooth Peripheral is disconnected. | |
116 void DidDisconnectPeripheral(); | |
117 | |
118 // Called by the adapter when CoreBluetooth calls CBCentralManager's delegate. | |
msarda
2016/02/11 10:55:38
I think this comment is too vague. What do you mea
jlebel
2016/02/19 11:02:35
Done.
| |
119 void GattConnected(); | |
msarda
2016/02/11 10:55:39
I think the tendency in Chrome is to use function
jlebel
2016/02/19 11:02:35
Done.
| |
110 | 120 |
111 // Equivalent to [peripheral_ state]. Allows compilation on OS X 10.6. | 121 // Equivalent to [peripheral_ state]. Allows compilation on OS X 10.6. |
112 CBPeripheralState GetPeripheralState() const; | 122 CBPeripheralState GetPeripheralState() const; |
113 | 123 |
114 // CoreBluetooth data structure. | 124 // CoreBluetooth data structure. |
115 base::scoped_nsobject<CBPeripheral> peripheral_; | 125 base::scoped_nsobject<CBPeripheral> peripheral_; |
116 | 126 |
117 // RSSI value. | 127 // RSSI value. |
118 int rssi_; | 128 int rssi_; |
119 | 129 |
(...skipping 12 matching lines...) Expand all Loading... | |
132 | 142 |
133 // The services (identified by UUIDs) that this device provides. | 143 // The services (identified by UUIDs) that this device provides. |
134 std::set<BluetoothUUID> advertised_uuids_; | 144 std::set<BluetoothUUID> advertised_uuids_; |
135 | 145 |
136 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyDeviceMac); | 146 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyDeviceMac); |
137 }; | 147 }; |
138 | 148 |
139 } // namespace device | 149 } // namespace device |
140 | 150 |
141 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_ | 151 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_ |
OLD | NEW |