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 |
(...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 VLOG(2) << "Looking for service: " << service_uuid.canonical_value(); | 457 VLOG(2) << "Looking for service: " << service_uuid.canonical_value(); |
458 for (BluetoothRemoteGattService* service : GetGattServices()) { | 458 for (BluetoothRemoteGattService* service : GetGattServices()) { |
459 VLOG(2) << "Service in cache: " << service->GetUUID().canonical_value(); | 459 VLOG(2) << "Service in cache: " << service->GetUUID().canonical_value(); |
460 if (service->GetUUID() == service_uuid && service->IsPrimary()) { | 460 if (service->GetUUID() == service_uuid && service->IsPrimary()) { |
461 services.push_back(service); | 461 services.push_back(service); |
462 } | 462 } |
463 } | 463 } |
464 return services; | 464 return services; |
465 } | 465 } |
466 | 466 |
467 std::vector<BluetoothRemoteGattCharacteristic*> | |
468 BluetoothDevice::GetCharacteristicsByUUID( | |
469 const std::string& service_instance_id, | |
470 const BluetoothUUID& characteristic_uuid) { | |
471 std::vector<BluetoothRemoteGattCharacteristic*> characteristics; | |
472 VLOG(2) << "Looking for characteristic: " | |
473 << characteristic_uuid.canonical_value(); | |
474 BluetoothRemoteGattService* service = GetGattService(service_instance_id); | |
475 if (service) { | |
476 for (BluetoothRemoteGattCharacteristic* characteristic : | |
477 service->GetCharacteristics()) { | |
478 VLOG(2) << "Characteristic in cache: " | |
479 << characteristic->GetUUID().canonical_value(); | |
480 if (characteristic->GetUUID() == characteristic_uuid) { | |
481 characteristics.push_back(characteristic); | |
482 } | |
483 } | |
484 } | |
485 return characteristics; | |
486 } | |
487 | |
488 std::vector<device::BluetoothRemoteGattDescriptor*> | |
489 BluetoothDevice::GetDescriptorsByUUID( | |
490 device::BluetoothRemoteGattCharacteristic* characteristic, | |
491 const BluetoothUUID& descriptor_uuid) { | |
492 std::vector<device::BluetoothRemoteGattDescriptor*> descriptors; | |
493 DVLOG(1) << "Looking for descriptor: " << descriptor_uuid.canonical_value(); | |
494 for (auto* descriptor : characteristic->GetDescriptors()) { | |
495 DVLOG(1) << "Descriptor in cache: " | |
496 << descriptor->GetUUID().canonical_value(); | |
497 if (descriptor->GetUUID() == descriptor_uuid) { | |
498 descriptors.push_back(descriptor); | |
499 } | |
500 } | |
501 return descriptors; | |
502 } | |
503 | |
504 void BluetoothDevice::DidConnectGatt() { | 467 void BluetoothDevice::DidConnectGatt() { |
505 for (const auto& callback : create_gatt_connection_success_callbacks_) { | 468 for (const auto& callback : create_gatt_connection_success_callbacks_) { |
506 callback.Run( | 469 callback.Run( |
507 base::MakeUnique<BluetoothGattConnection>(adapter_, GetAddress())); | 470 base::MakeUnique<BluetoothGattConnection>(adapter_, GetAddress())); |
508 } | 471 } |
509 create_gatt_connection_success_callbacks_.clear(); | 472 create_gatt_connection_success_callbacks_.clear(); |
510 create_gatt_connection_error_callbacks_.clear(); | 473 create_gatt_connection_error_callbacks_.clear(); |
511 GetAdapter()->NotifyDeviceChanged(this); | 474 GetAdapter()->NotifyDeviceChanged(this); |
512 } | 475 } |
513 | 476 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 if (power < INT8_MIN) { | 541 if (power < INT8_MIN) { |
579 return INT8_MIN; | 542 return INT8_MIN; |
580 } | 543 } |
581 if (power > INT8_MAX) { | 544 if (power > INT8_MAX) { |
582 return INT8_MAX; | 545 return INT8_MAX; |
583 } | 546 } |
584 return static_cast<int8_t>(power); | 547 return static_cast<int8_t>(power); |
585 } | 548 } |
586 | 549 |
587 } // namespace device | 550 } // namespace device |
OLD | NEW |