OLD | NEW |
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 DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ | 5 #ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ |
6 #define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ | 6 #define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ |
7 | 7 |
| 8 #include <stdint.h> |
| 9 |
8 #include <string> | 10 #include <string> |
9 #include <vector> | 11 #include <vector> |
10 | 12 |
11 #include "base/basictypes.h" | |
12 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/macros.h" |
13 #include "dbus/object_path.h" | 15 #include "dbus/object_path.h" |
14 #include "dbus/property.h" | 16 #include "dbus/property.h" |
15 #include "device/bluetooth/bluetooth_export.h" | 17 #include "device/bluetooth/bluetooth_export.h" |
16 #include "device/bluetooth/dbus/bluez_dbus_client.h" | 18 #include "device/bluetooth/dbus/bluez_dbus_client.h" |
17 | 19 |
18 namespace bluez { | 20 namespace bluez { |
19 | 21 |
20 // BluetoothGattCharacteristicClient is used to communicate with remote GATT | 22 // BluetoothGattCharacteristicClient is used to communicate with remote GATT |
21 // characteristic objects exposed by the Bluetooth daemon. | 23 // characteristic objects exposed by the Bluetooth daemon. |
22 class DEVICE_BLUETOOTH_EXPORT BluetoothGattCharacteristicClient | 24 class DEVICE_BLUETOOTH_EXPORT BluetoothGattCharacteristicClient |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 // Called when the GATT characteristic with object path |object_path| has a | 74 // Called when the GATT characteristic with object path |object_path| has a |
73 // change in the value of the property named |property_name|. | 75 // change in the value of the property named |property_name|. |
74 virtual void GattCharacteristicPropertyChanged( | 76 virtual void GattCharacteristicPropertyChanged( |
75 const dbus::ObjectPath& object_path, | 77 const dbus::ObjectPath& object_path, |
76 const std::string& property_name) {} | 78 const std::string& property_name) {} |
77 }; | 79 }; |
78 | 80 |
79 // Callbacks used to report the result of asynchronous methods. | 81 // Callbacks used to report the result of asynchronous methods. |
80 typedef base::Callback<void(const std::string& error_name, | 82 typedef base::Callback<void(const std::string& error_name, |
81 const std::string& error_message)> ErrorCallback; | 83 const std::string& error_message)> ErrorCallback; |
82 typedef base::Callback<void(const std::vector<uint8>& value)> ValueCallback; | 84 typedef base::Callback<void(const std::vector<uint8_t>& value)> ValueCallback; |
83 | 85 |
84 ~BluetoothGattCharacteristicClient() override; | 86 ~BluetoothGattCharacteristicClient() override; |
85 | 87 |
86 // Adds and removes observers for events on all remote GATT characteristics. | 88 // Adds and removes observers for events on all remote GATT characteristics. |
87 // Check the |object_path| parameter of observer methods to determine which | 89 // Check the |object_path| parameter of observer methods to determine which |
88 // GATT characteristic is issuing the event. | 90 // GATT characteristic is issuing the event. |
89 virtual void AddObserver(Observer* observer) = 0; | 91 virtual void AddObserver(Observer* observer) = 0; |
90 virtual void RemoveObserver(Observer* observer) = 0; | 92 virtual void RemoveObserver(Observer* observer) = 0; |
91 | 93 |
92 // Returns the list of GATT characteristic object paths known to the system. | 94 // Returns the list of GATT characteristic object paths known to the system. |
93 virtual std::vector<dbus::ObjectPath> GetCharacteristics() = 0; | 95 virtual std::vector<dbus::ObjectPath> GetCharacteristics() = 0; |
94 | 96 |
95 // Obtain the properties for the GATT characteristic with object path | 97 // Obtain the properties for the GATT characteristic with object path |
96 // |object_path|. Values should be copied if needed. | 98 // |object_path|. Values should be copied if needed. |
97 virtual Properties* GetProperties(const dbus::ObjectPath& object_path) = 0; | 99 virtual Properties* GetProperties(const dbus::ObjectPath& object_path) = 0; |
98 | 100 |
99 // Issues a request to read the value of GATT characteristic with object path | 101 // Issues a request to read the value of GATT characteristic with object path |
100 // |object_path| and returns the value in |callback| on success. On error, | 102 // |object_path| and returns the value in |callback| on success. On error, |
101 // invokes |error_callback|. | 103 // invokes |error_callback|. |
102 virtual void ReadValue(const dbus::ObjectPath& object_path, | 104 virtual void ReadValue(const dbus::ObjectPath& object_path, |
103 const ValueCallback& callback, | 105 const ValueCallback& callback, |
104 const ErrorCallback& error_callback) = 0; | 106 const ErrorCallback& error_callback) = 0; |
105 | 107 |
106 // Issues a request to write the value of GATT characteristic with object path | 108 // Issues a request to write the value of GATT characteristic with object path |
107 // |object_path| with value |value|. Invokes |callback| on success and | 109 // |object_path| with value |value|. Invokes |callback| on success and |
108 // |error_callback| on failure. | 110 // |error_callback| on failure. |
109 virtual void WriteValue(const dbus::ObjectPath& object_path, | 111 virtual void WriteValue(const dbus::ObjectPath& object_path, |
110 const std::vector<uint8>& value, | 112 const std::vector<uint8_t>& value, |
111 const base::Closure& callback, | 113 const base::Closure& callback, |
112 const ErrorCallback& error_callback) = 0; | 114 const ErrorCallback& error_callback) = 0; |
113 | 115 |
114 // Starts a notification session from this characteristic with object path | 116 // Starts a notification session from this characteristic with object path |
115 // |object_path| if it supports value notifications or indications. Invokes | 117 // |object_path| if it supports value notifications or indications. Invokes |
116 // |callback| on success and |error_callback| on failure. | 118 // |callback| on success and |error_callback| on failure. |
117 virtual void StartNotify(const dbus::ObjectPath& object_path, | 119 virtual void StartNotify(const dbus::ObjectPath& object_path, |
118 const base::Closure& callback, | 120 const base::Closure& callback, |
119 const ErrorCallback& error_callback) = 0; | 121 const ErrorCallback& error_callback) = 0; |
120 | 122 |
(...skipping 14 matching lines...) Expand all Loading... |
135 protected: | 137 protected: |
136 BluetoothGattCharacteristicClient(); | 138 BluetoothGattCharacteristicClient(); |
137 | 139 |
138 private: | 140 private: |
139 DISALLOW_COPY_AND_ASSIGN(BluetoothGattCharacteristicClient); | 141 DISALLOW_COPY_AND_ASSIGN(BluetoothGattCharacteristicClient); |
140 }; | 142 }; |
141 | 143 |
142 } // namespace bluez | 144 } // namespace bluez |
143 | 145 |
144 #endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ | 146 #endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_CHARACTERISTIC_CLIENT_H_ |
OLD | NEW |