summaryrefslogtreecommitdiffstats
path: root/chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc
diff options
context:
space:
mode:
authorarmansito <armansito@chromium.org>2015-02-06 12:21:19 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-06 20:22:01 +0000
commit2e5cbe58a08a122c8896ae6542b5822a827a1707 (patch)
tree0826f76e86a2486600d69bcea7077f0c5baaf9b1 /chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc
parent873d9c13d08de9449b659fd5dad1fcf579758a3a (diff)
downloadchromium_src-2e5cbe58a08a122c8896ae6542b5822a827a1707.zip
chromium_src-2e5cbe58a08a122c8896ae6542b5822a827a1707.tar.gz
chromium_src-2e5cbe58a08a122c8896ae6542b5822a827a1707.tar.bz2
chromeos/dbus: Update Bluetooth GATT API clients to upstream definition
This CL ports the GATT API bindings from the D-Bus API in our Chrome OS fork to the API definition in doc/gatt-api.txt in BlueZ upstream. TBR=keybuk@chromium.org BUG=440968 Review URL: https://codereview.chromium.org/788193004 Cr-Commit-Position: refs/heads/master@{#315095}
Diffstat (limited to 'chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc')
-rw-r--r--chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc27
1 files changed, 18 insertions, 9 deletions
diff --git a/chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc b/chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc
index ec04474..1f3a9bf 100644
--- a/chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc
+++ b/chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc
@@ -176,14 +176,16 @@ void FakeBluetoothGattCharacteristicClient::ReadValue(
}
return;
}
+
base::Closure completed_callback;
if (!IsHeartRateVisible()) {
completed_callback =
base::Bind(error_callback, kUnknownCharacteristicError, "");
} else {
- std::vector<uint8> value;
- value.push_back(0x06); // Location is "foot".
- completed_callback = base::Bind(callback, value);
+ std::vector<uint8> value = {0x06}; // Location is "foot".
+ completed_callback = base::Bind(
+ &FakeBluetoothGattCharacteristicClient::DelayedReadValueCallback,
+ weak_ptr_factory_.GetWeakPtr(), object_path, callback, value);
}
if (extra_requests_ > 0) {
@@ -191,6 +193,7 @@ void FakeBluetoothGattCharacteristicClient::ReadValue(
new DelayedCallback(completed_callback, extra_requests_);
return;
}
+
completed_callback.Run();
}
@@ -488,12 +491,7 @@ void FakeBluetoothGattCharacteristicClient::
VLOG(2) << "Updating heart rate value.";
std::vector<uint8> measurement = GetHeartRateMeasurementValue();
-
- FOR_EACH_OBSERVER(
- BluetoothGattCharacteristicClient::Observer,
- observers_,
- GattCharacteristicValueUpdated(
- dbus::ObjectPath(heart_rate_measurement_path_), measurement));
+ heart_rate_measurement_properties_->value.ReplaceValue(measurement);
base::MessageLoop::current()->PostDelayedTask(
FROM_HERE,
@@ -504,6 +502,17 @@ void FakeBluetoothGattCharacteristicClient::
kHeartRateMeasurementNotificationIntervalMs));
}
+void FakeBluetoothGattCharacteristicClient::DelayedReadValueCallback(
+ const dbus::ObjectPath& object_path,
+ const ValueCallback& callback,
+ const std::vector<uint8_t>& value) {
+ Properties* properties = GetProperties(object_path);
+ DCHECK(properties);
+
+ properties->value.ReplaceValue(value);
+ callback.Run(value);
+}
+
std::vector<uint8>
FakeBluetoothGattCharacteristicClient::GetHeartRateMeasurementValue() {
// TODO(armansito): We should make sure to properly pack this struct to ensure