OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/bluetooth_remote_gatt_service_chromeos.h" | 5 #include "device/bluetooth/bluetooth_remote_gatt_service_chromeos.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "chromeos/dbus/bluetooth_gatt_service_client.h" | 9 #include "chromeos/dbus/bluetooth_gatt_service_client.h" |
10 #include "chromeos/dbus/dbus_thread_manager.h" | 10 #include "chromeos/dbus/dbus_thread_manager.h" |
11 #include "device/bluetooth/bluetooth_adapter_chromeos.h" | 11 #include "device/bluetooth/bluetooth_adapter_chromeos.h" |
12 #include "device/bluetooth/bluetooth_device_chromeos.h" | 12 #include "device/bluetooth/bluetooth_device_chromeos.h" |
13 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h" | 13 #include "device/bluetooth/bluetooth_remote_gatt_characteristic_chromeos.h" |
14 #include "device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.h" | 14 #include "device/bluetooth/bluetooth_remote_gatt_descriptor_chromeos.h" |
15 | 15 |
16 namespace chromeos { | 16 namespace chromeos { |
17 | 17 |
18 namespace { | 18 namespace { |
19 | 19 |
20 // TODO(jamuraa) move these to cros_system_api later | 20 // TODO(jamuraa) move these to cros_system_api later |
21 const char kErrorFailed[] = "org.bluez.Error.Failed"; | 21 const char kErrorFailed[] = "org.bluez.Error.Failed"; |
22 const char kErrorInProgress[] = "org.bluez.Error.InProgress"; | 22 const char kErrorInProgress[] = "org.bluez.Error.InProgress"; |
23 const char kErrorInvalidValueLength[] = "org.bluez.Error.InvalidValueLength"; | 23 const char kErrorInvalidValueLength[] = "org.bluez.Error.InvalidValueLength"; |
24 const char kErrorNotAuthorized[] = "org.bluez.Error.NotAuthorized"; | 24 const char kErrorNotAuthorized[] = "org.bluez.Error.NotAuthorized"; |
25 const char kErrorNotPaired[] = "org.bluez.Error.NotPaired"; | 25 const char kErrorNotPaired[] = "org.bluez.Error.NotPaired"; |
26 const char kErrorNotSupported[] = "org.bluez.Error.NotSupported"; | 26 const char kErrorNotSupported[] = "org.bluez.Error.NotSupported"; |
27 const char kErrorReadNotPermitted[] = "org.bluez.Error.ReadNotPermitted"; | 27 const char kErrorNotPermitted[] = "org.bluez.Error.NotPermitted"; |
28 const char kErrorWriteNotPermitted[] = "org.bluez.Error.WriteNotPermitted"; | |
29 | 28 |
30 } // namespace | 29 } // namespace |
31 | 30 |
32 BluetoothRemoteGattServiceChromeOS::BluetoothRemoteGattServiceChromeOS( | 31 BluetoothRemoteGattServiceChromeOS::BluetoothRemoteGattServiceChromeOS( |
33 BluetoothAdapterChromeOS* adapter, | 32 BluetoothAdapterChromeOS* adapter, |
34 BluetoothDeviceChromeOS* device, | 33 BluetoothDeviceChromeOS* device, |
35 const dbus::ObjectPath& object_path) | 34 const dbus::ObjectPath& object_path) |
36 : object_path_(object_path), | 35 : object_path_(object_path), |
37 adapter_(adapter), | 36 adapter_(adapter), |
38 device_(device), | 37 device_(device), |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 device::BluetoothGattService::GattErrorCode | 158 device::BluetoothGattService::GattErrorCode |
160 BluetoothRemoteGattServiceChromeOS::DBusErrorToServiceError( | 159 BluetoothRemoteGattServiceChromeOS::DBusErrorToServiceError( |
161 std::string error_name) { | 160 std::string error_name) { |
162 device::BluetoothGattService::GattErrorCode code = GATT_ERROR_UNKNOWN; | 161 device::BluetoothGattService::GattErrorCode code = GATT_ERROR_UNKNOWN; |
163 if (error_name == kErrorFailed) { | 162 if (error_name == kErrorFailed) { |
164 code = GATT_ERROR_FAILED; | 163 code = GATT_ERROR_FAILED; |
165 } else if (error_name == kErrorInProgress) { | 164 } else if (error_name == kErrorInProgress) { |
166 code = GATT_ERROR_IN_PROGRESS; | 165 code = GATT_ERROR_IN_PROGRESS; |
167 } else if (error_name == kErrorInvalidValueLength) { | 166 } else if (error_name == kErrorInvalidValueLength) { |
168 code = GATT_ERROR_INVALID_LENGTH; | 167 code = GATT_ERROR_INVALID_LENGTH; |
169 } else if (error_name == kErrorReadNotPermitted || | 168 } else if (error_name == kErrorNotPermitted) { |
170 error_name == kErrorWriteNotPermitted) { | |
171 code = GATT_ERROR_NOT_PERMITTED; | 169 code = GATT_ERROR_NOT_PERMITTED; |
172 } else if (error_name == kErrorNotAuthorized) { | 170 } else if (error_name == kErrorNotAuthorized) { |
173 code = GATT_ERROR_NOT_AUTHORIZED; | 171 code = GATT_ERROR_NOT_AUTHORIZED; |
174 } else if (error_name == kErrorNotPaired) { | 172 } else if (error_name == kErrorNotPaired) { |
175 code = GATT_ERROR_NOT_PAIRED; | 173 code = GATT_ERROR_NOT_PAIRED; |
176 } else if (error_name == kErrorNotSupported) { | 174 } else if (error_name == kErrorNotSupported) { |
177 code = GATT_ERROR_NOT_SUPPORTED; | 175 code = GATT_ERROR_NOT_SUPPORTED; |
178 } | 176 } |
179 return code; | 177 return code; |
180 } | 178 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 DCHECK(adapter_); | 320 DCHECK(adapter_); |
323 | 321 |
324 if (property_name == properties->flags.name()) | 322 if (property_name == properties->flags.name()) |
325 NotifyServiceChanged(); | 323 NotifyServiceChanged(); |
326 else if (property_name == properties->value.name()) | 324 else if (property_name == properties->value.name()) |
327 adapter_->NotifyGattCharacteristicValueChanged(iter->second, | 325 adapter_->NotifyGattCharacteristicValueChanged(iter->second, |
328 properties->value.value()); | 326 properties->value.value()); |
329 } | 327 } |
330 | 328 |
331 } // namespace chromeos | 329 } // namespace chromeos |
OLD | NEW |