OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_device_bluez.h" | 5 #include "device/bluetooth/bluez/bluetooth_device_bluez.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( | 600 bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( |
601 object_path_); | 601 object_path_); |
602 DCHECK(properties); | 602 DCHECK(properties); |
603 DCHECK(properties->service_data.is_valid()); | 603 DCHECK(properties->service_data.is_valid()); |
604 | 604 |
605 service_data_.clear(); | 605 service_data_.clear(); |
606 for (const auto& pair : properties->service_data.value()) | 606 for (const auto& pair : properties->service_data.value()) |
607 service_data_[BluetoothUUID(pair.first)] = pair.second; | 607 service_data_[BluetoothUUID(pair.first)] = pair.second; |
608 } | 608 } |
609 | 609 |
| 610 void BluetoothDeviceBlueZ::UpdateManufacturerData() { |
| 611 bluez::BluetoothDeviceClient::Properties* properties = |
| 612 bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( |
| 613 object_path_); |
| 614 DCHECK(properties); |
| 615 manufacturer_data_.clear(); |
| 616 |
| 617 if (properties->manufacturer_data.is_valid()) { |
| 618 for (const auto& pair : properties->manufacturer_data.value()) |
| 619 manufacturer_data_[pair.first] = pair.second; |
| 620 } |
| 621 } |
| 622 |
| 623 void BluetoothDeviceBlueZ::UpdateAdvertisingDataFlags() { |
| 624 bluez::BluetoothDeviceClient::Properties* properties = |
| 625 bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( |
| 626 object_path_); |
| 627 DCHECK(properties); |
| 628 advertising_data_flags_ = base::nullopt; |
| 629 |
| 630 // The advertising data flags property is a vector<uint8> because the |
| 631 // Supplement to Bluetooth Core Specification Version 6 page 13 said that |
| 632 // "The Flags field may be zero or more octets long." However, only the first |
| 633 // byte of that is needed because there is only 5 bits of data defined there. |
| 634 if (properties->advertising_data_flags.is_valid()) |
| 635 advertising_data_flags_ = properties->advertising_data_flags.value()[0]; |
| 636 } |
| 637 |
610 BluetoothPairingBlueZ* BluetoothDeviceBlueZ::BeginPairing( | 638 BluetoothPairingBlueZ* BluetoothDeviceBlueZ::BeginPairing( |
611 BluetoothDevice::PairingDelegate* pairing_delegate) { | 639 BluetoothDevice::PairingDelegate* pairing_delegate) { |
612 pairing_.reset(new BluetoothPairingBlueZ(this, pairing_delegate)); | 640 pairing_.reset(new BluetoothPairingBlueZ(this, pairing_delegate)); |
613 return pairing_.get(); | 641 return pairing_.get(); |
614 } | 642 } |
615 | 643 |
616 void BluetoothDeviceBlueZ::EndPairing() { | 644 void BluetoothDeviceBlueZ::EndPairing() { |
617 pairing_.reset(); | 645 pairing_.reset(); |
618 } | 646 } |
619 | 647 |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 void BluetoothDeviceBlueZ::OnForgetError(const ErrorCallback& error_callback, | 941 void BluetoothDeviceBlueZ::OnForgetError(const ErrorCallback& error_callback, |
914 const std::string& error_name, | 942 const std::string& error_name, |
915 const std::string& error_message) { | 943 const std::string& error_message) { |
916 LOG(WARNING) << object_path_.value() | 944 LOG(WARNING) << object_path_.value() |
917 << ": Failed to remove device: " << error_name << ": " | 945 << ": Failed to remove device: " << error_name << ": " |
918 << error_message; | 946 << error_message; |
919 error_callback.Run(); | 947 error_callback.Run(); |
920 } | 948 } |
921 | 949 |
922 } // namespace bluez | 950 } // namespace bluez |
OLD | NEW |