Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(307)

Side by Side Diff: device/bluetooth/dbus/bluetooth_gatt_attribute_value_delegate.h

Issue 1979163002: Add DBus plumbing and tests for sending devices with ATT read/writes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@devices
Patch Set: gyp fix Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_ATTRIBUTE_VALUE_DELEGATE_H_ 5 #ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_ATTRIBUTE_VALUE_DELEGATE_H_
6 #define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_ATTRIBUTE_VALUE_DELEGATE_H_ 6 #define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_ATTRIBUTE_VALUE_DELEGATE_H_
7 7
8 #include <cstdint> 8 #include <cstdint>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "device/bluetooth/bluetooth_local_gatt_service.h" 12 #include "device/bluetooth/bluetooth_local_gatt_service.h"
13 13
14 namespace dbus {
15 class ObjectPath;
16 }
17
18 namespace device {
19 class BluetoothDevice;
20 }
21
14 namespace bluez { 22 namespace bluez {
15 23
24 class BluetoothLocalGattServiceBlueZ;
25
16 // A simpler interface for reacting to GATT attribute value requests by the 26 // A simpler interface for reacting to GATT attribute value requests by the
17 // DBus attribute service providers. 27 // DBus attribute service providers.
18 class BluetoothGattAttributeValueDelegate { 28 class BluetoothGattAttributeValueDelegate {
19 public: 29 public:
20 virtual ~BluetoothGattAttributeValueDelegate() {} 30 explicit BluetoothGattAttributeValueDelegate(
31 BluetoothLocalGattServiceBlueZ* service);
32 virtual ~BluetoothGattAttributeValueDelegate();
21 33
22 // This method will be called when a remote device requests to read the 34 // 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 35 // value of the exported GATT attribute. Invoke |callback| with a value
24 // to return that value to the requester. Invoke |error_callback| to report 36 // 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 37 // a failure to read the value. This can happen, for example, if the
26 // attribute has no read permission set. Either callback should be 38 // attribute has no read permission set. Either callback should be
27 // invoked after a reasonable amount of time, since the request will time 39 // invoked after a reasonable amount of time, since the request will time
28 // out if left pending for too long causing a disconnection. 40 // out if left pending for too long causing a disconnection.
29 virtual void GetValue( 41 virtual void GetValue(
42 const dbus::ObjectPath& device_path,
30 const device::BluetoothLocalGattService::Delegate::ValueCallback& 43 const device::BluetoothLocalGattService::Delegate::ValueCallback&
31 callback, 44 callback,
32 const device::BluetoothLocalGattService::Delegate::ErrorCallback& 45 const device::BluetoothLocalGattService::Delegate::ErrorCallback&
33 error_callback) = 0; 46 error_callback) = 0;
34 47
35 // This method will be called, when a remote device requests to write the 48 // This method will be called, when a remote device requests to write the
36 // value of the exported GATT attribute. Invoke |callback| to report 49 // value of the exported GATT attribute. Invoke |callback| to report
37 // that the value was successfully written. Invoke |error_callback| to 50 // 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 51 // 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 52 // attribute has no write permission set. Either callback should be
40 // invoked after a reasonable amount of time, since the request will time 53 // invoked after a reasonable amount of time, since the request will time
41 // out if left pending for too long causing a disconnection. 54 // out if left pending for too long causing a disconnection.
42 virtual void SetValue( 55 virtual void SetValue(
56 const dbus::ObjectPath& device_path,
43 const std::vector<uint8_t>& value, 57 const std::vector<uint8_t>& value,
44 const base::Closure& callback, 58 const base::Closure& callback,
45 const device::BluetoothLocalGattService::Delegate::ErrorCallback& 59 const device::BluetoothLocalGattService::Delegate::ErrorCallback&
46 error_callback) = 0; 60 error_callback) = 0;
47 61
48 // This method will be called, when a remote device requests to start sending 62 // This method will be called, when a remote device requests to start sending
49 // notifications for this characteristic. This will never be called for 63 // notifications for this characteristic. This will never be called for
50 // descriptors. 64 // descriptors.
51 virtual void StartNotifications() = 0; 65 virtual void StartNotifications() = 0;
52 66
53 // This method will be called, when a remote device requests to stop sending 67 // This method will be called, when a remote device requests to stop sending
54 // notifications for this characteristic. This will never be called for 68 // notifications for this characteristic. This will never be called for
55 // descriptors. 69 // descriptors.
56 virtual void StopNotifications() = 0; 70 virtual void StopNotifications() = 0;
71
72 protected:
73 // Gets the Bluetooth device object on the current service's adapter with
74 // the given object path.
75 device::BluetoothDevice* GetDeviceWithPath(
76 const dbus::ObjectPath& object_path);
77
78 const BluetoothLocalGattServiceBlueZ* service() { return service_; }
79
80 private:
81 const BluetoothLocalGattServiceBlueZ* service_;
82
83 DISALLOW_COPY_AND_ASSIGN(BluetoothGattAttributeValueDelegate);
57 }; 84 };
58 85
59 } // namespace bluez 86 } // namespace bluez
60 87
61 #endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_ATTRIBUTE_VALUE_DELEGATE_H_ 88 #endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_ATTRIBUTE_VALUE_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698