bluetooth_local_gatt_descriptor.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Copyright 2016 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_LOCAL_GATT_DESCRIPTOR_H_
  5. #define DEVICE_BLUETOOTH_BLUETOOTH_LOCAL_GATT_DESCRIPTOR_H_
  6. #include <stdint.h>
  7. #include "device/bluetooth/bluetooth_export.h"
  8. #include "device/bluetooth/bluetooth_gatt_descriptor.h"
  9. #include "device/bluetooth/bluetooth_local_gatt_characteristic.h"
  10. #include "device/bluetooth/public/cpp/bluetooth_uuid.h"
  11. namespace device {
  12. // BluetoothLocalGattDescriptor represents a local GATT characteristic
  13. // descriptor. A GATT characteristic descriptor provides further information
  14. // about a characteristic's value. They can be used to describe the
  15. // characteristic's features or to control certain behaviors.
  16. //
  17. // Note: We use virtual inheritance on the GATT descriptor since it will be
  18. // inherited by platform specific versions of the GATT descriptor classes also.
  19. // The platform specific local GATT descriptor classes will inherit both this
  20. // class and their GATT descriptor class, hence causing an inheritance diamond.
  21. class DEVICE_BLUETOOTH_EXPORT BluetoothLocalGattDescriptor
  22. : public virtual BluetoothGattDescriptor {
  23. public:
  24. // Constructs a BluetoothLocalGattDescriptor that can be associated with a
  25. // local GATT characteristic when the adapter is in the peripheral role. To
  26. // associate the returned descriptor with a characteristic, provide a pointer
  27. // to that characteristic instance to the create function.
  28. //
  29. // This method constructs a characteristic descriptor with UUID |uuid| and the
  30. // initial cached value |value|. |value| will be cached and returned for read
  31. // requests and automatically modified for write requests by default, unless
  32. // an instance of BluetoothLocalGattService::Delegate has been provided to
  33. // the
  34. // associated BluetoothLocalGattService instance, in which case the delegate
  35. // will
  36. // handle the read and write requests.
  37. //
  38. // Currently, only custom UUIDs, |kCharacteristicDescriptionUuid|, and
  39. // |kCharacteristicPresentationFormat| are supported for locally hosted
  40. // descriptors. This method will return NULL if |uuid| is any one of the
  41. // unsupported predefined descriptor UUIDs.
  42. static base::WeakPtr<BluetoothLocalGattDescriptor> Create(
  43. const BluetoothUUID& uuid,
  44. BluetoothGattCharacteristic::Permissions permissions,
  45. BluetoothLocalGattCharacteristic* characteristic);
  46. BluetoothLocalGattDescriptor(const BluetoothLocalGattDescriptor&) = delete;
  47. BluetoothLocalGattDescriptor& operator=(const BluetoothLocalGattDescriptor&) =
  48. delete;
  49. virtual BluetoothLocalGattCharacteristic* GetCharacteristic() const = 0;
  50. protected:
  51. BluetoothLocalGattDescriptor();
  52. ~BluetoothLocalGattDescriptor() override;
  53. };
  54. } // namespace device
  55. #endif // DEVICE_BLUETOOTH_BLUETOOTH_LOCAL_GATT_DESCRIPTOR_H_