bluetooth_classic_device_mac.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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.
  4. #ifndef DEVICE_BLUETOOTH_BLUETOOTH_CLASSIC_DEVICE_MAC_H_
  5. #define DEVICE_BLUETOOTH_BLUETOOTH_CLASSIC_DEVICE_MAC_H_
  6. #import <IOBluetooth/IOBluetooth.h>
  7. #include <stdint.h>
  8. #include <string>
  9. #include "base/mac/scoped_nsobject.h"
  10. #include "base/time/time.h"
  11. #include "device/bluetooth/bluetooth_device_mac.h"
  12. #include "third_party/abseil-cpp/absl/types/optional.h"
  13. @class IOBluetoothDevice;
  14. namespace device {
  15. class BluetoothAdapterMac;
  16. class BluetoothUUID;
  17. class BluetoothClassicDeviceMac : public BluetoothDeviceMac {
  18. public:
  19. explicit BluetoothClassicDeviceMac(BluetoothAdapterMac* adapter,
  20. IOBluetoothDevice* device);
  21. BluetoothClassicDeviceMac(const BluetoothClassicDeviceMac&) = delete;
  22. BluetoothClassicDeviceMac& operator=(const BluetoothClassicDeviceMac&) =
  23. delete;
  24. ~BluetoothClassicDeviceMac() override;
  25. // BluetoothDevice override
  26. uint32_t GetBluetoothClass() const override;
  27. std::string GetAddress() const override;
  28. AddressType GetAddressType() const override;
  29. VendorIDSource GetVendorIDSource() const override;
  30. uint16_t GetVendorID() const override;
  31. uint16_t GetProductID() const override;
  32. uint16_t GetDeviceID() const override;
  33. uint16_t GetAppearance() const override;
  34. absl::optional<std::string> GetName() const override;
  35. bool IsPaired() const override;
  36. bool IsConnected() const override;
  37. bool IsGattConnected() const override;
  38. bool IsConnectable() const override;
  39. bool IsConnecting() const override;
  40. UUIDSet GetUUIDs() const override;
  41. absl::optional<int8_t> GetInquiryRSSI() const override;
  42. absl::optional<int8_t> GetInquiryTxPower() const override;
  43. bool ExpectingPinCode() const override;
  44. bool ExpectingPasskey() const override;
  45. bool ExpectingConfirmation() const override;
  46. void GetConnectionInfo(ConnectionInfoCallback callback) override;
  47. void SetConnectionLatency(ConnectionLatency connection_latency,
  48. base::OnceClosure callback,
  49. ErrorCallback error_callback) override;
  50. void Connect(PairingDelegate* pairing_delegate,
  51. ConnectCallback callback) override;
  52. void SetPinCode(const std::string& pincode) override;
  53. void SetPasskey(uint32_t passkey) override;
  54. void ConfirmPairing() override;
  55. void RejectPairing() override;
  56. void CancelPairing() override;
  57. void Disconnect(base::OnceClosure callback,
  58. ErrorCallback error_callback) override;
  59. void Forget(base::OnceClosure callback,
  60. ErrorCallback error_callback) override;
  61. void ConnectToService(const BluetoothUUID& uuid,
  62. ConnectToServiceCallback callback,
  63. ConnectToServiceErrorCallback error_callback) override;
  64. void ConnectToServiceInsecurely(
  65. const BluetoothUUID& uuid,
  66. ConnectToServiceCallback callback,
  67. ConnectToServiceErrorCallback error_callback) override;
  68. base::Time GetLastUpdateTime() const override;
  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. bool IsLowEnergyDevice() override;
  73. protected:
  74. // BluetoothDevice override
  75. void CreateGattConnectionImpl(
  76. absl::optional<BluetoothUUID> service_uuid) override;
  77. void DisconnectGatt() override;
  78. private:
  79. friend class BluetoothAdapterMac;
  80. // Implementation to read the host's transmit power level of type
  81. // |power_level_type|.
  82. int GetHostTransmitPower(
  83. BluetoothHCITransmitPowerLevelType power_level_type) const;
  84. base::scoped_nsobject<IOBluetoothDevice> device_;
  85. };
  86. } // namespace device
  87. #endif // DEVICE_BLUETOOTH_BLUETOOTH_CLASSIC_DEVICE_MAC_H_