OLD | NEW |
(Empty) | |
| 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 |
| 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_H_ |
| 7 |
| 8 #include <stdint.h> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/callback.h" |
| 12 #include "base/callback_forward.h" |
| 13 #include "base/macros.h" |
| 14 #include "device/bluetooth/bluetooth_export.h" |
| 15 #include "device/bluetooth/bluetooth_gatt_characteristic.h" |
| 16 #include "device/bluetooth/bluetooth_gatt_descriptor.h" |
| 17 #include "device/bluetooth/bluetooth_uuid.h" |
| 18 |
| 19 namespace device { |
| 20 |
| 21 class BluetoothRemoteGattCharacteristic; |
| 22 |
| 23 // BluetoothRemoteGattDescriptor represents a remote GATT characteristic |
| 24 // descriptor. |
| 25 // |
| 26 // Note: We use virtual inheritance on the GATT descriptor since it will be |
| 27 // inherited by platform specific versions of the GATT descriptor classes also. |
| 28 // The platform specific remote GATT descriptor classes will inherit both this |
| 29 // class and their GATT descriptor class, hence causing an inheritance diamond. |
| 30 class DEVICE_BLUETOOTH_EXPORT BluetoothRemoteGattDescriptor |
| 31 : public virtual BluetoothGattDescriptor { |
| 32 public: |
| 33 // The ValueCallback is used to return the value of a remote characteristic |
| 34 // descriptor upon a read request. |
| 35 typedef base::Callback<void(const std::vector<uint8_t>&)> ValueCallback; |
| 36 |
| 37 // The Bluetooth-specific UUID of the characteristic descriptor. |
| 38 virtual BluetoothUUID GetUUID() const = 0; |
| 39 |
| 40 // Returns the value of the descriptor. For remote descriptors, this is the |
| 41 // most recently cached value of the remote descriptor. For local descriptors |
| 42 // this is the most recently updated value or the value retrieved from the |
| 43 // delegate. |
| 44 virtual const std::vector<uint8_t>& GetValue() const = 0; |
| 45 |
| 46 // Returns a pointer to the GATT characteristic that this characteristic |
| 47 // descriptor belongs to. |
| 48 virtual BluetoothRemoteGattCharacteristic* GetCharacteristic() const = 0; |
| 49 |
| 50 // Returns the bitmask of characteristic descriptor attribute permissions. |
| 51 virtual BluetoothGattCharacteristic::Permissions GetPermissions() const = 0; |
| 52 |
| 53 // Sends a read request to a remote characteristic descriptor to read its |
| 54 // value. |callback| is called to return the read value on success and |
| 55 // |error_callback| is called for failures. |
| 56 virtual void ReadRemoteDescriptor(const ValueCallback& callback, |
| 57 const ErrorCallback& error_callback) = 0; |
| 58 |
| 59 // Sends a write request to a remote characteristic descriptor, to modify the |
| 60 // value of the descriptor with the new value |new_value|. |callback| is |
| 61 // called to signal success and |error_callback| for failures. This method |
| 62 // only applies to remote descriptors and will fail for those that are locally |
| 63 // hosted. |
| 64 virtual void WriteRemoteDescriptor(const std::vector<uint8_t>& new_value, |
| 65 const base::Closure& callback, |
| 66 const ErrorCallback& error_callback) = 0; |
| 67 |
| 68 protected: |
| 69 BluetoothRemoteGattDescriptor(); |
| 70 ~BluetoothRemoteGattDescriptor() override; |
| 71 |
| 72 private: |
| 73 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattDescriptor); |
| 74 }; |
| 75 |
| 76 } // namespace device |
| 77 |
| 78 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_DESCRIPTOR_H_ |
OLD | NEW |