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

Unified Diff: device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm

Issue 2728623004: Fix getting notified twice after subscribe to notifications and call readValue (Closed)
Patch Set: updated test code Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm
diff --git a/device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm b/device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm
index ae72118130f9cf810262344aa18969c4421c809d..2e2da4e618c0214d4907811847147a72b587390d 100644
--- a/device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm
+++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_mac.mm
@@ -257,10 +257,12 @@ void BluetoothRemoteGattCharacteristicMac::DidUpdateValue(NSError* error) {
callbacks.second.Run(error_code);
return;
}
- UpdateValueAndNotify();
+ UpdateValue();
callbacks.first.Run(value_);
} else if (IsNotifying()) {
- UpdateValueAndNotify();
+ UpdateValue();
+ gatt_service_->GetMacAdapter()->NotifyGattCharacteristicValueChanged(
+ this, value_);
} else {
// In case of buggy device, nothing should be done if receiving extra
// read confirmation.
@@ -269,12 +271,10 @@ void BluetoothRemoteGattCharacteristicMac::DidUpdateValue(NSError* error) {
}
}
-void BluetoothRemoteGattCharacteristicMac::UpdateValueAndNotify() {
+void BluetoothRemoteGattCharacteristicMac::UpdateValue() {
NSData* nsdata_value = cb_characteristic_.get().value;
const uint8_t* buffer = static_cast<const uint8_t*>(nsdata_value.bytes);
value_.assign(buffer, buffer + nsdata_value.length);
- gatt_service_->GetMacAdapter()->NotifyGattCharacteristicValueChanged(this,
- value_);
}
void BluetoothRemoteGattCharacteristicMac::DidWriteValue(NSError* error) {

Powered by Google App Engine
This is Rietveld 408576698