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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 UUIDSet uuids; | 368 UUIDSet uuids; |
369 const std::vector<std::string>& dbus_uuids = properties->uuids.value(); | 369 const std::vector<std::string>& dbus_uuids = properties->uuids.value(); |
370 for (const std::string& dbus_uuid : dbus_uuids) { | 370 for (const std::string& dbus_uuid : dbus_uuids) { |
371 device::BluetoothUUID uuid(dbus_uuid); | 371 device::BluetoothUUID uuid(dbus_uuid); |
372 DCHECK(uuid.IsValid()); | 372 DCHECK(uuid.IsValid()); |
373 uuids.insert(std::move(uuid)); | 373 uuids.insert(std::move(uuid)); |
374 } | 374 } |
375 return uuids; | 375 return uuids; |
376 } | 376 } |
377 | 377 |
378 base::Optional<uint8_t> BluetoothDeviceBlueZ::GetAdvertisingDataFlags() const { | |
ortuno
2016/10/18 01:41:19
Also please follow the same pattern as Manufacture
puthik_chromium
2016/11/02 23:20:38
Done.
| |
379 bluez::BluetoothDeviceClient::Properties* properties = | |
380 bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( | |
381 object_path_); | |
382 DCHECK(properties); | |
383 | |
384 if (properties->advertising_data_flags.is_valid()) | |
385 return properties->advertising_data_flags.value(); | |
386 return base::nullopt; | |
387 } | |
388 | |
378 base::Optional<int8_t> BluetoothDeviceBlueZ::GetInquiryRSSI() const { | 389 base::Optional<int8_t> BluetoothDeviceBlueZ::GetInquiryRSSI() const { |
379 bluez::BluetoothDeviceClient::Properties* properties = | 390 bluez::BluetoothDeviceClient::Properties* properties = |
380 bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( | 391 bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( |
381 object_path_); | 392 object_path_); |
382 DCHECK(properties); | 393 DCHECK(properties); |
383 | 394 |
384 if (!properties->rssi.is_valid()) | 395 if (!properties->rssi.is_valid()) |
385 return base::nullopt; | 396 return base::nullopt; |
386 | 397 |
387 // BlueZ uses int16_t because there is no int8_t for DBus, so we should never | 398 // BlueZ uses int16_t because there is no int8_t for DBus, so we should never |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
600 bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( | 611 bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( |
601 object_path_); | 612 object_path_); |
602 DCHECK(properties); | 613 DCHECK(properties); |
603 DCHECK(properties->service_data.is_valid()); | 614 DCHECK(properties->service_data.is_valid()); |
604 | 615 |
605 service_data_.clear(); | 616 service_data_.clear(); |
606 for (const auto& pair : properties->service_data.value()) | 617 for (const auto& pair : properties->service_data.value()) |
607 service_data_[BluetoothUUID(pair.first)] = pair.second; | 618 service_data_[BluetoothUUID(pair.first)] = pair.second; |
608 } | 619 } |
609 | 620 |
621 void BluetoothDeviceBlueZ::UpdateManufacturerData() { | |
622 bluez::BluetoothDeviceClient::Properties* properties = | |
623 bluez::BluezDBusManager::Get()->GetBluetoothDeviceClient()->GetProperties( | |
624 object_path_); | |
625 DCHECK(properties); | |
626 DCHECK(properties->manufacturer_data.is_valid()); | |
ortuno
2016/10/18 01:41:18
manufacturer data is optional so this would is not
puthik_chromium
2016/11/02 23:20:38
Done.
| |
627 | |
628 manufacturer_data_.clear(); | |
629 for (const auto& pair : properties->manufacturer_data.value()) | |
630 manufacturer_data_[pair.first] = pair.second; | |
631 } | |
632 | |
610 BluetoothPairingBlueZ* BluetoothDeviceBlueZ::BeginPairing( | 633 BluetoothPairingBlueZ* BluetoothDeviceBlueZ::BeginPairing( |
611 BluetoothDevice::PairingDelegate* pairing_delegate) { | 634 BluetoothDevice::PairingDelegate* pairing_delegate) { |
612 pairing_.reset(new BluetoothPairingBlueZ(this, pairing_delegate)); | 635 pairing_.reset(new BluetoothPairingBlueZ(this, pairing_delegate)); |
613 return pairing_.get(); | 636 return pairing_.get(); |
614 } | 637 } |
615 | 638 |
616 void BluetoothDeviceBlueZ::EndPairing() { | 639 void BluetoothDeviceBlueZ::EndPairing() { |
617 pairing_.reset(); | 640 pairing_.reset(); |
618 } | 641 } |
619 | 642 |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
913 void BluetoothDeviceBlueZ::OnForgetError(const ErrorCallback& error_callback, | 936 void BluetoothDeviceBlueZ::OnForgetError(const ErrorCallback& error_callback, |
914 const std::string& error_name, | 937 const std::string& error_name, |
915 const std::string& error_message) { | 938 const std::string& error_message) { |
916 LOG(WARNING) << object_path_.value() | 939 LOG(WARNING) << object_path_.value() |
917 << ": Failed to remove device: " << error_name << ": " | 940 << ": Failed to remove device: " << error_name << ": " |
918 << error_message; | 941 << error_message; |
919 error_callback.Run(); | 942 error_callback.Run(); |
920 } | 943 } |
921 | 944 |
922 } // namespace bluez | 945 } // namespace bluez |
OLD | NEW |