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

Unified Diff: chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.cc

Issue 1951863004: API changes to support sending characteristic properties. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluez_changes_for_properties
Patch Set: Created 4 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.cc
diff --git a/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.cc b/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.cc
index 6ce3304f1a51eb510365d2b9cbc4580cdce0f9da..d239c36a1d2afa92595b4947805cd8575b615c7d 100644
--- a/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.cc
+++ b/chrome/browser/extensions/api/bluetooth_low_energy/bluetooth_low_energy_api.cc
@@ -171,6 +171,57 @@ std::unique_ptr<device::BluetoothAdvertisement::ServiceData> CreateServiceData(
return created_data;
}
+bool HasProperty(
+ const std::vector<apibtle::CharacteristicProperty>& api_properties,
+ apibtle::CharacteristicProperty property) {
+ if (find(api_properties.begin(), api_properties.end(), property) !=
+ api_properties.end())
+ return true;
+ return false;
+}
+
+device::BluetoothGattCharacteristic::Properties GetBluetoothProperties(
+ const std::vector<apibtle::CharacteristicProperty>& api_properties) {
+ device::BluetoothGattCharacteristic::Properties properties =
+ device::BluetoothGattCharacteristic::PROPERTY_NONE;
+
scheib 2016/05/07 01:15:06 Add a compile time check that all enum values are
rkc 2016/05/07 20:39:23 Done.
+ if (HasProperty(api_properties, apibtle::CHARACTERISTIC_PROPERTY_BROADCAST))
+ properties |= device::BluetoothGattCharacteristic::PROPERTY_BROADCAST;
+
+ if (HasProperty(api_properties, apibtle::CHARACTERISTIC_PROPERTY_READ))
+ properties |= device::BluetoothGattCharacteristic::PROPERTY_READ;
+ if (HasProperty(api_properties,
+ apibtle::CHARACTERISTIC_PROPERTY_WRITEWITHOUTRESPONSE))
+ properties |=
+ device::BluetoothGattCharacteristic::PROPERTY_WRITE_WITHOUT_RESPONSE;
+ if (HasProperty(api_properties, apibtle::CHARACTERISTIC_PROPERTY_WRITE))
+ properties |= device::BluetoothGattCharacteristic::PROPERTY_WRITE;
+
+ if (HasProperty(api_properties, apibtle::CHARACTERISTIC_PROPERTY_NOTIFY))
+ properties |= device::BluetoothGattCharacteristic::PROPERTY_NOTIFY;
+
+ if (HasProperty(api_properties, apibtle::CHARACTERISTIC_PROPERTY_INDICATE))
+ properties |= device::BluetoothGattCharacteristic::PROPERTY_INDICATE;
+
+ if (HasProperty(api_properties,
+ apibtle::CHARACTERISTIC_PROPERTY_AUTHENTICATEDSIGNEDWRITES))
+ properties |= device::BluetoothGattCharacteristic::
+ PROPERTY_AUTHENTICATED_SIGNED_WRITES;
+ if (HasProperty(api_properties,
+ apibtle::CHARACTERISTIC_PROPERTY_EXTENDEDPROPERTIES))
+ properties |=
+ device::BluetoothGattCharacteristic::PROPERTY_EXTENDED_PROPERTIES;
+ if (HasProperty(api_properties,
+ apibtle::CHARACTERISTIC_PROPERTY_RELIABLEWRITE))
+ properties |= device::BluetoothGattCharacteristic::PROPERTY_RELIABLE_WRITE;
+ if (HasProperty(api_properties,
+ apibtle::CHARACTERISTIC_PROPERTY_WRITABLEAUXILIARIES))
+ properties |=
+ device::BluetoothGattCharacteristic::PROPERTY_WRITABLE_AUXILIARIES;
+
+ return properties;
+}
+
} // namespace
@@ -1180,7 +1231,7 @@ void BluetoothLowEnergyCreateCharacteristicFunction::DoWork() {
base::WeakPtr<device::BluetoothLocalGattCharacteristic> characteristic =
device::BluetoothLocalGattCharacteristic::Create(
device::BluetoothUUID(params_->characteristic.uuid),
- device::BluetoothGattCharacteristic::Properties(),
+ GetBluetoothProperties(params_->characteristic.properties),
device::BluetoothGattCharacteristic::Permissions(), service);
// Keep a track of this characteristic so we can look it up later if a
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698