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 | |
9 #import <CoreBluetooth/CoreBluetooth.h> | |
10 #else | |
8 #import <IOBluetooth/IOBluetooth.h> | 11 #import <IOBluetooth/IOBluetooth.h> |
armansito
2015/01/24 17:59:37
Does importing IOBluetooth.h on Mac also include t
dvh
2015/01/27 00:14:55
Sure, it will import CoreBluetooth automatically f
armansito
2015/01/29 04:37:18
OK, I just vaguely remember having to directly imp
| |
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, int rssi); |
25 ~BluetoothLowEnergyDeviceMac() override; | |
25 | 26 |
armansito
2015/01/24 18:07:09
nit: We usually don't add new lines between overri
dvh
2015/01/27 00:14:55
Done.
| |
26 // BluetoothDevice override | 27 std::string GetIdentifier() const override; |
28 | |
27 uint32 GetBluetoothClass() const override; | 29 uint32 GetBluetoothClass() const override; |
30 | |
28 std::string GetAddress() const override; | 31 std::string GetAddress() const override; |
29 VendorIDSource GetVendorIDSource() const override; | 32 |
33 BluetoothDevice::VendorIDSource GetVendorIDSource() const override; | |
34 | |
30 uint16 GetVendorID() const override; | 35 uint16 GetVendorID() const override; |
36 | |
31 uint16 GetProductID() const override; | 37 uint16 GetProductID() const override; |
38 | |
32 uint16 GetDeviceID() const override; | 39 uint16 GetDeviceID() const override; |
40 | |
41 virtual int GetRSSI() const; | |
42 | |
33 bool IsPaired() const override; | 43 bool IsPaired() const override; |
44 | |
34 bool IsConnected() const override; | 45 bool IsConnected() const override; |
46 | |
35 bool IsConnectable() const override; | 47 bool IsConnectable() const override; |
48 | |
36 bool IsConnecting() const override; | 49 bool IsConnecting() const override; |
37 UUIDList GetUUIDs() const override; | 50 |
51 BluetoothDevice::UUIDList GetUUIDs() const override; | |
52 | |
38 bool ExpectingPinCode() const override; | 53 bool ExpectingPinCode() const override; |
54 | |
39 bool ExpectingPasskey() const override; | 55 bool ExpectingPasskey() const override; |
56 | |
40 bool ExpectingConfirmation() const override; | 57 bool ExpectingConfirmation() const override; |
58 | |
41 void GetConnectionInfo(const ConnectionInfoCallback& callback) override; | 59 void GetConnectionInfo(const ConnectionInfoCallback& callback) override; |
42 void Connect(PairingDelegate* pairing_delegate, | 60 |
43 const base::Closure& callback, | 61 void Connect(PairingDelegate* pairing_delegate, const base::Closure& callback, |
44 const ConnectErrorCallback& error_callback) override; | 62 const ConnectErrorCallback& error_callback) override; |
63 | |
45 void SetPinCode(const std::string& pincode) override; | 64 void SetPinCode(const std::string& pincode) override; |
65 | |
46 void SetPasskey(uint32 passkey) override; | 66 void SetPasskey(uint32 passkey) override; |
67 | |
47 void ConfirmPairing() override; | 68 void ConfirmPairing() override; |
69 | |
48 void RejectPairing() override; | 70 void RejectPairing() override; |
71 | |
49 void CancelPairing() override; | 72 void CancelPairing() override; |
73 | |
50 void Disconnect(const base::Closure& callback, | 74 void Disconnect(const base::Closure& callback, |
51 const ErrorCallback& error_callback) override; | 75 const ErrorCallback& error_callback) override; |
76 | |
52 void Forget(const ErrorCallback& error_callback) override; | 77 void Forget(const ErrorCallback& error_callback) override; |
78 | |
53 void ConnectToService( | 79 void ConnectToService( |
54 const BluetoothUUID& uuid, | 80 const BluetoothUUID& uuid, const ConnectToServiceCallback& callback, |
81 const ConnectToServiceErrorCallback& error_callback) override; | |
82 | |
83 void ConnectToServiceInsecurely( | |
84 const device::BluetoothUUID& uuid, | |
55 const ConnectToServiceCallback& callback, | 85 const ConnectToServiceCallback& callback, |
56 const ConnectToServiceErrorCallback& error_callback) override; | 86 const ConnectToServiceErrorCallback& error_callback) override; |
57 void ConnectToServiceInsecurely( | 87 |
58 const BluetoothUUID& uuid, | |
59 const ConnectToServiceCallback& callback, | |
60 const ConnectToServiceErrorCallback& error_callback) override; | |
61 void CreateGattConnection( | 88 void CreateGattConnection( |
62 const GattConnectionCallback& callback, | 89 const GattConnectionCallback& callback, |
63 const ConnectErrorCallback& error_callback) override; | 90 const ConnectErrorCallback& error_callback) override; |
64 | 91 |
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: | 92 protected: |
74 // BluetoothDevice override | |
75 std::string GetDeviceName() const override; | 93 std::string GetDeviceName() const override; |
76 | 94 |
95 // Updates information about the device. | |
96 virtual void Update(CBPeripheral* peripheral, NSDictionary* advertisementData, | |
97 int rssi); | |
98 | |
77 private: | 99 private: |
78 friend class BluetoothAdapterMac; | 100 friend class BluetoothLowEnergyDiscoverManagerMac; |
79 | 101 |
80 // Implementation to read the host's transmit power level of type | 102 // CoreBluetooth data structure. |
81 // |power_level_type|. | 103 base::scoped_nsobject<CBPeripheral> peripheral_; |
armansito
2015/01/24 18:07:09
nit: Add new lines between member declarations her
dvh
2015/01/27 00:14:55
Done.
| |
82 int GetHostTransmitPower( | 104 // RSSI value. |
83 BluetoothHCITransmitPowerLevelType power_level_type) const; | 105 int rssi_; |
106 // Whether the device is connectable. | |
107 bool connectable_; | |
84 | 108 |
85 base::scoped_nsobject<IOBluetoothDevice> device_; | 109 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyDeviceMac); |
110 }; | |
111 } | |
86 | 112 |
87 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceMac); | 113 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_ |
88 }; | |
89 | |
90 } // namespace device | |
91 | |
92 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_MAC_H_ | |
OLD | NEW |