OLD | NEW |
---|---|
1 // Copyright 2013 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_DEVICE_MAC_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_ |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_MAC_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_ |
7 | 7 |
8 #if TARGET_IPHONE_SIMULATOR || TARGET_OS_IPHONE | |
Avi (use Gerrit)
2015/01/29 05:25:02
You want to use the Chromium OS_ defines. Do not u
dvh
2015/01/30 22:45:45
Done.
| |
9 #import <CoreBluetooth/CoreBluetooth.h> | |
10 #else | |
8 #import <IOBluetooth/IOBluetooth.h> | 11 #import <IOBluetooth/IOBluetooth.h> |
12 #endif | |
9 | 13 |
10 #include <string> | |
11 | |
12 #include "base/basictypes.h" | |
13 #include "base/mac/scoped_nsobject.h" | 14 #include "base/mac/scoped_nsobject.h" |
14 #include "base/observer_list.h" | |
15 #include "device/bluetooth/bluetooth_device.h" | 15 #include "device/bluetooth/bluetooth_device.h" |
16 | 16 |
17 @class IOBluetoothDevice; | |
18 | |
19 namespace device { | 17 namespace device { |
20 | 18 |
21 class BluetoothDeviceMac : public BluetoothDevice { | 19 class BluetoothLowEnergyDiscoverManagerMac; |
20 | |
21 class BluetoothLowEnergyDeviceMac : public BluetoothDevice { | |
22 public: | 22 public: |
23 explicit BluetoothDeviceMac(IOBluetoothDevice* device); | 23 BluetoothLowEnergyDeviceMac(CBPeripheral* peripheral, |
24 ~BluetoothDeviceMac() override; | 24 NSDictionary* advertisementData, |
25 int rssi); | |
26 ~BluetoothLowEnergyDeviceMac() override; | |
25 | 27 |
26 // BluetoothDevice override | 28 virtual int GetRSSI() const; |
29 | |
30 // BluetoothDevice override. | |
armansito
2015/01/29 04:37:19
nit: s/override/overrides/
dvh
2015/01/30 22:45:45
Done.
| |
31 std::string GetIdentifier() const override; | |
27 uint32 GetBluetoothClass() const override; | 32 uint32 GetBluetoothClass() const override; |
28 std::string GetAddress() const override; | 33 std::string GetAddress() const override; |
29 VendorIDSource GetVendorIDSource() const override; | 34 BluetoothDevice::VendorIDSource GetVendorIDSource() const override; |
30 uint16 GetVendorID() const override; | 35 uint16 GetVendorID() const override; |
31 uint16 GetProductID() const override; | 36 uint16 GetProductID() const override; |
32 uint16 GetDeviceID() const override; | 37 uint16 GetDeviceID() const override; |
33 bool IsPaired() const override; | 38 bool IsPaired() const override; |
34 bool IsConnected() const override; | 39 bool IsConnected() const override; |
35 bool IsConnectable() const override; | 40 bool IsConnectable() const override; |
36 bool IsConnecting() const override; | 41 bool IsConnecting() const override; |
37 UUIDList GetUUIDs() const override; | 42 BluetoothDevice::UUIDList GetUUIDs() const override; |
38 bool ExpectingPinCode() const override; | 43 bool ExpectingPinCode() const override; |
39 bool ExpectingPasskey() const override; | 44 bool ExpectingPasskey() const override; |
40 bool ExpectingConfirmation() const override; | 45 bool ExpectingConfirmation() const override; |
41 void GetConnectionInfo(const ConnectionInfoCallback& callback) override; | 46 void GetConnectionInfo(const ConnectionInfoCallback& callback) override; |
42 void Connect(PairingDelegate* pairing_delegate, | 47 void Connect(PairingDelegate* pairing_delegate, |
43 const base::Closure& callback, | 48 const base::Closure& callback, |
44 const ConnectErrorCallback& error_callback) override; | 49 const ConnectErrorCallback& error_callback) override; |
45 void SetPinCode(const std::string& pincode) override; | 50 void SetPinCode(const std::string& pincode) override; |
46 void SetPasskey(uint32 passkey) override; | 51 void SetPasskey(uint32 passkey) override; |
47 void ConfirmPairing() override; | 52 void ConfirmPairing() override; |
48 void RejectPairing() override; | 53 void RejectPairing() override; |
49 void CancelPairing() override; | 54 void CancelPairing() override; |
50 void Disconnect(const base::Closure& callback, | 55 void Disconnect(const base::Closure& callback, |
51 const ErrorCallback& error_callback) override; | 56 const ErrorCallback& error_callback) override; |
52 void Forget(const ErrorCallback& error_callback) override; | 57 void Forget(const ErrorCallback& error_callback) override; |
53 void ConnectToService( | 58 void ConnectToService( |
54 const BluetoothUUID& uuid, | 59 const BluetoothUUID& uuid, |
55 const ConnectToServiceCallback& callback, | 60 const ConnectToServiceCallback& callback, |
56 const ConnectToServiceErrorCallback& error_callback) override; | 61 const ConnectToServiceErrorCallback& error_callback) override; |
57 void ConnectToServiceInsecurely( | 62 void ConnectToServiceInsecurely( |
58 const BluetoothUUID& uuid, | 63 const device::BluetoothUUID& uuid, |
59 const ConnectToServiceCallback& callback, | 64 const ConnectToServiceCallback& callback, |
60 const ConnectToServiceErrorCallback& error_callback) override; | 65 const ConnectToServiceErrorCallback& error_callback) override; |
61 void CreateGattConnection( | 66 void CreateGattConnection( |
62 const GattConnectionCallback& callback, | 67 const GattConnectionCallback& callback, |
63 const ConnectErrorCallback& error_callback) override; | 68 const ConnectErrorCallback& error_callback) override; |
64 | 69 |
65 // Returns the timestamp when the device was last seen during an inquiry. | |
66 // Returns nil if the device has never been seen during an inquiry. | |
67 NSDate* GetLastInquiryUpdate(); | |
68 | |
69 // Returns the Bluetooth address for the |device|. The returned address has a | |
70 // normalized format (see below). | |
71 static std::string GetDeviceAddress(IOBluetoothDevice* device); | |
72 | |
73 protected: | 70 protected: |
74 // BluetoothDevice override | 71 // BluetoothDevice override. |
75 std::string GetDeviceName() const override; | 72 std::string GetDeviceName() const override; |
76 | 73 |
74 // Updates information about the device. | |
75 virtual void Update(CBPeripheral* peripheral, | |
76 NSDictionary* advertisementData, | |
77 int rssi); | |
78 | |
77 private: | 79 private: |
78 friend class BluetoothAdapterMac; | 80 friend class BluetoothLowEnergyDiscoverManagerMac; |
79 | 81 |
80 // Implementation to read the host's transmit power level of type | 82 // CoreBluetooth data structure. |
81 // |power_level_type|. | 83 base::scoped_nsobject<CBPeripheral> peripheral_; |
82 int GetHostTransmitPower( | |
83 BluetoothHCITransmitPowerLevelType power_level_type) const; | |
84 | 84 |
85 base::scoped_nsobject<IOBluetoothDevice> device_; | 85 // RSSI value. |
86 int rssi_; | |
86 | 87 |
87 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceMac); | 88 // Whether the device is connectable. |
89 bool connectable_; | |
90 | |
91 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyDeviceMac); | |
88 }; | 92 }; |
93 } | |
Avi (use Gerrit)
2015/01/29 05:25:02
Add a blank space here. Why did you remove the "//
dvh
2015/01/30 22:45:45
Done.
| |
89 | 94 |
90 } // namespace device | 95 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_ |
91 | |
92 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_MAC_H_ | |
OLD | NEW |