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

Unified Diff: device/bluetooth/bluez/bluetooth_gatt_service_bluez.cc

Issue 1920693002: Complete //device/bt implementation for hosting local GATT attributes. (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/bluez/bluetooth_gatt_service_bluez.cc
diff --git a/device/bluetooth/bluez/bluetooth_gatt_service_bluez.cc b/device/bluetooth/bluez/bluetooth_gatt_service_bluez.cc
index 0e9d90e606921e10ddaa4e442076d49cbf36bf21..1422973c4347379cc8f68055fe479de2797b4c15 100644
--- a/device/bluetooth/bluez/bluetooth_gatt_service_bluez.cc
+++ b/device/bluetooth/bluez/bluetooth_gatt_service_bluez.cc
@@ -4,24 +4,14 @@
#include "device/bluetooth/bluez/bluetooth_gatt_service_bluez.h"
+#include "base/guid.h"
#include "base/logging.h"
+#include "base/strings/string_util.h"
#include "device/bluetooth/bluez/bluetooth_adapter_bluez.h"
+#include "third_party/cros_system_api/dbus/service_constants.h"
namespace bluez {
-namespace {
-
-// TODO(jamuraa) move these to cros_system_api later
-const char kErrorFailed[] = "org.bluez.Error.Failed";
-const char kErrorInProgress[] = "org.bluez.Error.InProgress";
-const char kErrorInvalidValueLength[] = "org.bluez.Error.InvalidValueLength";
-const char kErrorNotAuthorized[] = "org.bluez.Error.NotAuthorized";
-const char kErrorNotPaired[] = "org.bluez.Error.NotPaired";
-const char kErrorNotSupported[] = "org.bluez.Error.NotSupported";
-const char kErrorNotPermitted[] = "org.bluez.Error.NotPermitted";
-
-} // namespace
-
BluetoothGattServiceBlueZ::BluetoothGattServiceBlueZ(
BluetoothAdapterBlueZ* adapter)
: adapter_(adapter) {
@@ -38,19 +28,20 @@ std::string BluetoothGattServiceBlueZ::GetIdentifier() const {
device::BluetoothGattService::GattErrorCode
BluetoothGattServiceBlueZ::DBusErrorToServiceError(std::string error_name) {
device::BluetoothGattService::GattErrorCode code = GATT_ERROR_UNKNOWN;
- if (error_name == kErrorFailed) {
+ if (error_name == bluetooth_gatt_service::kErrorFailed) {
code = GATT_ERROR_FAILED;
- } else if (error_name == kErrorInProgress) {
+ } else if (error_name == bluetooth_gatt_service::kErrorInProgress) {
code = GATT_ERROR_IN_PROGRESS;
- } else if (error_name == kErrorInvalidValueLength) {
+ } else if (error_name == bluetooth_gatt_service::kErrorInvalidValueLength) {
code = GATT_ERROR_INVALID_LENGTH;
- } else if (error_name == kErrorNotPermitted) {
+ } else if (error_name == bluetooth_gatt_service::kErrorReadNotPermitted ||
+ error_name == bluetooth_gatt_service::kErrorWriteNotPermitted) {
code = GATT_ERROR_NOT_PERMITTED;
- } else if (error_name == kErrorNotAuthorized) {
+ } else if (error_name == bluetooth_gatt_service::kErrorNotAuthorized) {
code = GATT_ERROR_NOT_AUTHORIZED;
- } else if (error_name == kErrorNotPaired) {
+ } else if (error_name == bluetooth_gatt_service::kErrorNotPaired) {
code = GATT_ERROR_NOT_PAIRED;
- } else if (error_name == kErrorNotSupported) {
+ } else if (error_name == bluetooth_gatt_service::kErrorNotSupported) {
code = GATT_ERROR_NOT_SUPPORTED;
}
return code;
@@ -60,4 +51,15 @@ BluetoothAdapterBlueZ* BluetoothGattServiceBlueZ::GetAdapter() const {
return adapter_;
}
+dbus::ObjectPath BluetoothGattServiceBlueZ::GenerateAttributeObjectPath(
+ const std::string attribute_type) {
+ DCHECK(adapter_);
+
+ std::string GuidString = base::GenerateGUID();
+ base::RemoveChars(GuidString, "-", &GuidString);
+
+ return dbus::ObjectPath(adapter_->GetApplicationObjectPath().value() + "/" +
+ attribute_type + "/" + GuidString);
+}
+
} // namespace bluez

Powered by Google App Engine
This is Rietveld 408576698