1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_MAC_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_MAC_H_
8 #import <IOBluetooth/IOBluetooth.h>
12 #include "base/basictypes.h"
13 #include "base/mac/scoped_nsobject.h"
14 #include "base/observer_list.h"
15 #include "device/bluetooth/bluetooth_device.h"
17 @class IOBluetoothDevice;
21 class BluetoothDeviceMac : public BluetoothDevice {
23 explicit BluetoothDeviceMac(IOBluetoothDevice* device);
24 ~BluetoothDeviceMac() override;
26 // BluetoothDevice override
27 uint32 GetBluetoothClass() const override;
28 std::string GetAddress() const override;
29 VendorIDSource GetVendorIDSource() const override;
30 uint16 GetVendorID() const override;
31 uint16 GetProductID() const override;
32 uint16 GetDeviceID() const override;
33 int GetRSSI() const override;
34 int GetCurrentHostTransmitPower() const override;
35 int GetMaximumHostTransmitPower() const override;
36 bool IsPaired() const override;
37 bool IsConnected() const override;
38 bool IsConnectable() const override;
39 bool IsConnecting() const override;
40 UUIDList GetUUIDs() const override;
41 bool ExpectingPinCode() const override;
42 bool ExpectingPasskey() const override;
43 bool ExpectingConfirmation() const override;
44 void Connect(PairingDelegate* pairing_delegate,
45 const base::Closure& callback,
46 const ConnectErrorCallback& error_callback) override;
47 void SetPinCode(const std::string& pincode) override;
48 void SetPasskey(uint32 passkey) override;
49 void ConfirmPairing() override;
50 void RejectPairing() override;
51 void CancelPairing() override;
52 void Disconnect(const base::Closure& callback,
53 const ErrorCallback& error_callback) override;
54 void Forget(const ErrorCallback& error_callback) override;
55 void ConnectToService(
56 const BluetoothUUID& uuid,
57 const ConnectToServiceCallback& callback,
58 const ConnectToServiceErrorCallback& error_callback) override;
59 void ConnectToServiceInsecurely(
60 const BluetoothUUID& uuid,
61 const ConnectToServiceCallback& callback,
62 const ConnectToServiceErrorCallback& error_callback) override;
63 void CreateGattConnection(
64 const GattConnectionCallback& callback,
65 const ConnectErrorCallback& error_callback) override;
66 void StartConnectionMonitor(const base::Closure& callback,
67 const ErrorCallback& error_callback) override;
69 // Returns the timestamp when the device was last seen during an inquiry.
70 // Returns nil if the device has never been seen during an inquiry.
71 NSDate* GetLastInquiryUpdate();
73 // Returns the Bluetooth address for the |device|. The returned address has a
74 // normalized format (see below).
75 static std::string GetDeviceAddress(IOBluetoothDevice* device);
78 // BluetoothDevice override
79 std::string GetDeviceName() const override;
82 friend class BluetoothAdapterMac;
84 // Implementation to read the host's transmit power level of type
85 // |power_level_type|.
86 int GetHostTransmitPower(
87 BluetoothHCITransmitPowerLevelType power_level_type) const;
89 base::scoped_nsobject<IOBluetoothDevice> device_;
91 DISALLOW_COPY_AND_ASSIGN(BluetoothDeviceMac);
96 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_MAC_H_