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

Side by Side Diff: device/bluetooth/bluez/bluetooth_gatt_service_bluez.cc

Issue 1915803002: Bluetooth class changes for implementing local GATT attributes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "device/bluetooth/bluez/bluetooth_gatt_service_bluez.h" 5 #include "device/bluetooth/bluez/bluetooth_gatt_service_bluez.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "device/bluetooth/bluetooth_gatt_service.h"
8 #include "device/bluetooth/bluez/bluetooth_adapter_bluez.h" 9 #include "device/bluetooth/bluez/bluetooth_adapter_bluez.h"
10 #include "third_party/cros_system_api/dbus/service_constants.h"
9 11
10 namespace bluez { 12 namespace bluez {
11 13
12 namespace {
13
14 // TODO(jamuraa) move these to cros_system_api later
15 const char kErrorFailed[] = "org.bluez.Error.Failed";
16 const char kErrorInProgress[] = "org.bluez.Error.InProgress";
17 const char kErrorInvalidValueLength[] = "org.bluez.Error.InvalidValueLength";
18 const char kErrorNotAuthorized[] = "org.bluez.Error.NotAuthorized";
19 const char kErrorNotPaired[] = "org.bluez.Error.NotPaired";
20 const char kErrorNotSupported[] = "org.bluez.Error.NotSupported";
21 const char kErrorNotPermitted[] = "org.bluez.Error.NotPermitted";
22
23 } // namespace
24
25 BluetoothGattServiceBlueZ::BluetoothGattServiceBlueZ( 14 BluetoothGattServiceBlueZ::BluetoothGattServiceBlueZ(
26 BluetoothAdapterBlueZ* adapter) 15 BluetoothAdapterBlueZ* adapter)
27 : adapter_(adapter) { 16 : adapter_(adapter) {
28 DCHECK(adapter_); 17 DCHECK(adapter_);
29 } 18 }
30 19
31 BluetoothGattServiceBlueZ::~BluetoothGattServiceBlueZ() {} 20 BluetoothGattServiceBlueZ::~BluetoothGattServiceBlueZ() {}
32 21
33 std::string BluetoothGattServiceBlueZ::GetIdentifier() const { 22 std::string BluetoothGattServiceBlueZ::GetIdentifier() const {
34 return object_path_.value(); 23 return object_path_.value();
35 } 24 }
36 25
37 // static 26 // static
38 device::BluetoothGattService::GattErrorCode 27 device::BluetoothGattService::GattErrorCode
39 BluetoothGattServiceBlueZ::DBusErrorToServiceError(std::string error_name) { 28 BluetoothGattServiceBlueZ::DBusErrorToServiceError(std::string error_name) {
40 device::BluetoothGattService::GattErrorCode code = GATT_ERROR_UNKNOWN; 29 device::BluetoothGattService::GattErrorCode code = GATT_ERROR_UNKNOWN;
41 if (error_name == kErrorFailed) { 30 if (error_name == bluetooth_gatt_service::kErrorFailed) {
42 code = GATT_ERROR_FAILED; 31 code = GATT_ERROR_FAILED;
43 } else if (error_name == kErrorInProgress) { 32 } else if (error_name == bluetooth_gatt_service::kErrorInProgress) {
44 code = GATT_ERROR_IN_PROGRESS; 33 code = GATT_ERROR_IN_PROGRESS;
45 } else if (error_name == kErrorInvalidValueLength) { 34 } else if (error_name == bluetooth_gatt_service::kErrorInvalidValueLength) {
46 code = GATT_ERROR_INVALID_LENGTH; 35 code = GATT_ERROR_INVALID_LENGTH;
47 } else if (error_name == kErrorNotPermitted) { 36 } else if (error_name == bluetooth_gatt_service::kErrorReadNotPermitted ||
37 error_name == bluetooth_gatt_service::kErrorWriteNotPermitted) {
48 code = GATT_ERROR_NOT_PERMITTED; 38 code = GATT_ERROR_NOT_PERMITTED;
49 } else if (error_name == kErrorNotAuthorized) { 39 } else if (error_name == bluetooth_gatt_service::kErrorNotAuthorized) {
50 code = GATT_ERROR_NOT_AUTHORIZED; 40 code = GATT_ERROR_NOT_AUTHORIZED;
51 } else if (error_name == kErrorNotPaired) { 41 } else if (error_name == bluetooth_gatt_service::kErrorNotPaired) {
52 code = GATT_ERROR_NOT_PAIRED; 42 code = GATT_ERROR_NOT_PAIRED;
53 } else if (error_name == kErrorNotSupported) { 43 } else if (error_name == bluetooth_gatt_service::kErrorNotSupported) {
54 code = GATT_ERROR_NOT_SUPPORTED; 44 code = GATT_ERROR_NOT_SUPPORTED;
55 } 45 }
56 return code; 46 return code;
57 } 47 }
58 48
59 BluetoothAdapterBlueZ* BluetoothGattServiceBlueZ::GetAdapter() const { 49 BluetoothAdapterBlueZ* BluetoothGattServiceBlueZ::GetAdapter() const {
60 return adapter_; 50 return adapter_;
61 } 51 }
62 52
63 } // namespace bluez 53 } // namespace bluez
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698