| 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 16 matching lines...) Expand all Loading... |
| 27 namespace device { | 27 namespace device { |
| 28 | 28 |
| 29 class BluetoothAdapterMac; | 29 class BluetoothAdapterMac; |
| 30 class BluetoothLowEnergyDiscoverManagerMac; | 30 class BluetoothLowEnergyDiscoverManagerMac; |
| 31 class BluetoothRemoteGattServiceMac; | 31 class BluetoothRemoteGattServiceMac; |
| 32 | 32 |
| 33 class DEVICE_BLUETOOTH_EXPORT BluetoothLowEnergyDeviceMac | 33 class DEVICE_BLUETOOTH_EXPORT BluetoothLowEnergyDeviceMac |
| 34 : public BluetoothDeviceMac { | 34 : public BluetoothDeviceMac { |
| 35 public: | 35 public: |
| 36 BluetoothLowEnergyDeviceMac(BluetoothAdapterMac* adapter, | 36 BluetoothLowEnergyDeviceMac(BluetoothAdapterMac* adapter, |
| 37 CBPeripheral* peripheral, | 37 CBPeripheral* peripheral); |
| 38 NSDictionary* advertisement_data, | |
| 39 int rssi); | |
| 40 ~BluetoothLowEnergyDeviceMac() override; | 38 ~BluetoothLowEnergyDeviceMac() override; |
| 41 | 39 |
| 42 int GetRSSI() const; | |
| 43 | |
| 44 // BluetoothDevice overrides. | 40 // BluetoothDevice overrides. |
| 45 std::string GetIdentifier() const override; | 41 std::string GetIdentifier() const override; |
| 46 uint32_t GetBluetoothClass() const override; | 42 uint32_t GetBluetoothClass() const override; |
| 47 std::string GetAddress() const override; | 43 std::string GetAddress() const override; |
| 48 BluetoothDevice::VendorIDSource GetVendorIDSource() const override; | 44 BluetoothDevice::VendorIDSource GetVendorIDSource() const override; |
| 49 uint16_t GetVendorID() const override; | 45 uint16_t GetVendorID() const override; |
| 50 uint16_t GetProductID() const override; | 46 uint16_t GetProductID() const override; |
| 51 uint16_t GetDeviceID() const override; | 47 uint16_t GetDeviceID() const override; |
| 52 uint16_t GetAppearance() const override; | 48 uint16_t GetAppearance() const override; |
| 53 base::Optional<std::string> GetName() const override; | 49 base::Optional<std::string> GetName() const override; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 86 |
| 91 // Methods used by BluetoothLowEnergyPeripheralBridge. | 87 // Methods used by BluetoothLowEnergyPeripheralBridge. |
| 92 void DidDiscoverPrimaryServices(NSError* error); | 88 void DidDiscoverPrimaryServices(NSError* error); |
| 93 void DidModifyServices(NSArray* invalidatedServices); | 89 void DidModifyServices(NSArray* invalidatedServices); |
| 94 void DidDiscoverCharacteristics(CBService* cb_service, NSError* error); | 90 void DidDiscoverCharacteristics(CBService* cb_service, NSError* error); |
| 95 void DidUpdateValue(CBCharacteristic* characteristic, NSError* error); | 91 void DidUpdateValue(CBCharacteristic* characteristic, NSError* error); |
| 96 void DidWriteValue(CBCharacteristic* characteristic, NSError* error); | 92 void DidWriteValue(CBCharacteristic* characteristic, NSError* error); |
| 97 void DidUpdateNotificationState(CBCharacteristic* characteristic, | 93 void DidUpdateNotificationState(CBCharacteristic* characteristic, |
| 98 NSError* error); | 94 NSError* error); |
| 99 | 95 |
| 100 // Updates information about the device. | |
| 101 virtual void Update(NSDictionary* advertisement_data, int rssi); | |
| 102 | |
| 103 static std::string GetPeripheralIdentifier(CBPeripheral* peripheral); | 96 static std::string GetPeripheralIdentifier(CBPeripheral* peripheral); |
| 104 | 97 |
| 105 // Hashes and truncates the peripheral identifier to deterministically | 98 // Hashes and truncates the peripheral identifier to deterministically |
| 106 // 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 |
| 107 // we switch to using bluetooth identifiers throughout Chrome. | 100 // we switch to using bluetooth identifiers throughout Chrome. |
| 108 // http://crbug.com/507824 | 101 // http://crbug.com/507824 |
| 109 static std::string GetPeripheralHashAddress(CBPeripheral* peripheral); | 102 static std::string GetPeripheralHashAddress(CBPeripheral* peripheral); |
| 110 | 103 |
| 111 private: | 104 private: |
| 112 friend class BluetoothAdapterMac; | 105 friend class BluetoothAdapterMac; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 129 // Callback used when the CoreBluetooth Peripheral is disconnected. | 122 // Callback used when the CoreBluetooth Peripheral is disconnected. |
| 130 void DidDisconnectPeripheral(BluetoothDevice::ConnectErrorCode error_code); | 123 void DidDisconnectPeripheral(BluetoothDevice::ConnectErrorCode error_code); |
| 131 | 124 |
| 132 // CoreBluetooth data structure. | 125 // CoreBluetooth data structure. |
| 133 base::scoped_nsobject<CBPeripheral> peripheral_; | 126 base::scoped_nsobject<CBPeripheral> peripheral_; |
| 134 | 127 |
| 135 // Objective-C delegate for the CBPeripheral. | 128 // Objective-C delegate for the CBPeripheral. |
| 136 base::scoped_nsobject<BluetoothLowEnergyPeripheralDelegate> | 129 base::scoped_nsobject<BluetoothLowEnergyPeripheralDelegate> |
| 137 peripheral_delegate_; | 130 peripheral_delegate_; |
| 138 | 131 |
| 139 // RSSI value. | |
| 140 int rssi_; | |
| 141 | |
| 142 // Whether the device is connectable. | 132 // Whether the device is connectable. |
| 143 bool connectable_; | 133 bool connectable_; |
| 144 | 134 |
| 145 // The peripheral's identifier, as returned by [CBPeripheral identifier]. | 135 // The peripheral's identifier, as returned by [CBPeripheral identifier]. |
| 146 std::string identifier_; | 136 std::string identifier_; |
| 147 | 137 |
| 148 // A local address for the device created by hashing the peripheral | 138 // A local address for the device created by hashing the peripheral |
| 149 // identifier. | 139 // identifier. |
| 150 std::string hash_address_; | 140 std::string hash_address_; |
| 151 | 141 |
| 152 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyDeviceMac); | 142 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyDeviceMac); |
| 153 }; | 143 }; |
| 154 | 144 |
| 155 } // namespace device | 145 } // namespace device |
| 156 | 146 |
| 157 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_ | 147 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_ |
| OLD | NEW |