Chromium Code Reviews| 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 #include "device/bluetooth/bluez/bluetooth_remote_gatt_characteristic_bluez.h" | 5 #include "device/bluetooth/bluez/bluetooth_remote_gatt_characteristic_bluez.h" |
| 6 | 6 |
| 7 #include <iterator> | 7 #include <iterator> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 38 } | 38 } |
| 39 | 39 |
| 40 } // namespace | 40 } // namespace |
| 41 | 41 |
| 42 BluetoothRemoteGattCharacteristicBlueZ::BluetoothRemoteGattCharacteristicBlueZ( | 42 BluetoothRemoteGattCharacteristicBlueZ::BluetoothRemoteGattCharacteristicBlueZ( |
| 43 BluetoothRemoteGattServiceBlueZ* service, | 43 BluetoothRemoteGattServiceBlueZ* service, |
| 44 const dbus::ObjectPath& object_path) | 44 const dbus::ObjectPath& object_path) |
| 45 : BluetoothGattCharacteristicBlueZ(object_path), | 45 : BluetoothGattCharacteristicBlueZ(object_path), |
| 46 has_notify_session_(false), | 46 has_notify_session_(false), |
| 47 service_(service), | 47 service_(service), |
| 48 characteristic_value_read_in_progress_(false), | |
| 48 weak_ptr_factory_(this) { | 49 weak_ptr_factory_(this) { |
| 49 VLOG(1) << "Creating remote GATT characteristic with identifier: " | 50 VLOG(1) << "Creating remote GATT characteristic with identifier: " |
| 50 << GetIdentifier() << ", UUID: " << GetUUID().canonical_value(); | 51 << GetIdentifier() << ", UUID: " << GetUUID().canonical_value(); |
| 51 bluez::BluezDBusManager::Get() | 52 bluez::BluezDBusManager::Get() |
| 52 ->GetBluetoothGattDescriptorClient() | 53 ->GetBluetoothGattDescriptorClient() |
| 53 ->AddObserver(this); | 54 ->AddObserver(this); |
| 54 | 55 |
| 55 // Add all known GATT characteristic descriptors. | 56 // Add all known GATT characteristic descriptors. |
| 56 const std::vector<dbus::ObjectPath>& gatt_descs = | 57 const std::vector<dbus::ObjectPath>& gatt_descs = |
| 57 bluez::BluezDBusManager::Get() | 58 bluez::BluezDBusManager::Get() |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 return iter->second; | 178 return iter->second; |
| 178 } | 179 } |
| 179 | 180 |
| 180 void BluetoothRemoteGattCharacteristicBlueZ::ReadRemoteCharacteristic( | 181 void BluetoothRemoteGattCharacteristicBlueZ::ReadRemoteCharacteristic( |
| 181 const ValueCallback& callback, | 182 const ValueCallback& callback, |
| 182 const ErrorCallback& error_callback) { | 183 const ErrorCallback& error_callback) { |
| 183 VLOG(1) << "Sending GATT characteristic read request to characteristic: " | 184 VLOG(1) << "Sending GATT characteristic read request to characteristic: " |
| 184 << GetIdentifier() << ", UUID: " << GetUUID().canonical_value() | 185 << GetIdentifier() << ", UUID: " << GetUUID().canonical_value() |
| 185 << "."; | 186 << "."; |
| 186 | 187 |
| 188 characteristic_value_read_in_progress_ = true; | |
|
ortuno
2017/03/03 05:28:37
If the read fails then this never goes back to fal
juncai
2017/03/04 01:33:59
Done.
| |
| 189 | |
| 187 bluez::BluezDBusManager::Get() | 190 bluez::BluezDBusManager::Get() |
| 188 ->GetBluetoothGattCharacteristicClient() | 191 ->GetBluetoothGattCharacteristicClient() |
| 189 ->ReadValue(object_path(), callback, | 192 ->ReadValue(object_path(), callback, |
| 190 base::Bind(&BluetoothRemoteGattCharacteristicBlueZ::OnError, | 193 base::Bind(&BluetoothRemoteGattCharacteristicBlueZ::OnError, |
| 191 weak_ptr_factory_.GetWeakPtr(), error_callback)); | 194 weak_ptr_factory_.GetWeakPtr(), error_callback)); |
| 192 } | 195 } |
| 193 | 196 |
| 194 void BluetoothRemoteGattCharacteristicBlueZ::WriteRemoteCharacteristic( | 197 void BluetoothRemoteGattCharacteristicBlueZ::WriteRemoteCharacteristic( |
| 195 const std::vector<uint8_t>& value, | 198 const std::vector<uint8_t>& value, |
| 196 const base::Closure& callback, | 199 const base::Closure& callback, |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 357 const ErrorCallback& error_callback, | 360 const ErrorCallback& error_callback, |
| 358 const std::string& error_name, | 361 const std::string& error_name, |
| 359 const std::string& error_message) { | 362 const std::string& error_message) { |
| 360 VLOG(1) << "Operation failed: " << error_name | 363 VLOG(1) << "Operation failed: " << error_name |
| 361 << ", message: " << error_message; | 364 << ", message: " << error_message; |
| 362 error_callback.Run( | 365 error_callback.Run( |
| 363 BluetoothGattServiceBlueZ::DBusErrorToServiceError(error_name)); | 366 BluetoothGattServiceBlueZ::DBusErrorToServiceError(error_name)); |
| 364 } | 367 } |
| 365 | 368 |
| 366 } // namespace bluez | 369 } // namespace bluez |
| OLD | NEW |