| OLD | NEW |
| 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_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <queue> | 10 #include <queue> |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 // the characteristic's new value. | 112 // the characteristic's new value. |
| 113 // | 113 // |
| 114 // To stop the flow of notifications, simply call the Stop method on the | 114 // To stop the flow of notifications, simply call the Stop method on the |
| 115 // BluetoothGattNotifySession object that you received in |callback|. | 115 // BluetoothGattNotifySession object that you received in |callback|. |
| 116 virtual void StartNotifySession(const NotifySessionCallback& callback, | 116 virtual void StartNotifySession(const NotifySessionCallback& callback, |
| 117 const ErrorCallback& error_callback); | 117 const ErrorCallback& error_callback); |
| 118 | 118 |
| 119 // Sends a read request to a remote characteristic to read its value. | 119 // Sends a read request to a remote characteristic to read its value. |
| 120 // |callback| is called to return the read value on success and | 120 // |callback| is called to return the read value on success and |
| 121 // |error_callback| is called for failures. | 121 // |error_callback| is called for failures. |
| 122 virtual void ReadRemoteCharacteristic( | 122 // If there are any other GATT operations in progress this will fail |
| 123 // with BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS. This currently |
| 124 // only happens on Android. |
| 125 // TODO(crbug.com/657921): Return in progress error on all platforms. |
| 126 virtual void ReadRemoteCharacteristic(const ValueCallback& callback, |
| 127 const ErrorCallback& error_callback); |
| 128 // TODO(crbug.com/657921): Make pure virtual once all platform implement it. |
| 129 virtual void ReadRemoteCharacteristicImpl( |
| 123 const ValueCallback& callback, | 130 const ValueCallback& callback, |
| 124 const ErrorCallback& error_callback) = 0; | 131 const ErrorCallback& error_callback){}; |
| 125 | 132 |
| 126 // Sends a write request to a remote characteristic with the value |value|. | 133 // Sends a write request to a remote characteristic with the value |value|. |
| 127 // |callback| is called to signal success and |error_callback| for failures. | 134 // |callback| is called to signal success and |error_callback| for failures. |
| 128 // This method only applies to remote characteristics and will fail for those | 135 // This method only applies to remote characteristics and will fail for those |
| 129 // that are locally hosted. | 136 // that are locally hosted. |
| 130 virtual void WriteRemoteCharacteristic( | 137 // If there are any other GATT operations in progress this will fail |
| 138 // with BluetoothRemoteGattService::GATT_ERROR_IN_PROGRESS. This currently |
| 139 // only happens on Android. |
| 140 // TODO(crbug.com/657921): Return in progress error on all platforms. |
| 141 virtual void WriteRemoteCharacteristic(const std::vector<uint8_t>& value, |
| 142 const base::Closure& callback, |
| 143 const ErrorCallback& error_callback); |
| 144 // TODO(crbug.com/657921): Make pure virtual once all platform implement it. |
| 145 virtual void WriteRemoteCharacteristicImpl( |
| 131 const std::vector<uint8_t>& value, | 146 const std::vector<uint8_t>& value, |
| 132 const base::Closure& callback, | 147 const base::Closure& callback, |
| 133 const ErrorCallback& error_callback) = 0; | 148 const ErrorCallback& error_callback){}; |
| 134 | 149 |
| 135 protected: | 150 protected: |
| 136 BluetoothRemoteGattCharacteristic(); | 151 BluetoothRemoteGattCharacteristic(); |
| 137 ~BluetoothRemoteGattCharacteristic() override; | 152 ~BluetoothRemoteGattCharacteristic() override; |
| 138 | 153 |
| 154 bool HasPendingGattOperation(); |
| 155 void SetPendingGattOperation(bool pending); |
| 156 |
| 139 // Writes to the Client Characteristic Configuration descriptor to enable | 157 // Writes to the Client Characteristic Configuration descriptor to enable |
| 140 // notifications/indications. This method is meant to be called from | 158 // notifications/indications. This method is meant to be called from |
| 141 // StartNotifySession and should contain only the code necessary to start | 159 // StartNotifySession and should contain only the code necessary to start |
| 142 // listening to characteristic notifications on a particular platform. | 160 // listening to characteristic notifications on a particular platform. |
| 143 virtual void SubscribeToNotifications( | 161 virtual void SubscribeToNotifications( |
| 144 BluetoothRemoteGattDescriptor* ccc_descriptor, | 162 BluetoothRemoteGattDescriptor* ccc_descriptor, |
| 145 const base::Closure& callback, | 163 const base::Closure& callback, |
| 146 const ErrorCallback& error_callback) = 0; | 164 const ErrorCallback& error_callback) = 0; |
| 147 | 165 |
| 148 // Writes to the Client Characteristic Configuration descriptor to disable | 166 // Writes to the Client Characteristic Configuration descriptor to disable |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 std::set<BluetoothGattNotifySession*> notify_sessions_; | 248 std::set<BluetoothGattNotifySession*> notify_sessions_; |
| 231 | 249 |
| 232 base::WeakPtrFactory<BluetoothRemoteGattCharacteristic> weak_ptr_factory_; | 250 base::WeakPtrFactory<BluetoothRemoteGattCharacteristic> weak_ptr_factory_; |
| 233 | 251 |
| 234 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristic); | 252 DISALLOW_COPY_AND_ASSIGN(BluetoothRemoteGattCharacteristic); |
| 235 }; | 253 }; |
| 236 | 254 |
| 237 } // namespace device | 255 } // namespace device |
| 238 | 256 |
| 239 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_H_ | 257 #endif // DEVICE_BLUETOOTH_BLUETOOTH_REMOTE_GATT_CHARACTERISTIC_H_ |
| OLD | NEW |