Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(892)

Unified Diff: device/bluetooth/bluetooth_adapter_mac.mm

Issue 2248913002: bluetooth: Implement RSSI and Tx Power on macOS and Android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bluetooth-refactor-adv-data
Patch Set: Clean up Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/bluetooth_adapter_mac.mm
diff --git a/device/bluetooth/bluetooth_adapter_mac.mm b/device/bluetooth/bluetooth_adapter_mac.mm
index ef4a20dee2da1156e992a84add68576b47755754..eb54042f88d7034d338a5f56e41095feb5d08f18 100644
--- a/device/bluetooth/bluetooth_adapter_mac.mm
+++ b/device/bluetooth/bluetooth_adapter_mac.mm
@@ -539,8 +539,19 @@ void BluetoothAdapterMac::LowEnergyDeviceUpdated(
std::vector<uint8_t>(bytes, bytes + length));
}
- device_mac->UpdateAdvertisementData(std::move(advertised_uuids),
- std::move(service_data_map));
+ // Get Tx Power.
+ base::Optional<int8_t> clamped_tx_power;
+ NSNumber* tx_power =
+ [advertisement_data objectForKey:CBAdvertisementDataTxPowerLevelKey];
+ clamped_tx_power =
+ tx_power == nil ? base::nullopt
Jeffrey Yasskin 2016/08/24 04:32:02 Either make this the initialization of the variabl
ortuno 2016/08/24 21:29:09 Done. hmm I wonder why I declared the variable up
+ : base::make_optional<int8_t>(
+ BluetoothDevice::ClampPower([tx_power intValue]));
+
+ device_mac->UpdateAdvertisementData(
+ BluetoothDevice::ClampPower(rssi), std::move(advertised_uuids),
+ std::move(service_data_map),
+ clamped_tx_power ? &clamped_tx_power.value() : nullptr);
if (is_new_device) {
std::string device_address =

Powered by Google App Engine
This is Rietveld 408576698