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/bluetooth_adapter_mac.h" | 5 #include "device/bluetooth/bluetooth_adapter_mac.h" |
6 | 6 |
7 #import <IOBluetooth/objc/IOBluetoothDevice.h> | 7 #import <IOBluetooth/objc/IOBluetoothDevice.h> |
8 #import <IOBluetooth/objc/IOBluetoothHostController.h> | 8 #import <IOBluetooth/objc/IOBluetoothHostController.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 | 10 |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 service_data_map.emplace(BluetoothUUID([[uuid UUIDString] UTF8String]), | 545 service_data_map.emplace(BluetoothUUID([[uuid UUIDString] UTF8String]), |
546 std::vector<uint8_t>(bytes, bytes + length)); | 546 std::vector<uint8_t>(bytes, bytes + length)); |
547 } | 547 } |
548 | 548 |
549 // Get Tx Power. | 549 // Get Tx Power. |
550 NSNumber* tx_power = | 550 NSNumber* tx_power = |
551 [advertisement_data objectForKey:CBAdvertisementDataTxPowerLevelKey]; | 551 [advertisement_data objectForKey:CBAdvertisementDataTxPowerLevelKey]; |
552 int8_t clamped_tx_power = BluetoothDevice::ClampPower([tx_power intValue]); | 552 int8_t clamped_tx_power = BluetoothDevice::ClampPower([tx_power intValue]); |
553 | 553 |
554 device_mac->UpdateAdvertisementData( | 554 device_mac->UpdateAdvertisementData( |
555 BluetoothDevice::ClampPower(rssi), std::move(advertised_uuids), | 555 BluetoothDevice::ClampPower(rssi), nullptr, std::move(advertised_uuids), |
556 std::move(service_data_map), | 556 std::move(service_data_map), |
557 tx_power == nil ? nullptr : &clamped_tx_power); | 557 tx_power == nil ? nullptr : &clamped_tx_power); |
558 | 558 |
559 if (is_new_device) { | 559 if (is_new_device) { |
560 std::string device_address = | 560 std::string device_address = |
561 BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(peripheral); | 561 BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(peripheral); |
562 devices_.add(device_address, std::unique_ptr<BluetoothDevice>(device_mac)); | 562 devices_.add(device_address, std::unique_ptr<BluetoothDevice>(device_mac)); |
563 for (auto& observer : observers_) | 563 for (auto& observer : observers_) |
564 observer.DeviceAdded(this, device_mac); | 564 observer.DeviceAdded(this, device_mac); |
565 } else { | 565 } else { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 std::string device_address = | 646 std::string device_address = |
647 BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(peripheral); | 647 BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(peripheral); |
648 DevicesMap::const_iterator iter = devices_.find(device_address); | 648 DevicesMap::const_iterator iter = devices_.find(device_address); |
649 if (iter == devices_.end()) { | 649 if (iter == devices_.end()) { |
650 return nil; | 650 return nil; |
651 } | 651 } |
652 return static_cast<BluetoothLowEnergyDeviceMac*>(iter->second); | 652 return static_cast<BluetoothLowEnergyDeviceMac*>(iter->second); |
653 } | 653 } |
654 | 654 |
655 } // namespace device | 655 } // namespace device |
OLD | NEW |