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
3 // found in the LICENSE file.
5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_
9 #import <CoreBluetooth/CoreBluetooth.h>
11 #import <IOBluetooth/IOBluetooth.h>
14 #include "base/mac/scoped_nsobject.h"
15 #include "base/mac/sdk_forward_declarations.h"
16 #include "device/bluetooth/bluetooth_device.h"
20 class BluetoothLowEnergyDiscoverManagerMac
;
22 class BluetoothLowEnergyDeviceMac
: public BluetoothDevice
{
24 BluetoothLowEnergyDeviceMac(CBPeripheral
* peripheral
,
25 NSDictionary
* advertisementData
,
27 ~BluetoothLowEnergyDeviceMac() override
;
31 // BluetoothDevice overrides.
32 std::string
GetIdentifier() const override
;
33 uint32
GetBluetoothClass() const override
;
34 std::string
GetAddress() const override
;
35 BluetoothDevice::VendorIDSource
GetVendorIDSource() const override
;
36 uint16
GetVendorID() const override
;
37 uint16
GetProductID() const override
;
38 uint16
GetDeviceID() const override
;
39 bool IsPaired() const override
;
40 bool IsConnected() const override
;
41 bool IsConnectable() const override
;
42 bool IsConnecting() const override
;
43 BluetoothDevice::UUIDList
GetUUIDs() const override
;
44 int16
GetInquiryRSSI() const override
;
45 int16
GetInquiryTxPower() const override
;
46 bool ExpectingPinCode() const override
;
47 bool ExpectingPasskey() const override
;
48 bool ExpectingConfirmation() const override
;
49 void GetConnectionInfo(const ConnectionInfoCallback
& callback
) override
;
50 void Connect(PairingDelegate
* pairing_delegate
,
51 const base::Closure
& callback
,
52 const ConnectErrorCallback
& error_callback
) override
;
53 void SetPinCode(const std::string
& pincode
) override
;
54 void SetPasskey(uint32 passkey
) override
;
55 void ConfirmPairing() override
;
56 void RejectPairing() override
;
57 void CancelPairing() override
;
58 void Disconnect(const base::Closure
& callback
,
59 const ErrorCallback
& error_callback
) override
;
60 void Forget(const ErrorCallback
& error_callback
) override
;
61 void ConnectToService(
62 const BluetoothUUID
& uuid
,
63 const ConnectToServiceCallback
& callback
,
64 const ConnectToServiceErrorCallback
& error_callback
) override
;
65 void ConnectToServiceInsecurely(
66 const device::BluetoothUUID
& uuid
,
67 const ConnectToServiceCallback
& callback
,
68 const ConnectToServiceErrorCallback
& error_callback
) override
;
69 void CreateGattConnection(
70 const GattConnectionCallback
& callback
,
71 const ConnectErrorCallback
& error_callback
) override
;
74 // BluetoothDevice override.
75 std::string
GetDeviceName() const override
;
77 // Updates information about the device.
78 virtual void Update(CBPeripheral
* peripheral
,
79 NSDictionary
* advertisementData
,
82 static std::string
GetPeripheralIdentifier(CBPeripheral
* peripheral
);
85 friend class BluetoothAdapterMac
;
87 // CoreBluetooth data structure.
88 base::scoped_nsobject
<CBPeripheral
> peripheral_
;
93 // Whether the device is connectable.
96 DISALLOW_COPY_AND_ASSIGN(BluetoothLowEnergyDeviceMac
);
101 #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOW_ENERGY_DEVICE_MAC_H_