Chromium Code Reviews| Index: device/bluetooth/bluetooth_device.cc |
| diff --git a/device/bluetooth/bluetooth_device.cc b/device/bluetooth/bluetooth_device.cc |
| index 7c56c127884732fcc129b68a325a909840570e18..de13d04240fa4931801d03de55aea9d35f8f5c7f 100644 |
| --- a/device/bluetooth/bluetooth_device.cc |
| +++ b/device/bluetooth/bluetooth_device.cc |
| @@ -15,6 +15,7 @@ |
| #include "base/values.h" |
| #include "device/bluetooth/bluetooth_adapter.h" |
| #include "device/bluetooth/bluetooth_gatt_connection.h" |
| +#include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" |
| #include "device/bluetooth/bluetooth_remote_gatt_service.h" |
| #include "device/bluetooth/string_util_icu.h" |
| #include "grit/bluetooth_strings.h" |
| @@ -449,6 +450,52 @@ void BluetoothDevice::ClearAdvertisementData() { |
| GetAdapter()->NotifyDeviceChanged(this); |
| } |
| +std::vector<BluetoothRemoteGattCharacteristic*> |
| +BluetoothDevice::GetCharacteristicsByUUID( |
| + const std::string& service_instance_id, |
| + const BluetoothUUID& characteristic_uuid) { |
| + std::vector<BluetoothRemoteGattCharacteristic*> characteristics; |
| + VLOG(1) << "Looking for characteristic: " |
|
scheib
2017/01/07 01:42:36
Change these VLOGs to be VLOG(2). Now that we're i
juncai
2017/01/09 19:29:19
Done.
|
| + << characteristic_uuid.canonical_value(); |
| + BluetoothRemoteGattService* service = GetGattService(service_instance_id); |
| + if (service) { |
| + for (BluetoothRemoteGattCharacteristic* characteristic : |
| + service->GetCharacteristics()) { |
| + VLOG(1) << "Characteristic in cache: " |
| + << characteristic->GetUUID().canonical_value(); |
| + if (characteristic->GetUUID() == characteristic_uuid) { |
| + characteristics.push_back(characteristic); |
| + } |
| + } |
| + } |
| + return characteristics; |
| +} |
| + |
| +std::vector<BluetoothRemoteGattService*> |
| +BluetoothDevice::GetPrimaryServicesByUUID(const BluetoothUUID& service_uuid) { |
| + std::vector<BluetoothRemoteGattService*> services; |
| + VLOG(1) << "Looking for service: " << service_uuid.canonical_value(); |
| + for (BluetoothRemoteGattService* service : GetGattServices()) { |
| + VLOG(1) << "Service in cache: " << service->GetUUID().canonical_value(); |
| + if (service->GetUUID() == service_uuid && service->IsPrimary()) { |
| + services.push_back(service); |
| + } |
| + } |
| + return services; |
| +} |
| + |
| +std::vector<BluetoothRemoteGattService*> BluetoothDevice::GetPrimaryServices() { |
| + std::vector<BluetoothRemoteGattService*> services; |
| + VLOG(1) << "Looking for services."; |
| + for (BluetoothRemoteGattService* service : GetGattServices()) { |
| + VLOG(1) << "Service in cache: " << service->GetUUID().canonical_value(); |
| + if (service->IsPrimary()) { |
| + services.push_back(service); |
| + } |
| + } |
| + return services; |
| +} |
| + |
| void BluetoothDevice::DidConnectGatt() { |
| for (const auto& callback : create_gatt_connection_success_callbacks_) { |
| callback.Run( |