Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Side by Side Diff: device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm

Issue 2357993002: Don't send a value changed notification when a characteristic is written (Closed)
Patch Set: Adding unittest Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/bluetooth_remote_gatt_characteristic_mac.h" 5 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_mac.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #include "base/threading/thread_task_runner_handle.h" 10 #include "base/threading/thread_task_runner_handle.h"
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 characteristic_value_read_or_write_in_progress_ = false; 309 characteristic_value_read_or_write_in_progress_ = false;
310 if (error) { 310 if (error) {
311 VLOG(1) << "Bluetooth error while writing for characteristic, domain: " 311 VLOG(1) << "Bluetooth error while writing for characteristic, domain: "
312 << base::SysNSStringToUTF8(error.domain) 312 << base::SysNSStringToUTF8(error.domain)
313 << ", error code: " << error.code; 313 << ", error code: " << error.code;
314 BluetoothGattService::GattErrorCode error_code = 314 BluetoothGattService::GattErrorCode error_code =
315 BluetoothDeviceMac::GetGattErrorCodeFromNSError(error); 315 BluetoothDeviceMac::GetGattErrorCodeFromNSError(error);
316 callbacks.second.Run(error_code); 316 callbacks.second.Run(error_code);
317 return; 317 return;
318 } 318 }
319 NSData* nsdata_value = cb_characteristic_.get().value;
320 const uint8_t* buffer = static_cast<const uint8_t*>(nsdata_value.bytes);
321 std::vector<uint8_t> gatt_value(buffer, buffer + nsdata_value.length);
322 gatt_service_->GetMacAdapter()->NotifyGattCharacteristicValueChanged(this, 319 gatt_service_->GetMacAdapter()->NotifyGattCharacteristicValueChanged(this,
323 value_); 320 value_);
324 callbacks.first.Run(); 321 callbacks.first.Run();
325 } 322 }
326 323
327 void BluetoothRemoteGattCharacteristicMac::DidUpdateNotificationState( 324 void BluetoothRemoteGattCharacteristicMac::DidUpdateNotificationState(
328 NSError* error) { 325 NSError* error) {
329 std::vector<std::pair<NotifySessionCallback, ErrorCallback>> 326 std::vector<std::pair<NotifySessionCallback, ErrorCallback>>
330 reentrant_safe_callbacks; 327 reentrant_safe_callbacks;
331 reentrant_safe_callbacks.swap(start_notify_session_callbacks_); 328 reentrant_safe_callbacks.swap(start_notify_session_callbacks_);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 return (GetProperties() & BluetoothGattCharacteristic::PROPERTY_WRITE) 367 return (GetProperties() & BluetoothGattCharacteristic::PROPERTY_WRITE)
371 ? CBCharacteristicWriteWithResponse 368 ? CBCharacteristicWriteWithResponse
372 : CBCharacteristicWriteWithoutResponse; 369 : CBCharacteristicWriteWithoutResponse;
373 } 370 }
374 371
375 CBCharacteristic* BluetoothRemoteGattCharacteristicMac::GetCBCharacteristic() 372 CBCharacteristic* BluetoothRemoteGattCharacteristicMac::GetCBCharacteristic()
376 const { 373 const {
377 return cb_characteristic_.get(); 374 return cb_characteristic_.get();
378 } 375 }
379 } // namespace device. 376 } // namespace device.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698