| 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(); |
| 110 | 117 |
| 111 // Equivalent to [peripheral_ state]. Allows compilation on OS X 10.6. | 118 // Equivalent to [peripheral_ state]. Allows compilation on OS X 10.6. |
| 112 CBPeripheralState GetPeripheralState() const; | 119 CBPeripheralState GetPeripheralState() const; |
| 113 | 120 |
| 114 // CoreBluetooth data structure. | 121 // CoreBluetooth data structure. |
| 115 base::scoped_nsobject<CBPeripheral> peripheral_; | 122 base::scoped_nsobject<CBPeripheral> peripheral_; |
| 116 | 123 |
| 117 // RSSI value. | 124 // RSSI value. |
| 118 int rssi_; | 125 int rssi_; |
| 119 | 126 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 132 | 139 |
| 133 // The services (identified by UUIDs) that this device provides. | 140 // The services (identified by UUIDs) that this device provides. |
| 134 std::set<BluetoothUUID> advertised_uuids_; | 141 std::set<BluetoothUUID> advertised_uuids_; |
| 135 | 142 |
| 136 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyDeviceMac); | 143 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyDeviceMac); |
| 137 }; | 144 }; |
| 138 | 145 |
| 139 } // namespace device | 146 } // namespace device |
| 140 | 147 |
| 141 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_ | 148 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_ |
| OLD | NEW |