bluetooth_gatt_characteristic_delegate_wrapper.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_DELEGATE_WRAPPER_H_
  5. #define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_DELEGATE_WRAPPER_H_
  6. #include <cstdint>
  7. #include <vector>
  8. #include "base/callback_forward.h"
  9. #include "base/memory/raw_ptr.h"
  10. #include "device/bluetooth/bluetooth_gatt_characteristic.h"
  11. #include "device/bluetooth/bluetooth_local_gatt_service.h"
  12. #include "device/bluetooth/bluez/bluetooth_gatt_service_bluez.h"
  13. #include "device/bluetooth/bluez/bluetooth_local_gatt_service_bluez.h"
  14. #include "device/bluetooth/dbus/bluetooth_gatt_attribute_value_delegate.h"
  15. namespace bluez {
  16. class BluetoothLocalGattCharacteristicBlueZ;
  17. // Wrapper class around AttributeValueDelegate to handle characteristics.
  18. class BluetoothGattCharacteristicDelegateWrapper
  19. : public BluetoothGattAttributeValueDelegate {
  20. public:
  21. BluetoothGattCharacteristicDelegateWrapper(
  22. BluetoothLocalGattServiceBlueZ* service,
  23. BluetoothLocalGattCharacteristicBlueZ* characteristic);
  24. BluetoothGattCharacteristicDelegateWrapper(
  25. const BluetoothGattCharacteristicDelegateWrapper&) = delete;
  26. BluetoothGattCharacteristicDelegateWrapper& operator=(
  27. const BluetoothGattCharacteristicDelegateWrapper&) = delete;
  28. // BluetoothGattAttributeValueDelegate overrides:
  29. void GetValue(const dbus::ObjectPath& device_path,
  30. device::BluetoothLocalGattService::Delegate::ValueCallback
  31. callback) override;
  32. void SetValue(const dbus::ObjectPath& device_path,
  33. const std::vector<uint8_t>& value,
  34. base::OnceClosure callback,
  35. device::BluetoothLocalGattService::Delegate::ErrorCallback
  36. error_callback) override;
  37. void PrepareSetValue(
  38. const dbus::ObjectPath& device_path,
  39. const std::vector<uint8_t>& value,
  40. int offset,
  41. bool has_subsequent_request,
  42. base::OnceClosure callback,
  43. device::BluetoothLocalGattService::Delegate::ErrorCallback error_callback)
  44. override;
  45. void StartNotifications(const dbus::ObjectPath& device_path,
  46. device::BluetoothGattCharacteristic::NotificationType
  47. notification_type) override;
  48. void StopNotifications(const dbus::ObjectPath& device_path) override;
  49. private:
  50. raw_ptr<BluetoothLocalGattCharacteristicBlueZ> characteristic_;
  51. };
  52. } // namespace bluez
  53. #endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_DELEGATE_WRAPPER_H_