diff options
author | armansito@chromium.org <armansito@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-07 03:16:48 +0000 |
---|---|---|
committer | armansito@chromium.org <armansito@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-07 03:16:48 +0000 |
commit | 15966434752a7772bddde6df909fddda1b870635 (patch) | |
tree | 402ca96483c71d26c42c9afbaf2838aff4e2b9a4 /chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc | |
parent | d808fc83724b2a5050a387f41f9041198a4b91b8 (diff) | |
download | chromium_src-15966434752a7772bddde6df909fddda1b870635.zip chromium_src-15966434752a7772bddde6df909fddda1b870635.tar.gz chromium_src-15966434752a7772bddde6df909fddda1b870635.tar.bz2 |
device/bluetooth: Implement GATT characteristic properties on Chrome OS.
This CL implements GATT characteristic properties for
BluetoothRemoteGattCharacteristicChromeOS. Also, a typo in the "Writable
Auxiliaries" property declaration has been fixed.
BUG=362799
TEST=device_unittests, browser_tests
Review URL: https://codereview.chromium.org/307453007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275599 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc')
-rw-r--r-- | chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc b/chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc index dbbdcc3..c822f95 100644 --- a/chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc +++ b/chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc @@ -69,14 +69,28 @@ void FakeBluetoothGattCharacteristicClient::Properties::Set( callback.Run(false); return; } + // Allow writing to only certain characteristics that are defined with the // write permission. - // TODO(armansito): Actually check against the permissions property instead of - // UUID, once that property is fully defined in the API. - if (uuid.value() != kHeartRateControlPointUUID) { + bool write = false; + for (std::vector<std::string>::const_iterator iter = flags.value().begin(); + iter != flags.value().end(); + ++iter) { + if (*iter == bluetooth_gatt_characteristic::kFlagWrite || + *iter == bluetooth_gatt_characteristic::kFlagWriteWithoutResponse || + *iter == + bluetooth_gatt_characteristic::kFlagAuthenticatedSignedWrites || + *iter == bluetooth_gatt_characteristic::kFlagReliableWrite) { + write = true; + break; + } + } + + if (!write) { callback.Run(false); return; } + callback.Run(true); property->ReplaceValueWithSetValue(); } @@ -140,6 +154,8 @@ void FakeBluetoothGattCharacteristicClient::ExposeHeartRateCharacteristics( VLOG(2) << "Exposing fake Heart Rate characteristics."; + std::vector<std::string> flags; + // ==== Heart Rate Measurement Characteristic ==== heart_rate_measurement_path_ = service_path.value() + "/" + kHeartRateMeasurementPathComponent; @@ -150,9 +166,8 @@ void FakeBluetoothGattCharacteristicClient::ExposeHeartRateCharacteristics( heart_rate_measurement_properties_->uuid.ReplaceValue( kHeartRateMeasurementUUID); heart_rate_measurement_properties_->service.ReplaceValue(service_path); - - // TODO(armansito): Fill out the flags field once bindings for the values have - // been added. For now, leave it empty. + flags.push_back(bluetooth_gatt_characteristic::kFlagNotify); + heart_rate_measurement_properties_->flags.ReplaceValue(flags); std::vector<uint8> measurement_value = GetHeartRateMeasurementValue(); heart_rate_measurement_properties_->value.ReplaceValue(measurement_value); @@ -166,9 +181,9 @@ void FakeBluetoothGattCharacteristicClient::ExposeHeartRateCharacteristics( dbus::ObjectPath(body_sensor_location_path_)))); body_sensor_location_properties_->uuid.ReplaceValue(kBodySensorLocationUUID); body_sensor_location_properties_->service.ReplaceValue(service_path); - - // TODO(armansito): Fill out the flags field once bindings for the values have - // been added. For now, leave it empty. + flags.clear(); + flags.push_back(bluetooth_gatt_characteristic::kFlagRead); + body_sensor_location_properties_->flags.ReplaceValue(flags); // The sensor is in the "Other" location. std::vector<uint8> body_sensor_location_value; @@ -186,9 +201,9 @@ void FakeBluetoothGattCharacteristicClient::ExposeHeartRateCharacteristics( heart_rate_control_point_properties_->uuid.ReplaceValue( kHeartRateControlPointUUID); heart_rate_control_point_properties_->service.ReplaceValue(service_path); - - // TODO(armansito): Fill out the flags field once bindings for the values have - // been added. For now, leave it empty. + flags.clear(); + flags.push_back(bluetooth_gatt_characteristic::kFlagWrite); + heart_rate_control_point_properties_->flags.ReplaceValue(flags); // Set the initial value to 0. Whenever this gets set to 1, we will reset the // total calories burned and change the value back to 0. |