OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bluetooth_device.h" | 5 #include "device/bluetooth/bluetooth_device.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "device/bluetooth/bluetooth_adapter.h" | 16 #include "device/bluetooth/bluetooth_adapter.h" |
17 #include "device/bluetooth/bluetooth_gatt_connection.h" | 17 #include "device/bluetooth/bluetooth_gatt_connection.h" |
18 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" | 18 #include "device/bluetooth/bluetooth_remote_gatt_characteristic.h" |
| 19 #include "device/bluetooth/bluetooth_remote_gatt_descriptor.h" |
19 #include "device/bluetooth/bluetooth_remote_gatt_service.h" | 20 #include "device/bluetooth/bluetooth_remote_gatt_service.h" |
20 #include "device/bluetooth/string_util_icu.h" | 21 #include "device/bluetooth/string_util_icu.h" |
21 #include "grit/bluetooth_strings.h" | 22 #include "grit/bluetooth_strings.h" |
22 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
23 | 24 |
24 namespace device { | 25 namespace device { |
25 | 26 |
26 BluetoothDevice::DeviceUUIDs::DeviceUUIDs() = default; | 27 BluetoothDevice::DeviceUUIDs::DeviceUUIDs() = default; |
27 | 28 |
28 BluetoothDevice::DeviceUUIDs::~DeviceUUIDs() = default; | 29 BluetoothDevice::DeviceUUIDs::~DeviceUUIDs() = default; |
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 VLOG(2) << "Characteristic in cache: " | 490 VLOG(2) << "Characteristic in cache: " |
490 << characteristic->GetUUID().canonical_value(); | 491 << characteristic->GetUUID().canonical_value(); |
491 if (characteristic->GetUUID() == characteristic_uuid) { | 492 if (characteristic->GetUUID() == characteristic_uuid) { |
492 characteristics.push_back(characteristic); | 493 characteristics.push_back(characteristic); |
493 } | 494 } |
494 } | 495 } |
495 } | 496 } |
496 return characteristics; | 497 return characteristics; |
497 } | 498 } |
498 | 499 |
| 500 std::vector<device::BluetoothRemoteGattDescriptor*> |
| 501 BluetoothDevice::GetDescriptorsByUUID( |
| 502 device::BluetoothRemoteGattCharacteristic* characteristic, |
| 503 const BluetoothUUID& descriptor_uuid) { |
| 504 std::vector<device::BluetoothRemoteGattDescriptor*> descriptors; |
| 505 DVLOG(1) << "Looking for descriptor: " << descriptor_uuid.canonical_value(); |
| 506 for (auto* descriptor : characteristic->GetDescriptors()) { |
| 507 DVLOG(1) << "Descriptor in cache: " |
| 508 << descriptor->GetUUID().canonical_value(); |
| 509 if (descriptor->GetUUID() == descriptor_uuid) { |
| 510 descriptors.push_back(descriptor); |
| 511 } |
| 512 } |
| 513 return descriptors; |
| 514 } |
| 515 |
499 void BluetoothDevice::DidConnectGatt() { | 516 void BluetoothDevice::DidConnectGatt() { |
500 for (const auto& callback : create_gatt_connection_success_callbacks_) { | 517 for (const auto& callback : create_gatt_connection_success_callbacks_) { |
501 callback.Run( | 518 callback.Run( |
502 base::MakeUnique<BluetoothGattConnection>(adapter_, GetAddress())); | 519 base::MakeUnique<BluetoothGattConnection>(adapter_, GetAddress())); |
503 } | 520 } |
504 create_gatt_connection_success_callbacks_.clear(); | 521 create_gatt_connection_success_callbacks_.clear(); |
505 create_gatt_connection_error_callbacks_.clear(); | 522 create_gatt_connection_error_callbacks_.clear(); |
506 GetAdapter()->NotifyDeviceChanged(this); | 523 GetAdapter()->NotifyDeviceChanged(this); |
507 } | 524 } |
508 | 525 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
568 if (power < INT8_MIN) { | 585 if (power < INT8_MIN) { |
569 return INT8_MIN; | 586 return INT8_MIN; |
570 } | 587 } |
571 if (power > INT8_MAX) { | 588 if (power > INT8_MAX) { |
572 return INT8_MAX; | 589 return INT8_MAX; |
573 } | 590 } |
574 return static_cast<int8_t>(power); | 591 return static_cast<int8_t>(power); |
575 } | 592 } |
576 | 593 |
577 } // namespace device | 594 } // namespace device |
OLD | NEW |