| OLD | NEW |
| 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_local_gatt_characteristic_bluez.h" | 5 #include "device/bluetooth/bluez/bluetooth_local_gatt_characteristic_bluez.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "device/bluetooth/bluez/bluetooth_local_gatt_service_bluez.h" | 11 #include "device/bluetooth/bluez/bluetooth_local_gatt_service_bluez.h" |
| 12 | 12 |
| 13 namespace device { | 13 namespace device { |
| 14 | 14 |
| 15 // static | 15 // static |
| 16 base::WeakPtr<device::BluetoothLocalGattCharacteristic> | 16 base::WeakPtr<device::BluetoothLocalGattCharacteristic> |
| 17 BluetoothLocalGattCharacteristic::Create( | 17 BluetoothLocalGattCharacteristic::Create( |
| 18 const device::BluetoothUUID& uuid, | 18 const device::BluetoothUUID& uuid, |
| 19 device::BluetoothGattCharacteristic::Properties properties, | 19 device::BluetoothGattCharacteristic::Properties properties, |
| 20 device::BluetoothGattCharacteristic::Permissions permissions, | 20 device::BluetoothGattCharacteristic::Permissions permissions, |
| 21 device::BluetoothLocalGattService* service) { | 21 device::BluetoothLocalGattService* service) { |
| 22 DCHECK(service); | 22 DCHECK(service); |
| 23 bluez::BluetoothLocalGattServiceBlueZ* service_bluez = | 23 bluez::BluetoothLocalGattServiceBlueZ* service_bluez = |
| 24 static_cast<bluez::BluetoothLocalGattServiceBlueZ*>(service); | 24 static_cast<bluez::BluetoothLocalGattServiceBlueZ*>(service); |
| 25 // TODO(rkc): Handle permisisons once BlueZ supports getting them from DBus. |
| 25 bluez::BluetoothLocalGattCharacteristicBlueZ* characteristic = | 26 bluez::BluetoothLocalGattCharacteristicBlueZ* characteristic = |
| 26 new bluez::BluetoothLocalGattCharacteristicBlueZ(uuid, service_bluez); | 27 new bluez::BluetoothLocalGattCharacteristicBlueZ(uuid, properties, |
| 28 service_bluez); |
| 27 return characteristic->weak_ptr_factory_.GetWeakPtr(); | 29 return characteristic->weak_ptr_factory_.GetWeakPtr(); |
| 28 } | 30 } |
| 29 | 31 |
| 30 } // device | 32 } // device |
| 31 | 33 |
| 32 namespace bluez { | 34 namespace bluez { |
| 33 | 35 |
| 34 BluetoothLocalGattCharacteristicBlueZ::BluetoothLocalGattCharacteristicBlueZ( | 36 BluetoothLocalGattCharacteristicBlueZ::BluetoothLocalGattCharacteristicBlueZ( |
| 35 const device::BluetoothUUID& uuid, | 37 const device::BluetoothUUID& uuid, |
| 38 Properties properties, |
| 36 BluetoothLocalGattServiceBlueZ* service) | 39 BluetoothLocalGattServiceBlueZ* service) |
| 37 : BluetoothGattCharacteristicBlueZ( | 40 : BluetoothGattCharacteristicBlueZ( |
| 38 BluetoothLocalGattServiceBlueZ::AddGuidToObjectPath( | 41 BluetoothLocalGattServiceBlueZ::AddGuidToObjectPath( |
| 39 service->object_path().value() + "/characteristic")), | 42 service->object_path().value() + "/characteristic")), |
| 40 uuid_(uuid), | 43 uuid_(uuid), |
| 44 properties_(properties), |
| 41 service_(service), | 45 service_(service), |
| 42 weak_ptr_factory_(this) { | 46 weak_ptr_factory_(this) { |
| 43 VLOG(1) << "Creating local GATT characteristic with identifier: " | 47 VLOG(1) << "Creating local GATT characteristic with identifier: " |
| 44 << GetIdentifier(); | 48 << GetIdentifier(); |
| 45 service->AddCharacteristic(base::WrapUnique(this)); | 49 service->AddCharacteristic(base::WrapUnique(this)); |
| 46 } | 50 } |
| 47 | 51 |
| 48 BluetoothLocalGattCharacteristicBlueZ:: | 52 BluetoothLocalGattCharacteristicBlueZ:: |
| 49 ~BluetoothLocalGattCharacteristicBlueZ() {} | 53 ~BluetoothLocalGattCharacteristicBlueZ() {} |
| 50 | 54 |
| 51 device::BluetoothUUID BluetoothLocalGattCharacteristicBlueZ::GetUUID() const { | 55 device::BluetoothUUID BluetoothLocalGattCharacteristicBlueZ::GetUUID() const { |
| 52 return uuid_; | 56 return uuid_; |
| 53 } | 57 } |
| 54 | 58 |
| 55 device::BluetoothGattCharacteristic::Properties | 59 device::BluetoothGattCharacteristic::Properties |
| 56 BluetoothLocalGattCharacteristicBlueZ::GetProperties() const { | 60 BluetoothLocalGattCharacteristicBlueZ::GetProperties() const { |
| 57 NOTIMPLEMENTED(); | 61 return properties_; |
| 58 return Properties(); | |
| 59 } | 62 } |
| 60 | 63 |
| 61 device::BluetoothGattCharacteristic::Permissions | 64 device::BluetoothGattCharacteristic::Permissions |
| 62 BluetoothLocalGattCharacteristicBlueZ::GetPermissions() const { | 65 BluetoothLocalGattCharacteristicBlueZ::GetPermissions() const { |
| 63 NOTIMPLEMENTED(); | 66 NOTIMPLEMENTED(); |
| 64 return Permissions(); | 67 return Permissions(); |
| 65 } | 68 } |
| 66 | 69 |
| 67 BluetoothLocalGattServiceBlueZ* | 70 BluetoothLocalGattServiceBlueZ* |
| 68 BluetoothLocalGattCharacteristicBlueZ::GetService() { | 71 BluetoothLocalGattCharacteristicBlueZ::GetService() { |
| 69 return service_; | 72 return service_; |
| 70 } | 73 } |
| 71 | 74 |
| 72 void BluetoothLocalGattCharacteristicBlueZ::AddDescriptor( | 75 void BluetoothLocalGattCharacteristicBlueZ::AddDescriptor( |
| 73 std::unique_ptr<BluetoothLocalGattDescriptorBlueZ> descriptor) { | 76 std::unique_ptr<BluetoothLocalGattDescriptorBlueZ> descriptor) { |
| 74 descriptors_.push_back(std::move(descriptor)); | 77 descriptors_.push_back(std::move(descriptor)); |
| 75 } | 78 } |
| 76 | 79 |
| 77 const std::vector<std::unique_ptr<BluetoothLocalGattDescriptorBlueZ>>& | 80 const std::vector<std::unique_ptr<BluetoothLocalGattDescriptorBlueZ>>& |
| 78 BluetoothLocalGattCharacteristicBlueZ::GetDescriptors() const { | 81 BluetoothLocalGattCharacteristicBlueZ::GetDescriptors() const { |
| 79 return descriptors_; | 82 return descriptors_; |
| 80 } | 83 } |
| 81 | 84 |
| 82 } // namespace bluez | 85 } // namespace bluez |
| OLD | NEW |