| 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 10 matching lines...) Expand all Loading... |
| 21 #include "build/build_config.h" | 21 #include "build/build_config.h" |
| 22 #include "crypto/sha2.h" | 22 #include "crypto/sha2.h" |
| 23 #include "device/bluetooth/bluetooth_device_mac.h" | 23 #include "device/bluetooth/bluetooth_device_mac.h" |
| 24 | 24 |
| 25 @class BluetoothLowEnergyPeripheralDelegate; | 25 @class BluetoothLowEnergyPeripheralDelegate; |
| 26 | 26 |
| 27 namespace device { | 27 namespace device { |
| 28 | 28 |
| 29 class BluetoothAdapterMac; | 29 class BluetoothAdapterMac; |
| 30 class BluetoothRemoteGattServiceMac; | 30 class BluetoothRemoteGattServiceMac; |
| 31 class BluetoothRemoteGattDescriptorMac; |
| 31 | 32 |
| 32 class DEVICE_BLUETOOTH_EXPORT BluetoothLowEnergyDeviceMac | 33 class DEVICE_BLUETOOTH_EXPORT BluetoothLowEnergyDeviceMac |
| 33 : public BluetoothDeviceMac { | 34 : public BluetoothDeviceMac { |
| 34 public: | 35 public: |
| 35 BluetoothLowEnergyDeviceMac(BluetoothAdapterMac* adapter, | 36 BluetoothLowEnergyDeviceMac(BluetoothAdapterMac* adapter, |
| 36 CBPeripheral* peripheral); | 37 CBPeripheral* peripheral); |
| 37 ~BluetoothLowEnergyDeviceMac() override; | 38 ~BluetoothLowEnergyDeviceMac() override; |
| 38 | 39 |
| 39 // BluetoothDevice overrides. | 40 // BluetoothDevice overrides. |
| 40 std::string GetIdentifier() const override; | 41 std::string GetIdentifier() const override; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 84 |
| 84 // Methods used by BluetoothLowEnergyPeripheralBridge. | 85 // Methods used by BluetoothLowEnergyPeripheralBridge. |
| 85 void DidDiscoverPrimaryServices(NSError* error); | 86 void DidDiscoverPrimaryServices(NSError* error); |
| 86 void DidModifyServices(NSArray* invalidatedServices); | 87 void DidModifyServices(NSArray* invalidatedServices); |
| 87 void DidDiscoverCharacteristics(CBService* cb_service, NSError* error); | 88 void DidDiscoverCharacteristics(CBService* cb_service, NSError* error); |
| 88 void DidUpdateValue(CBCharacteristic* characteristic, NSError* error); | 89 void DidUpdateValue(CBCharacteristic* characteristic, NSError* error); |
| 89 void DidWriteValue(CBCharacteristic* characteristic, NSError* error); | 90 void DidWriteValue(CBCharacteristic* characteristic, NSError* error); |
| 90 void DidUpdateNotificationState(CBCharacteristic* characteristic, | 91 void DidUpdateNotificationState(CBCharacteristic* characteristic, |
| 91 NSError* error); | 92 NSError* error); |
| 92 void DidDiscoverDescriptors(CBCharacteristic* characteristic, NSError* error); | 93 void DidDiscoverDescriptors(CBCharacteristic* characteristic, NSError* error); |
| 94 void DidUpdateValueForDescriptor(CBDescriptor* cb_descriptor, NSError* error); |
| 95 void DidWriteValueForDescriptor(CBDescriptor* descriptor, NSError* error); |
| 93 | 96 |
| 94 static std::string GetPeripheralIdentifier(CBPeripheral* peripheral); | 97 static std::string GetPeripheralIdentifier(CBPeripheral* peripheral); |
| 95 | 98 |
| 96 // Hashes and truncates the peripheral identifier to deterministically | 99 // Hashes and truncates the peripheral identifier to deterministically |
| 97 // construct an address. The use of fake addresses is a temporary fix before | 100 // construct an address. The use of fake addresses is a temporary fix before |
| 98 // we switch to using bluetooth identifiers throughout Chrome. | 101 // we switch to using bluetooth identifiers throughout Chrome. |
| 99 // http://crbug.com/507824 | 102 // http://crbug.com/507824 |
| 100 static std::string GetPeripheralHashAddress(CBPeripheral* peripheral); | 103 static std::string GetPeripheralHashAddress(CBPeripheral* peripheral); |
| 101 | 104 |
| 102 private: | 105 private: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 116 // Returns the Bluetooth adapter. | 119 // Returns the Bluetooth adapter. |
| 117 BluetoothAdapterMac* GetMacAdapter(); | 120 BluetoothAdapterMac* GetMacAdapter(); |
| 118 | 121 |
| 119 // Returns the CoreBluetooth Peripheral. | 122 // Returns the CoreBluetooth Peripheral. |
| 120 CBPeripheral* GetPeripheral(); | 123 CBPeripheral* GetPeripheral(); |
| 121 | 124 |
| 122 // Returns BluetoothRemoteGattServiceMac based on the CBService. | 125 // Returns BluetoothRemoteGattServiceMac based on the CBService. |
| 123 BluetoothRemoteGattServiceMac* GetBluetoothRemoteGattService( | 126 BluetoothRemoteGattServiceMac* GetBluetoothRemoteGattService( |
| 124 CBService* service) const; | 127 CBService* service) const; |
| 125 | 128 |
| 129 // Returns BluetoothRemoteGattDescriptorMac based on the CBDescriptor. |
| 130 BluetoothRemoteGattDescriptorMac* GetBluetoothRemoteGattDescriptor( |
| 131 CBDescriptor* cb_descriptor) const; |
| 132 |
| 126 // Callback used when the CoreBluetooth Peripheral is disconnected. | 133 // Callback used when the CoreBluetooth Peripheral is disconnected. |
| 127 void DidDisconnectPeripheral(NSError* error); | 134 void DidDisconnectPeripheral(NSError* error); |
| 128 | 135 |
| 129 // CoreBluetooth data structure. | 136 // CoreBluetooth data structure. |
| 130 base::scoped_nsobject<CBPeripheral> peripheral_; | 137 base::scoped_nsobject<CBPeripheral> peripheral_; |
| 131 | 138 |
| 132 // Objective-C delegate for the CBPeripheral. | 139 // Objective-C delegate for the CBPeripheral. |
| 133 base::scoped_nsobject<BluetoothLowEnergyPeripheralDelegate> | 140 base::scoped_nsobject<BluetoothLowEnergyPeripheralDelegate> |
| 134 peripheral_delegate_; | 141 peripheral_delegate_; |
| 135 | 142 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 152 }; | 159 }; |
| 153 | 160 |
| 154 // Stream operator for logging. | 161 // Stream operator for logging. |
| 155 DEVICE_BLUETOOTH_EXPORT std::ostream& operator<<( | 162 DEVICE_BLUETOOTH_EXPORT std::ostream& operator<<( |
| 156 std::ostream& out, | 163 std::ostream& out, |
| 157 const BluetoothLowEnergyDeviceMac& device); | 164 const BluetoothLowEnergyDeviceMac& device); |
| 158 | 165 |
| 159 } // namespace device | 166 } // namespace device |
| 160 | 167 |
| 161 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_ | 168 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_ |
| OLD | NEW |