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

Side by Side Diff: chromeos/dbus/bluetooth_gatt_characteristic_client.h

Issue 301093003: device/bluetooth: Update characteristic value D-Bus bindings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed comments. Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 CHROMEOS_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ 5 #ifndef CHROMEOS_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_
6 #define CHROMEOS_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ 6 #define CHROMEOS_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/callback.h"
11 #include "chromeos/chromeos_export.h" 12 #include "chromeos/chromeos_export.h"
12 #include "chromeos/dbus/dbus_client.h" 13 #include "chromeos/dbus/dbus_client.h"
13 #include "dbus/object_path.h" 14 #include "dbus/object_path.h"
14 #include "dbus/property.h" 15 #include "dbus/property.h"
15 16
16 namespace chromeos { 17 namespace chromeos {
17 18
18 // BluetoothGattCharacteristicClient is used to communicate with remote GATT 19 // BluetoothGattCharacteristicClient is used to communicate with remote GATT
19 // characteristic objects exposed by the Bluetooth daemon. 20 // characteristic objects exposed by the Bluetooth daemon.
20 class CHROMEOS_EXPORT BluetoothGattCharacteristicClient : public DBusClient { 21 class CHROMEOS_EXPORT BluetoothGattCharacteristicClient : public DBusClient {
21 public: 22 public:
22 // Structure of properties associated with GATT characteristics. 23 // Structure of properties associated with GATT characteristics.
23 struct Properties : public dbus::PropertySet { 24 struct Properties : public dbus::PropertySet {
24 // The 128-bit characteristic UUID. [read-only] 25 // The 128-bit characteristic UUID. [read-only]
25 dbus::Property<std::string> uuid; 26 dbus::Property<std::string> uuid;
26 27
27 // Object path of the GATT service the characteristic belongs to. 28 // Object path of the GATT service the characteristic belongs to.
28 // [read-only] 29 // [read-only]
29 dbus::Property<dbus::ObjectPath> service; 30 dbus::Property<dbus::ObjectPath> service;
30 31
31 // Characteristic value read from the remote Bluetooth device. Setting the
32 // value sends a write request to the remote device. [read-write]
33 dbus::Property<std::vector<uint8> > value;
34
35 // List of flags representing the GATT "Characteristic Properties bit field" 32 // List of flags representing the GATT "Characteristic Properties bit field"
36 // and properties read from the GATT "Characteristic Extended Properties" 33 // and properties read from the GATT "Characteristic Extended Properties"
37 // descriptor bit field. [read-only, optional] 34 // descriptor bit field. [read-only, optional]
38 dbus::Property<std::vector<std::string> > flags; 35 dbus::Property<std::vector<std::string> > flags;
39 36
40 Properties(dbus::ObjectProxy* object_proxy, 37 Properties(dbus::ObjectProxy* object_proxy,
41 const std::string& interface_name, 38 const std::string& interface_name,
42 const PropertyChangedCallback& callback); 39 const PropertyChangedCallback& callback);
43 virtual ~Properties(); 40 virtual ~Properties();
44 }; 41 };
(...skipping 10 matching lines...) Expand all
55 // Called when the GATT characteristic with object path |object_path| is 52 // Called when the GATT characteristic with object path |object_path| is
56 // removed from the system. 53 // removed from the system.
57 virtual void GattCharacteristicRemoved( 54 virtual void GattCharacteristicRemoved(
58 const dbus::ObjectPath& object_path) {} 55 const dbus::ObjectPath& object_path) {}
59 56
60 // Called when the GATT characteristic with object path |object_path| has a 57 // Called when the GATT characteristic with object path |object_path| has a
61 // change in the value of the property named |property_name|. 58 // change in the value of the property named |property_name|.
62 virtual void GattCharacteristicPropertyChanged( 59 virtual void GattCharacteristicPropertyChanged(
63 const dbus::ObjectPath& object_path, 60 const dbus::ObjectPath& object_path,
64 const std::string& property_name) {} 61 const std::string& property_name) {}
62
63 // Called when a "ValueUpdated" signal is received from the remote GATT
64 // characteristic with object path |object_path| with characteristic value
65 // |value|.
66 virtual void GattCharacteristicValueUpdated(
67 const dbus::ObjectPath& object_path,
68 const std::vector<uint8>& value) {}
65 }; 69 };
66 70
71 // Callbacks used to report the result of asynchronous methods.
72 typedef base::Callback<void(const std::string& error_name,
73 const std::string& error_message)> ErrorCallback;
74 typedef base::Callback<void(const std::vector<uint8>& value)> ValueCallback;
75
67 virtual ~BluetoothGattCharacteristicClient(); 76 virtual ~BluetoothGattCharacteristicClient();
68 77
69 // Adds and removes observers for events on all remote GATT characteristics. 78 // Adds and removes observers for events on all remote GATT characteristics.
70 // Check the |object_path| parameter of observer methods to determine which 79 // Check the |object_path| parameter of observer methods to determine which
71 // GATT characteristic is issuing the event. 80 // GATT characteristic is issuing the event.
72 virtual void AddObserver(Observer* observer) = 0; 81 virtual void AddObserver(Observer* observer) = 0;
73 virtual void RemoveObserver(Observer* observer) = 0; 82 virtual void RemoveObserver(Observer* observer) = 0;
74 83
75 // Returns the list of GATT characteristic object paths known to the system. 84 // Returns the list of GATT characteristic object paths known to the system.
76 virtual std::vector<dbus::ObjectPath> GetCharacteristics() = 0; 85 virtual std::vector<dbus::ObjectPath> GetCharacteristics() = 0;
77 86
78 // Obtain the properties for the GATT characteristic with object path 87 // Obtain the properties for the GATT characteristic with object path
79 // |object_path|. Values should be copied if needed. 88 // |object_path|. Values should be copied if needed.
80 virtual Properties* GetProperties(const dbus::ObjectPath& object_path) = 0; 89 virtual Properties* GetProperties(const dbus::ObjectPath& object_path) = 0;
81 90
91 // Issues a request to read the value of GATT characteristic with object path
92 // |object_path| and returns the value in |callback| on success. On error,
93 // invokes |error_callback|.
94 virtual void ReadValue(const dbus::ObjectPath& object_path,
95 const ValueCallback& callback,
96 const ErrorCallback& error_callback) = 0;
97
98 // Issues a request to write the value of GATT characteristic with object path
99 // |object_path| with value |value|. Invokes |callback| on success and
100 // |error_callback| on failure.
101 virtual void WriteValue(const dbus::ObjectPath& object_path,
102 const std::vector<uint8>& value,
103 const base::Closure& callback,
104 const ErrorCallback& error_callback) = 0;
105
82 // Creates the instance. 106 // Creates the instance.
83 static BluetoothGattCharacteristicClient* Create(); 107 static BluetoothGattCharacteristicClient* Create();
84 108
109 // Constants used to indicate exceptional error conditions.
110 static const char kNoResponseError[];
111 static const char kUnknownCharacteristicError[];
112
85 protected: 113 protected:
86 BluetoothGattCharacteristicClient(); 114 BluetoothGattCharacteristicClient();
87 115
88 private: 116 private:
89 DISALLOW_COPY_AND_ASSIGN(BluetoothGattCharacteristicClient); 117 DISALLOW_COPY_AND_ASSIGN(BluetoothGattCharacteristicClient);
90 }; 118 };
91 119
92 } // namespace chromeos 120 } // namespace chromeos
93 121
94 #endif // CHROMEOS_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ 122 #endif // CHROMEOS_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698