| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/bind.h" | |
| 6 #include "base/callback.h" | |
| 7 #include "base/logging.h" | |
| 8 #include "device/bluetooth/bluetooth_adapter_bluez.h" | |
| 9 #include "device/bluetooth/bluetooth_gatt_characteristic.h" | |
| 10 #include "device/bluetooth/bluetooth_local_gatt_service_bluez.h" | |
| 11 #include "device/bluetooth/dbus/bluetooth_gatt_manager_client.h" | |
| 12 #include "device/bluetooth/dbus/bluez_dbus_manager.h" | |
| 13 | |
| 14 namespace bluez { | |
| 15 | |
| 16 BluetoothLocalGattServiceBlueZ::BluetoothLocalGattServiceBlueZ( | |
| 17 BluetoothAdapterBlueZ* adapter, | |
| 18 const dbus::ObjectPath& object_path) | |
| 19 : BluetoothGattServiceBlueZ(adapter, object_path), weak_ptr_factory_(this) { | |
| 20 VLOG(1) << "Creating local GATT service with identifier: " | |
| 21 << object_path.value(); | |
| 22 } | |
| 23 | |
| 24 BluetoothLocalGattServiceBlueZ::~BluetoothLocalGattServiceBlueZ() {} | |
| 25 | |
| 26 device::BluetoothUUID BluetoothLocalGattServiceBlueZ::GetUUID() const { | |
| 27 NOTIMPLEMENTED(); | |
| 28 return device::BluetoothUUID(); | |
| 29 } | |
| 30 | |
| 31 bool BluetoothLocalGattServiceBlueZ::IsLocal() const { | |
| 32 return true; | |
| 33 } | |
| 34 | |
| 35 bool BluetoothLocalGattServiceBlueZ::IsPrimary() const { | |
| 36 NOTIMPLEMENTED(); | |
| 37 return false; | |
| 38 } | |
| 39 | |
| 40 device::BluetoothDevice* BluetoothLocalGattServiceBlueZ::GetDevice() const { | |
| 41 return nullptr; | |
| 42 } | |
| 43 | |
| 44 bool BluetoothLocalGattServiceBlueZ::AddCharacteristic( | |
| 45 device::BluetoothGattCharacteristic* characteristic) { | |
| 46 NOTIMPLEMENTED(); | |
| 47 return false; | |
| 48 } | |
| 49 | |
| 50 bool BluetoothLocalGattServiceBlueZ::AddIncludedService( | |
| 51 device::BluetoothGattService* service) { | |
| 52 NOTIMPLEMENTED(); | |
| 53 return false; | |
| 54 } | |
| 55 | |
| 56 void BluetoothLocalGattServiceBlueZ::Register( | |
| 57 const base::Closure& callback, | |
| 58 const ErrorCallback& error_callback) { | |
| 59 DCHECK(bluez::BluezDBusManager::Get()); | |
| 60 bluez::BluezDBusManager::Get() | |
| 61 ->GetBluetoothGattManagerClient() | |
| 62 ->RegisterService( | |
| 63 object_path(), BluetoothGattManagerClient::Options(), callback, | |
| 64 base::Bind(&BluetoothLocalGattServiceBlueZ::OnRegistrationError, | |
| 65 weak_ptr_factory_.GetWeakPtr(), error_callback)); | |
| 66 } | |
| 67 | |
| 68 void BluetoothLocalGattServiceBlueZ::Unregister( | |
| 69 const base::Closure& callback, | |
| 70 const ErrorCallback& error_callback) { | |
| 71 DCHECK(bluez::BluezDBusManager::Get()); | |
| 72 bluez::BluezDBusManager::Get() | |
| 73 ->GetBluetoothGattManagerClient() | |
| 74 ->UnregisterService( | |
| 75 object_path(), callback, | |
| 76 base::Bind(&BluetoothLocalGattServiceBlueZ::OnRegistrationError, | |
| 77 weak_ptr_factory_.GetWeakPtr(), error_callback)); | |
| 78 } | |
| 79 | |
| 80 void BluetoothLocalGattServiceBlueZ::OnRegistrationError( | |
| 81 const ErrorCallback& error_callback, | |
| 82 const std::string& error_name, | |
| 83 const std::string& error_message) { | |
| 84 VLOG(1) << "[Un]Register Service failed: " << error_name | |
| 85 << ", message: " << error_message; | |
| 86 error_callback.Run( | |
| 87 BluetoothGattServiceBlueZ::DBusErrorToServiceError(error_name)); | |
| 88 } | |
| 89 | |
| 90 } // namespace bluez | |
| OLD | NEW |