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

Unified Diff: device/bluetooth/bluetooth_remote_gatt_characteristic_bluez.cc

Issue 1872943002: Add support for local services/characteristics/descriptors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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_bluez.cc
diff --git a/device/bluetooth/bluetooth_remote_gatt_characteristic_bluez.cc b/device/bluetooth/bluetooth_remote_gatt_characteristic_bluez.cc
index d57ef9da2ba046acb0669f448ddc36ce76f8da98..969455f447efb637cf65fb17ba44724cb880f4d6 100644
--- a/device/bluetooth/bluetooth_remote_gatt_characteristic_bluez.cc
+++ b/device/bluetooth/bluetooth_remote_gatt_characteristic_bluez.cc
@@ -12,9 +12,8 @@
#include "base/strings/stringprintf.h"
#include "device/bluetooth/bluetooth_adapter_bluez.h"
#include "device/bluetooth/bluetooth_device.h"
+#include "device/bluetooth/bluetooth_gatt_descriptor_bluez.h"
#include "device/bluetooth/bluetooth_gatt_notify_session_bluez.h"
-#include "device/bluetooth/bluetooth_remote_gatt_characteristic_bluez.h"
-#include "device/bluetooth/bluetooth_remote_gatt_descriptor_bluez.h"
#include "device/bluetooth/bluetooth_remote_gatt_service_bluez.h"
#include "device/bluetooth/dbus/bluez_dbus_manager.h"
#include "third_party/cros_system_api/dbus/service_constants.h"
@@ -38,8 +37,7 @@ std::ostream& operator<<(std::ostream& out, const std::vector<uint8_t> bytes) {
BluetoothRemoteGattCharacteristicBlueZ::BluetoothRemoteGattCharacteristicBlueZ(
BluetoothRemoteGattServiceBlueZ* service,
const dbus::ObjectPath& object_path)
- : object_path_(object_path),
- service_(service),
+ : BluetoothGattCharacteristicBlueZ(service, object_path),
num_notify_sessions_(0),
notify_call_pending_(false),
weak_ptr_factory_(this) {
@@ -79,10 +77,6 @@ BluetoothRemoteGattCharacteristicBlueZ::
}
}
-std::string BluetoothRemoteGattCharacteristicBlueZ::GetIdentifier() const {
- return object_path_.value();
-}
-
device::BluetoothUUID BluetoothRemoteGattCharacteristicBlueZ::GetUUID() const {
bluez::BluetoothGattCharacteristicClient::Properties* properties =
bluez::BluezDBusManager::Get()
@@ -108,11 +102,6 @@ const std::vector<uint8_t>& BluetoothRemoteGattCharacteristicBlueZ::GetValue()
return properties->value.value();
}
-device::BluetoothGattService*
-BluetoothRemoteGattCharacteristicBlueZ::GetService() const {
- return service_;
-}
-
device::BluetoothGattCharacteristic::Properties
BluetoothRemoteGattCharacteristicBlueZ::GetProperties() const {
bluez::BluetoothGattCharacteristicClient::Properties* properties =
@@ -150,13 +139,6 @@ BluetoothRemoteGattCharacteristicBlueZ::GetProperties() const {
return props;
}
-device::BluetoothGattCharacteristic::Permissions
-BluetoothRemoteGattCharacteristicBlueZ::GetPermissions() const {
- // TODO(armansito): Once BlueZ defines the permissions, return the correct
- // values here.
- return PERMISSION_NONE;
-}
-
bool BluetoothRemoteGattCharacteristicBlueZ::IsNotifying() const {
bluez::BluetoothGattCharacteristicClient::Properties* properties =
bluez::BluezDBusManager::Get()
@@ -167,25 +149,6 @@ bool BluetoothRemoteGattCharacteristicBlueZ::IsNotifying() const {
return properties->notifying.value();
}
-std::vector<device::BluetoothGattDescriptor*>
-BluetoothRemoteGattCharacteristicBlueZ::GetDescriptors() const {
- std::vector<device::BluetoothGattDescriptor*> descriptors;
- for (DescriptorMap::const_iterator iter = descriptors_.begin();
- iter != descriptors_.end(); ++iter)
- descriptors.push_back(iter->second);
- return descriptors;
-}
-
-device::BluetoothGattDescriptor*
-BluetoothRemoteGattCharacteristicBlueZ::GetDescriptor(
- const std::string& identifier) const {
- DescriptorMap::const_iterator iter =
- descriptors_.find(dbus::ObjectPath(identifier));
- if (iter == descriptors_.end())
- return NULL;
- return iter->second;
-}
-
bool BluetoothRemoteGattCharacteristicBlueZ::AddDescriptor(
device::BluetoothGattDescriptor* descriptor) {
VLOG(1) << "Descriptors cannot be added to a remote GATT characteristic.";
@@ -198,35 +161,6 @@ bool BluetoothRemoteGattCharacteristicBlueZ::UpdateValue(
return false;
}
-void BluetoothRemoteGattCharacteristicBlueZ::ReadRemoteCharacteristic(
- const ValueCallback& callback,
- const ErrorCallback& error_callback) {
- VLOG(1) << "Sending GATT characteristic read request to characteristic: "
- << GetIdentifier() << ", UUID: " << GetUUID().canonical_value()
- << ".";
-
- bluez::BluezDBusManager::Get()
- ->GetBluetoothGattCharacteristicClient()
- ->ReadValue(object_path_, callback,
- base::Bind(&BluetoothRemoteGattCharacteristicBlueZ::OnError,
- weak_ptr_factory_.GetWeakPtr(), error_callback));
-}
-
-void BluetoothRemoteGattCharacteristicBlueZ::WriteRemoteCharacteristic(
- const std::vector<uint8_t>& new_value,
- const base::Closure& callback,
- const ErrorCallback& error_callback) {
- VLOG(1) << "Sending GATT characteristic write request to characteristic: "
- << GetIdentifier() << ", UUID: " << GetUUID().canonical_value()
- << ", with value: " << new_value << ".";
-
- bluez::BluezDBusManager::Get()
- ->GetBluetoothGattCharacteristicClient()
- ->WriteValue(object_path_, new_value, callback,
- base::Bind(&BluetoothRemoteGattCharacteristicBlueZ::OnError,
- weak_ptr_factory_.GetWeakPtr(), error_callback));
-}
-
void BluetoothRemoteGattCharacteristicBlueZ::StartNotifySession(
const NotifySessionCallback& callback,
const ErrorCallback& error_callback) {
@@ -279,6 +213,35 @@ void BluetoothRemoteGattCharacteristicBlueZ::StartNotifySession(
weak_ptr_factory_.GetWeakPtr(), error_callback));
}
+void BluetoothRemoteGattCharacteristicBlueZ::ReadRemoteCharacteristic(
+ const ValueCallback& callback,
+ const ErrorCallback& error_callback) {
+ VLOG(1) << "Sending GATT characteristic read request to characteristic: "
+ << GetIdentifier() << ", UUID: " << GetUUID().canonical_value()
+ << ".";
+
+ bluez::BluezDBusManager::Get()
+ ->GetBluetoothGattCharacteristicClient()
+ ->ReadValue(object_path_, callback,
+ base::Bind(&BluetoothRemoteGattCharacteristicBlueZ::OnError,
+ weak_ptr_factory_.GetWeakPtr(), error_callback));
+}
+
+void BluetoothRemoteGattCharacteristicBlueZ::WriteRemoteCharacteristic(
+ const std::vector<uint8_t>& new_value,
+ const base::Closure& callback,
+ const ErrorCallback& error_callback) {
+ VLOG(1) << "Sending GATT characteristic write request to characteristic: "
+ << GetIdentifier() << ", UUID: " << GetUUID().canonical_value()
+ << ", with value: " << new_value << ".";
+
+ bluez::BluezDBusManager::Get()
+ ->GetBluetoothGattCharacteristicClient()
+ ->WriteValue(object_path_, new_value, callback,
+ base::Bind(&BluetoothRemoteGattCharacteristicBlueZ::OnError,
+ weak_ptr_factory_.GetWeakPtr(), error_callback));
+}
+
void BluetoothRemoteGattCharacteristicBlueZ::RemoveNotifySession(
const base::Closure& callback) {
VLOG(1) << __func__;
@@ -337,8 +300,8 @@ void BluetoothRemoteGattCharacteristicBlueZ::GattDescriptorAdded(
VLOG(1) << "Adding new remote GATT descriptor for GATT characteristic: "
<< GetIdentifier() << ", UUID: " << GetUUID().canonical_value();
- BluetoothRemoteGattDescriptorBlueZ* descriptor =
- new BluetoothRemoteGattDescriptorBlueZ(this, object_path);
+ BluetoothGattDescriptorBlueZ* descriptor =
+ new BluetoothGattDescriptorBlueZ(this, object_path, false /* is_local */);
descriptors_[object_path] = descriptor;
DCHECK(descriptor->GetIdentifier() == object_path.value());
DCHECK(descriptor->GetUUID().IsValid());
@@ -358,7 +321,7 @@ void BluetoothRemoteGattCharacteristicBlueZ::GattDescriptorRemoved(
VLOG(1) << "Removing remote GATT descriptor from characteristic: "
<< GetIdentifier() << ", UUID: " << GetUUID().canonical_value();
- BluetoothRemoteGattDescriptorBlueZ* descriptor = iter->second;
+ BluetoothGattDescriptorBlueZ* descriptor = iter->second;
DCHECK(descriptor->object_path() == object_path);
descriptors_.erase(iter);
@@ -392,16 +355,6 @@ void BluetoothRemoteGattCharacteristicBlueZ::GattDescriptorPropertyChanged(
properties->value.value());
}
-void BluetoothRemoteGattCharacteristicBlueZ::OnError(
- const ErrorCallback& error_callback,
- const std::string& error_name,
- const std::string& error_message) {
- VLOG(1) << "Operation failed: " << error_name
- << ", message: " << error_message;
- error_callback.Run(
- BluetoothRemoteGattServiceBlueZ::DBusErrorToServiceError(error_name));
-}
-
void BluetoothRemoteGattCharacteristicBlueZ::OnStartNotifySuccess(
const NotifySessionCallback& callback) {
VLOG(1) << "Started notifications from characteristic: "
@@ -474,4 +427,14 @@ void BluetoothRemoteGattCharacteristicBlueZ::ProcessStartNotifyQueue() {
}
}
+void BluetoothRemoteGattCharacteristicBlueZ::OnError(
+ const ErrorCallback& error_callback,
+ const std::string& error_name,
+ const std::string& error_message) {
+ VLOG(1) << "Operation failed: " << error_name
+ << ", message: " << error_message;
+ error_callback.Run(
+ BluetoothGattServiceBlueZ::DBusErrorToServiceError(error_name));
+}
+
} // namespace bluez

Powered by Google App Engine
This is Rietveld 408576698