Chromium Code Reviews| Index: device/bluetooth/bluetooth_local_gatt_service_bluez.cc |
| diff --git a/device/bluetooth/bluetooth_local_gatt_service_bluez.cc b/device/bluetooth/bluetooth_local_gatt_service_bluez.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..5156b24640e4ade9608241a600a9cdde76155ab6 |
| --- /dev/null |
| +++ b/device/bluetooth/bluetooth_local_gatt_service_bluez.cc |
| @@ -0,0 +1,91 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
|
ortuno
2016/04/14 17:42:36
2016
rkc
2016/04/14 19:27:28
Done.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "device/bluetooth/bluetooth_local_gatt_service_bluez.h" |
| + |
| +#include "base/logging.h" |
| +#include "base/strings/stringprintf.h" |
| +#include "device/bluetooth/bluetooth_adapter_bluez.h" |
| +#include "device/bluetooth/bluetooth_device_bluez.h" |
| +#include "device/bluetooth/bluetooth_gatt_characteristic_bluez.h" |
| +#include "device/bluetooth/dbus/bluetooth_gatt_manager_client.h" |
| +#include "device/bluetooth/dbus/bluez_dbus_manager.h" |
|
ortuno
2016/04/14 17:42:36
Clean up includes here as well.
rkc
2016/04/14 19:27:28
Done.
|
| + |
| +namespace bluez { |
| + |
| +BluetoothLocalGattServiceBlueZ::BluetoothLocalGattServiceBlueZ( |
| + BluetoothAdapterBlueZ* adapter, |
| + const dbus::ObjectPath& object_path) |
| + : BluetoothGattServiceBlueZ(adapter, object_path), weak_ptr_factory_(this) { |
| + VLOG(1) << "Creating local GATT service with identifier: " |
| + << object_path.value(); |
| +} |
| + |
| +BluetoothLocalGattServiceBlueZ::~BluetoothLocalGattServiceBlueZ() {} |
| + |
| +device::BluetoothUUID BluetoothLocalGattServiceBlueZ::GetUUID() const { |
| + NOTIMPLEMENTED(); |
| + return device::BluetoothUUID(); |
| +} |
| + |
| +bool BluetoothLocalGattServiceBlueZ::IsLocal() const { |
| + return true; |
| +} |
| + |
| +bool BluetoothLocalGattServiceBlueZ::IsPrimary() const { |
|
ortuno
2016/04/14 17:42:36
This should be true right? There is no way to cons
rkc
2016/04/14 19:27:28
This method doesn't apply to local characteristics
ortuno
2016/04/14 21:17:38
But this is not a characteristic :P Anyway I reali
rkc
2016/04/14 21:59:38
Acknowledged.
|
| + NOTIMPLEMENTED(); |
| + return false; |
| +} |
| + |
| +device::BluetoothDevice* BluetoothLocalGattServiceBlueZ::GetDevice() const { |
| + return nullptr; |
| +} |
| + |
| +bool BluetoothLocalGattServiceBlueZ::AddCharacteristic( |
|
ortuno
2016/04/14 17:42:36
I'm guessing these Add functions will be removed b
rkc
2016/04/14 19:27:28
Acknowledged.
|
| + device::BluetoothGattCharacteristic* characteristic) { |
| + NOTIMPLEMENTED(); |
| + return false; |
| +} |
| + |
| +bool BluetoothLocalGattServiceBlueZ::AddIncludedService( |
| + device::BluetoothGattService* service) { |
| + NOTIMPLEMENTED(); |
| + return false; |
| +} |
| + |
| +void BluetoothLocalGattServiceBlueZ::Register( |
|
ortuno
2016/04/14 17:42:36
I thought you were moving this to the adapter?
rkc
2016/04/14 19:27:28
Please see my other comments regarding this being
|
| + const base::Closure& callback, |
| + const ErrorCallback& error_callback) { |
| + DCHECK(bluez::BluezDBusManager::Get()); |
| + bluez::BluezDBusManager::Get() |
| + ->GetBluetoothGattManagerClient() |
| + ->RegisterService( |
| + object_path(), BluetoothGattManagerClient::Options(), callback, |
| + base::Bind(&BluetoothLocalGattServiceBlueZ::OnRegistrationError, |
| + weak_ptr_factory_.GetWeakPtr(), error_callback)); |
| +} |
| + |
| +void BluetoothLocalGattServiceBlueZ::Unregister( |
| + const base::Closure& callback, |
| + const ErrorCallback& error_callback) { |
| + DCHECK(bluez::BluezDBusManager::Get()); |
| + bluez::BluezDBusManager::Get() |
| + ->GetBluetoothGattManagerClient() |
| + ->UnregisterService( |
| + object_path(), callback, |
| + base::Bind(&BluetoothLocalGattServiceBlueZ::OnRegistrationError, |
| + weak_ptr_factory_.GetWeakPtr(), error_callback)); |
| +} |
| + |
| +void BluetoothLocalGattServiceBlueZ::OnRegistrationError( |
| + const ErrorCallback& error_callback, |
| + const std::string& error_name, |
| + const std::string& error_message) { |
| + VLOG(1) << "[Un]Register Service failed: " << error_name |
| + << ", message: " << error_message; |
| + error_callback.Run( |
| + BluetoothGattServiceBlueZ::DBusErrorToServiceError(error_name)); |
| +} |
| + |
| +} // namespace bluez |