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 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h" | 5 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "chromeos/dbus/dbus_thread_manager.h" | 9 #include "chromeos/dbus/dbus_thread_manager.h" |
10 #include "device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.h" | 10 #include "device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.h" |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 descriptors_.erase(iter); | 261 descriptors_.erase(iter); |
262 | 262 |
263 service_->NotifyDescriptorAddedOrRemoved(this, descriptor, false /* added */); | 263 service_->NotifyDescriptorAddedOrRemoved(this, descriptor, false /* added */); |
264 delete descriptor; | 264 delete descriptor; |
265 | 265 |
266 DCHECK(service_); | 266 DCHECK(service_); |
267 | 267 |
268 service_->NotifyServiceChanged(); | 268 service_->NotifyServiceChanged(); |
269 } | 269 } |
270 | 270 |
271 void BluetoothRemoteGattCharacteristicChromeOS::GattDescriptorPropertyChanged( | |
272 const dbus::ObjectPath& object_path, | |
273 const std::string& property_name) { | |
274 DescriptorMap::const_iterator iter = descriptors_.find(object_path); | |
275 if (iter == descriptors_.end()) | |
276 return; | |
277 | |
278 // Ignore all property changes except for "Value". | |
279 BluetoothGattDescriptorClient::Properties* properties = | |
280 DBusThreadManager::Get()->GetBluetoothGattDescriptorClient()-> | |
281 GetProperties(object_path); | |
282 DCHECK(properties); | |
283 if (property_name != properties->value.name()) | |
284 return; | |
285 | |
286 VLOG(1) << "GATT descriptor property changed: " << object_path.value() | |
287 << ", property: " << property_name; | |
288 | |
289 DCHECK(service_); | |
290 | |
291 service_->NotifyDescriptorValueChanged( | |
292 this, iter->second, properties->value.value()); | |
293 } | |
294 | |
295 void BluetoothRemoteGattCharacteristicChromeOS::OnValueSuccess( | 271 void BluetoothRemoteGattCharacteristicChromeOS::OnValueSuccess( |
296 const ValueCallback& callback, | 272 const ValueCallback& callback, |
297 const std::vector<uint8>& value) { | 273 const std::vector<uint8>& value) { |
298 VLOG(1) << "Characteristic value read: " << value; | 274 VLOG(1) << "Characteristic value read: " << value; |
299 cached_value_ = value; | 275 cached_value_ = value; |
300 | 276 |
301 DCHECK(service_); | 277 DCHECK(service_); |
302 service_->NotifyCharacteristicValueChanged(this, cached_value_); | 278 service_->NotifyCharacteristicValueChanged(this, cached_value_); |
303 | 279 |
304 callback.Run(value); | 280 callback.Run(value); |
305 } | 281 } |
306 | 282 |
307 void BluetoothRemoteGattCharacteristicChromeOS::OnError( | 283 void BluetoothRemoteGattCharacteristicChromeOS::OnError( |
308 const ErrorCallback& error_callback, | 284 const ErrorCallback& error_callback, |
309 const std::string& error_name, | 285 const std::string& error_name, |
310 const std::string& error_message) { | 286 const std::string& error_message) { |
311 VLOG(1) << "Operation failed: " << error_name << ", message: " | 287 VLOG(1) << "Operation failed: " << error_name << ", message: " |
312 << error_message; | 288 << error_message; |
313 error_callback.Run(); | 289 error_callback.Run(); |
314 } | 290 } |
315 | 291 |
316 } // namespace chromeos | 292 } // namespace chromeos |
OLD | NEW |