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