diff options
author | armansito@chromium.org <armansito@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-08 05:18:28 +0000 |
---|---|---|
committer | armansito@chromium.org <armansito@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-08 05:18:28 +0000 |
commit | e65bc222634ed32194386ba1c0785cc93499309d (patch) | |
tree | ebba25c995609f5a1b0ef8ec62f2cefd2df433e1 /chromeos/dbus | |
parent | 05e5d16199f7c4c91e4024b6b7c2f2d9f8ace930 (diff) | |
download | chromium_src-e65bc222634ed32194386ba1c0785cc93499309d.zip chromium_src-e65bc222634ed32194386ba1c0785cc93499309d.tar.gz chromium_src-e65bc222634ed32194386ba1c0785cc93499309d.tar.bz2 |
device/bluetooth: Add chromeos::BluetoothRemoteGattServiceChromeOS.
Added the chromeos::BluetoothRemoteGattServiceChromeOS class which implements
a remote instance of device::BluetoothGattService for the Chrome OS
platform. This CL also introduces some minor changes to the GATT API,
namely removing the characteristic and descriptor Observer interfaces.
Addition, removal, and value changes of remote characteristics will instead
be tracked via BluetoothGattService::Observer.
BUG=360266,340529
TEST=device_unittests
Review URL: https://codereview.chromium.org/224953003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262327 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/dbus')
-rw-r--r-- | chromeos/dbus/bluetooth_gatt_service_client.cc | 11 | ||||
-rw-r--r-- | chromeos/dbus/bluetooth_gatt_service_client.h | 6 | ||||
-rw-r--r-- | chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc | 14 | ||||
-rw-r--r-- | chromeos/dbus/fake_bluetooth_gatt_service_client.cc | 11 |
4 files changed, 31 insertions, 11 deletions
diff --git a/chromeos/dbus/bluetooth_gatt_service_client.cc b/chromeos/dbus/bluetooth_gatt_service_client.cc index cdbcef1..1888e51 100644 --- a/chromeos/dbus/bluetooth_gatt_service_client.cc +++ b/chromeos/dbus/bluetooth_gatt_service_client.cc @@ -13,6 +13,15 @@ namespace chromeos { +namespace { + +// TODO(armansito): Add these to service_constants.h when they are defined +// in the BlueZ doc. +const char kDeviceProperty[] = "Device"; +const char kPrimaryProperty[] = "Primary"; + +} // namespace + BluetoothGattServiceClient::Properties::Properties( dbus::ObjectProxy* object_proxy, const std::string& interface_name, @@ -20,6 +29,8 @@ BluetoothGattServiceClient::Properties::Properties( : dbus::PropertySet(object_proxy, interface_name, callback) { RegisterProperty(bluetooth_gatt_service::kUUIDProperty, &uuid); RegisterProperty(bluetooth_gatt_service::kIncludesProperty, &includes); + RegisterProperty(kDeviceProperty, &device); + RegisterProperty(kPrimaryProperty, &primary); } BluetoothGattServiceClient::Properties::~Properties() { diff --git a/chromeos/dbus/bluetooth_gatt_service_client.h b/chromeos/dbus/bluetooth_gatt_service_client.h index 94eb3ce..d3ed19d 100644 --- a/chromeos/dbus/bluetooth_gatt_service_client.h +++ b/chromeos/dbus/bluetooth_gatt_service_client.h @@ -24,6 +24,12 @@ class CHROMEOS_EXPORT BluetoothGattServiceClient : public DBusClient { // The 128-bit service UUID. [read-only] dbus::Property<std::string> uuid; + // Object path of the Bluetooth device that the GATT service belongs to. + dbus::Property<dbus::ObjectPath> device; + + // Whether or not this service is a primary service. + dbus::Property<bool> primary; + // Array of object paths representing the included services of this service. // [read-only] dbus::Property<std::vector<dbus::ObjectPath> > includes; diff --git a/chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc b/chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc index 85408b8..c25e71c 100644 --- a/chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc +++ b/chromeos/dbus/fake_bluetooth_gatt_characteristic_client.cc @@ -209,21 +209,21 @@ void FakeBluetoothGattCharacteristicClient::ExposeHeartRateCharacteristics( void FakeBluetoothGattCharacteristicClient::HideHeartRateCharacteristics() { VLOG(2) << "Hiding fake Heart Rate characteristics."; + + // Notify the observers before deleting the properties structures so that they + // can be accessed from the observer method. + NotifyCharacteristicRemoved(dbus::ObjectPath(heart_rate_measurement_path_)); + NotifyCharacteristicRemoved(dbus::ObjectPath(body_sensor_location_path_)); + NotifyCharacteristicRemoved(dbus::ObjectPath(heart_rate_control_point_path_)); + heart_rate_measurement_properties_.reset(); body_sensor_location_properties_.reset(); heart_rate_control_point_properties_.reset(); - std::string hrm_path = heart_rate_measurement_path_; heart_rate_measurement_path_.clear(); - std::string bsl_path = body_sensor_location_path_; body_sensor_location_path_.clear(); - std::string hrcp_path = heart_rate_control_point_path_; heart_rate_control_point_path_.clear(); heart_rate_visible_ = false; - - NotifyCharacteristicRemoved(dbus::ObjectPath(hrm_path)); - NotifyCharacteristicRemoved(dbus::ObjectPath(bsl_path)); - NotifyCharacteristicRemoved(dbus::ObjectPath(hrcp_path)); } void FakeBluetoothGattCharacteristicClient::OnPropertyChanged( diff --git a/chromeos/dbus/fake_bluetooth_gatt_service_client.cc b/chromeos/dbus/fake_bluetooth_gatt_service_client.cc index d579a26..506ee05 100644 --- a/chromeos/dbus/fake_bluetooth_gatt_service_client.cc +++ b/chromeos/dbus/fake_bluetooth_gatt_service_client.cc @@ -94,7 +94,9 @@ void FakeBluetoothGattServiceClient::ExposeHeartRateService( &FakeBluetoothGattServiceClient::OnPropertyChanged, base::Unretained(this), dbus::ObjectPath(heart_rate_service_path_)))); - heart_rate_service_properties_->uuid.ReplaceValue(heart_rate_service_path_); + heart_rate_service_properties_->uuid.ReplaceValue(kHeartRateServiceUUID); + heart_rate_service_properties_->device.ReplaceValue(device_path); + heart_rate_service_properties_->primary.ReplaceValue(true); NotifyServiceAdded(dbus::ObjectPath(heart_rate_service_path_)); @@ -117,11 +119,12 @@ void FakeBluetoothGattServiceClient::HideHeartRateService() { DBusThreadManager::Get()->GetBluetoothGattCharacteristicClient()); char_client->HideHeartRateCharacteristics(); + // Notify observers before deleting the properties structure so that it + // can be accessed from the observer method. + NotifyServiceRemoved(dbus::ObjectPath(heart_rate_service_path_)); + heart_rate_service_properties_.reset(); - std::string hrs_path = heart_rate_service_path_; heart_rate_service_path_.clear(); - - NotifyServiceRemoved(dbus::ObjectPath(hrs_path)); } void FakeBluetoothGattServiceClient::OnPropertyChanged( |