| 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_DESCRIPTOR_CLIENT_H_ | 5 #ifndef DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_DESCRIPTOR_CLIENT_H_ |
| 6 #define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_DESCRIPTOR_CLIENT_H_ | 6 #define DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_DESCRIPTOR_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 // BluetoothGattDescriptorClient is used to communicate with remote GATT | 22 // BluetoothGattDescriptorClient is used to communicate with remote GATT |
| 21 // characteristic descriptor objects exposed by the Bluetooth daemon. | 23 // characteristic descriptor objects exposed by the Bluetooth daemon. |
| 22 class DEVICE_BLUETOOTH_EXPORT BluetoothGattDescriptorClient | 24 class DEVICE_BLUETOOTH_EXPORT BluetoothGattDescriptorClient |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 // Called when the GATT descriptor with object path |object_path| has a | 60 // Called when the GATT descriptor with object path |object_path| has a |
| 59 // change in the value of the property named |property_name|. | 61 // change in the value of the property named |property_name|. |
| 60 virtual void GattDescriptorPropertyChanged( | 62 virtual void GattDescriptorPropertyChanged( |
| 61 const dbus::ObjectPath& object_path, | 63 const dbus::ObjectPath& object_path, |
| 62 const std::string& property_name) {} | 64 const std::string& property_name) {} |
| 63 }; | 65 }; |
| 64 | 66 |
| 65 // Callbacks used to report the result of asynchronous methods. | 67 // Callbacks used to report the result of asynchronous methods. |
| 66 typedef base::Callback<void(const std::string& error_name, | 68 typedef base::Callback<void(const std::string& error_name, |
| 67 const std::string& error_message)> ErrorCallback; | 69 const std::string& error_message)> ErrorCallback; |
| 68 typedef base::Callback<void(const std::vector<uint8>& value)> ValueCallback; | 70 typedef base::Callback<void(const std::vector<uint8_t>& value)> ValueCallback; |
| 69 | 71 |
| 70 ~BluetoothGattDescriptorClient() override; | 72 ~BluetoothGattDescriptorClient() override; |
| 71 | 73 |
| 72 // Adds and removes observers for events on all remote GATT descriptors. Check | 74 // Adds and removes observers for events on all remote GATT descriptors. Check |
| 73 // the |object_path| parameter of observer methods to determine which GATT | 75 // the |object_path| parameter of observer methods to determine which GATT |
| 74 // descriptor is issuing the event. | 76 // descriptor is issuing the event. |
| 75 virtual void AddObserver(Observer* observer) = 0; | 77 virtual void AddObserver(Observer* observer) = 0; |
| 76 virtual void RemoveObserver(Observer* observer) = 0; | 78 virtual void RemoveObserver(Observer* observer) = 0; |
| 77 | 79 |
| 78 // Returns the list of GATT descriptor object paths known to the system. | 80 // Returns the list of GATT descriptor object paths known to the system. |
| 79 virtual std::vector<dbus::ObjectPath> GetDescriptors() = 0; | 81 virtual std::vector<dbus::ObjectPath> GetDescriptors() = 0; |
| 80 | 82 |
| 81 // Obtain the properties for the GATT descriptor with object path | 83 // Obtain the properties for the GATT descriptor with object path |
| 82 // |object_path|. Values should be copied if needed. | 84 // |object_path|. Values should be copied if needed. |
| 83 virtual Properties* GetProperties(const dbus::ObjectPath& object_path) = 0; | 85 virtual Properties* GetProperties(const dbus::ObjectPath& object_path) = 0; |
| 84 | 86 |
| 85 // Issues a request to read the value of GATT descriptor with object path | 87 // Issues a request to read the value of GATT descriptor with object path |
| 86 // |object_path| and returns the value in |callback| on success. On error, | 88 // |object_path| and returns the value in |callback| on success. On error, |
| 87 // invokes |error_callback|. | 89 // invokes |error_callback|. |
| 88 virtual void ReadValue(const dbus::ObjectPath& object_path, | 90 virtual void ReadValue(const dbus::ObjectPath& object_path, |
| 89 const ValueCallback& callback, | 91 const ValueCallback& callback, |
| 90 const ErrorCallback& error_callback) = 0; | 92 const ErrorCallback& error_callback) = 0; |
| 91 | 93 |
| 92 // Issues a request to write the value of GATT descriptor with object path | 94 // Issues a request to write the value of GATT descriptor with object path |
| 93 // |object_path| with value |value|. Invokes |callback| on success and | 95 // |object_path| with value |value|. Invokes |callback| on success and |
| 94 // |error_callback| on failure. | 96 // |error_callback| on failure. |
| 95 virtual void WriteValue(const dbus::ObjectPath& object_path, | 97 virtual void WriteValue(const dbus::ObjectPath& object_path, |
| 96 const std::vector<uint8>& value, | 98 const std::vector<uint8_t>& value, |
| 97 const base::Closure& callback, | 99 const base::Closure& callback, |
| 98 const ErrorCallback& error_callback) = 0; | 100 const ErrorCallback& error_callback) = 0; |
| 99 | 101 |
| 100 // Creates the instance. | 102 // Creates the instance. |
| 101 static BluetoothGattDescriptorClient* Create(); | 103 static BluetoothGattDescriptorClient* Create(); |
| 102 | 104 |
| 103 // Constants used to indicate exceptional error conditions. | 105 // Constants used to indicate exceptional error conditions. |
| 104 static const char kNoResponseError[]; | 106 static const char kNoResponseError[]; |
| 105 static const char kUnknownDescriptorError[]; | 107 static const char kUnknownDescriptorError[]; |
| 106 | 108 |
| 107 protected: | 109 protected: |
| 108 BluetoothGattDescriptorClient(); | 110 BluetoothGattDescriptorClient(); |
| 109 | 111 |
| 110 private: | 112 private: |
| 111 DISALLOW_COPY_AND_ASSIGN(BluetoothGattDescriptorClient); | 113 DISALLOW_COPY_AND_ASSIGN(BluetoothGattDescriptorClient); |
| 112 }; | 114 }; |
| 113 | 115 |
| 114 } // namespace bluez | 116 } // namespace bluez |
| 115 | 117 |
| 116 #endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_DESCRIPTOR_CLIENT_H_ | 118 #endif // DEVICE_BLUETOOTH_DBUS_BLUETOOTH_GATT_DESCRIPTOR_CLIENT_H_ |
| OLD | NEW |