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_DBUS_BLUETOOTH_GATT_ATTRIBUTE_VALUE_DELEGATE_H_ |
| 6 #define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_ATTRIBUTE_VALUE_DELEGATE_H_ |
| 7 |
| 8 #include <cstdint> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/callback_forward.h" |
| 12 #include "device/bluetooth/bluetooth_local_gatt_service.h" |
| 13 |
| 14 namespace bluez { |
| 15 |
| 16 // A simpler interface for reacting to GATT attribute value requests by the |
| 17 // DBus attribute service providers. |
| 18 class BluetoothGattAttributeValueDelegate { |
| 19 public: |
| 20 virtual ~BluetoothGattAttributeValueDelegate() {} |
| 21 |
| 22 // This method will be called when a remote device requests to read the |
| 23 // value of the exported GATT attribute. Invoke |callback| with a value |
| 24 // to return that value to the requester. Invoke |error_callback| to report |
| 25 // a failure to read the value. This can happen, for example, if the |
| 26 // attribute has no read permission set. Either callback should be |
| 27 // invoked after a reasonable amount of time, since the request will time |
| 28 // out if left pending for too long causing a disconnection. |
| 29 virtual void GetValue( |
| 30 const device::BluetoothLocalGattService::Delegate::ValueCallback& |
| 31 callback, |
| 32 const device::BluetoothLocalGattService::Delegate::ErrorCallback& |
| 33 error_callback) = 0; |
| 34 |
| 35 // This method will be called, when a remote device requests to write the |
| 36 // value of the exported GATT attribute. Invoke |callback| to report |
| 37 // that the value was successfully written. Invoke |error_callback| to |
| 38 // report a failure to write the value. This can happen, for example, if the |
| 39 // attribute has no write permission set. Either callback should be |
| 40 // invoked after a reasonable amount of time, since the request will time |
| 41 // out if left pending for too long causing a disconnection. |
| 42 virtual void SetValue( |
| 43 const std::vector<uint8_t>& value, |
| 44 const base::Closure& callback, |
| 45 const device::BluetoothLocalGattService::Delegate::ErrorCallback& |
| 46 error_callback) = 0; |
| 47 }; |
| 48 |
| 49 } // namespace bluez |
| 50 |
| 51 #endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_ATTRIBUTE_VALUE_DELEGATE_H_ |
OLD | NEW |