Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(144)

Side by Side Diff: device/bluetooth/bluetooth_low_energy_device_mac.h

Issue 791763005: Added bluetooth LE support on Mac platform (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 defined(OS_IOS)
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 "base/mac/sdk_forward_declarations.h"
15 #include "device/bluetooth/bluetooth_device.h" 16 #include "device/bluetooth/bluetooth_device.h"
16 17
17 @class IOBluetoothDevice;
18
19 namespace device { 18 namespace device {
20 19
21 class BluetoothDeviceMac : public BluetoothDevice { 20 class BluetoothLowEnergyDiscoverManagerMac;
21
22 class BluetoothLowEnergyDeviceMac : public BluetoothDevice {
22 public: 23 public:
23 explicit BluetoothDeviceMac(IOBluetoothDevice* device); 24 BluetoothLowEnergyDeviceMac(CBPeripheral* peripheral,
24 ~BluetoothDeviceMac() override; 25 NSDictionary* advertisementData,
26 int rssi);
27 ~BluetoothLowEnergyDeviceMac() override;
25 28
26 // BluetoothDevice override 29 int GetRSSI() const;
30
31 // BluetoothDevice overrides.
32 std::string GetIdentifier() const override;
27 uint32 GetBluetoothClass() const override; 33 uint32 GetBluetoothClass() const override;
28 std::string GetAddress() const override; 34 std::string GetAddress() const override;
29 VendorIDSource GetVendorIDSource() const override; 35 BluetoothDevice::VendorIDSource GetVendorIDSource() const override;
30 uint16 GetVendorID() const override; 36 uint16 GetVendorID() const override;
31 uint16 GetProductID() const override; 37 uint16 GetProductID() const override;
32 uint16 GetDeviceID() const override; 38 uint16 GetDeviceID() const override;
33 bool IsPaired() const override; 39 bool IsPaired() const override;
34 bool IsConnected() const override; 40 bool IsConnected() const override;
35 bool IsConnectable() const override; 41 bool IsConnectable() const override;
36 bool IsConnecting() const override; 42 bool IsConnecting() const override;
37 UUIDList GetUUIDs() const override; 43 BluetoothDevice::UUIDList GetUUIDs() const override;
38 bool ExpectingPinCode() const override; 44 bool ExpectingPinCode() const override;
39 bool ExpectingPasskey() const override; 45 bool ExpectingPasskey() const override;
40 bool ExpectingConfirmation() const override; 46 bool ExpectingConfirmation() const override;
41 void GetConnectionInfo(const ConnectionInfoCallback& callback) override; 47 void GetConnectionInfo(const ConnectionInfoCallback& callback) override;
42 void Connect(PairingDelegate* pairing_delegate, 48 void Connect(PairingDelegate* pairing_delegate,
43 const base::Closure& callback, 49 const base::Closure& callback,
44 const ConnectErrorCallback& error_callback) override; 50 const ConnectErrorCallback& error_callback) override;
45 void SetPinCode(const std::string& pincode) override; 51 void SetPinCode(const std::string& pincode) override;
46 void SetPasskey(uint32 passkey) override; 52 void SetPasskey(uint32 passkey) override;
47 void ConfirmPairing() override; 53 void ConfirmPairing() override;
48 void RejectPairing() override; 54 void RejectPairing() override;
49 void CancelPairing() override; 55 void CancelPairing() override;
50 void Disconnect(const base::Closure& callback, 56 void Disconnect(const base::Closure& callback,
51 const ErrorCallback& error_callback) override; 57 const ErrorCallback& error_callback) override;
52 void Forget(const ErrorCallback& error_callback) override; 58 void Forget(const ErrorCallback& error_callback) override;
53 void ConnectToService( 59 void ConnectToService(
54 const BluetoothUUID& uuid, 60 const BluetoothUUID& uuid,
55 const ConnectToServiceCallback& callback, 61 const ConnectToServiceCallback& callback,
56 const ConnectToServiceErrorCallback& error_callback) override; 62 const ConnectToServiceErrorCallback& error_callback) override;
57 void ConnectToServiceInsecurely( 63 void ConnectToServiceInsecurely(
58 const BluetoothUUID& uuid, 64 const device::BluetoothUUID& uuid,
59 const ConnectToServiceCallback& callback, 65 const ConnectToServiceCallback& callback,
60 const ConnectToServiceErrorCallback& error_callback) override; 66 const ConnectToServiceErrorCallback& error_callback) override;
61 void CreateGattConnection( 67 void CreateGattConnection(
62 const GattConnectionCallback& callback, 68 const GattConnectionCallback& callback,
63 const ConnectErrorCallback& error_callback) override; 69 const ConnectErrorCallback& error_callback) override;
64 70
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: 71 protected:
74 // BluetoothDevice override 72 // BluetoothDevice override.
75 std::string GetDeviceName() const override; 73 std::string GetDeviceName() const override;
76 74
75 // Updates information about the device.
76 virtual void Update(CBPeripheral* peripheral,
77 NSDictionary* advertisementData,
78 int rssi);
79
80 static std::string GetPeripheralIdentifier(CBPeripheral* peripheral);
81
77 private: 82 private:
78 friend class BluetoothAdapterMac; 83 friend class BluetoothLowEnergyDiscoveryManagerMac;
79 84
80 // Implementation to read the host's transmit power level of type 85 // CoreBluetooth data structure.
81 // |power_level_type|. 86 base::scoped_nsobject<CBPeripheral> peripheral_;
82 int GetHostTransmitPower(
83 BluetoothHCITransmitPowerLevelType power_level_type) const;
84 87
85 base::scoped_nsobject<IOBluetoothDevice> device_; 88 // RSSI value.
89 int rssi_;
86 90
87 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceMac); 91 // Whether the device is connectable.
92 bool connectable_;
93
94 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyDeviceMac);
88 }; 95 };
89 96
90 } // namespace device 97 } // namespace device
91 98
92 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_MAC_H_ 99 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_discovery_manager_mac.h ('k') | device/bluetooth/bluetooth_low_energy_device_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698