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

Unified Diff: device/bluetooth/bluetooth_adapter_mac.mm

Issue 2339253002: bluetooth: mac: add connected LE devices to chooser (Closed)
Patch Set: Cleanup Created 4 years, 2 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
« no previous file with comments | « device/bluetooth/bluetooth_adapter_mac.h ('k') | device/bluetooth/bluetooth_adapter_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/bluetooth/bluetooth_adapter_mac.mm
diff --git a/device/bluetooth/bluetooth_adapter_mac.mm b/device/bluetooth/bluetooth_adapter_mac.mm
index 61d169e2c21937557362c21eb9b3d2f77e15d2f5..79de647f192e750e2c0217b4cab00d8a61a233f4 100644
--- a/device/bluetooth/bluetooth_adapter_mac.mm
+++ b/device/bluetooth/bluetooth_adapter_mac.mm
@@ -170,6 +170,27 @@ bool BluetoothAdapterMac::IsDiscovering() const {
return is_discovering;
}
+void BluetoothAdapterMac::RetrievedConnectedPeripherals() {
ortuno 2016/10/06 02:22:07 +scheib for thoughts. Some context: We are adding
ortuno 2016/10/06 02:22:52 +scheib for realz
scheib 2016/10/06 21:01:34 RetrievedConnectedPeripherals seems to be incorrec
ortuno 2016/10/06 23:43:12 Right, but we still have the problem of providing
scheib 2016/10/07 17:08:00 This method doesn't return devices. It causes conn
ortuno 2016/10/10 02:57:22 The current method as is does not return devices b
jlebel 2016/10/13 15:29:02 Acknowledged.
+ // It is not possible to ask for all connected peripherals with
+ // -[CBCentralManager retrieveConnectedPeripheralsWithServices:] by passing
+ // nil. To try to get most of the peripherals, the search is done with
+ // Generic Access service.
+ CBUUID* genericAccessServiceUUID = [CBUUID UUIDWithString:@"1800"];
ortuno 2016/10/12 06:42:46 I've been thinking about this and I think we need
jlebel 2016/10/13 15:29:01 I've tried, and yes, the devices are filtered out
ortuno 2016/10/14 03:03:03 To summarize the problem: Peripherals returned by
scheib 2016/10/14 17:16:14 :( I'm a tad confused on if we have the UUIDs to
+ NSArray* connectedServices = @[ genericAccessServiceUUID ];
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wpartial-availability"
+ // Can remove ignore -Wpartial-availability when 10.8 will not be supported
+ // anymore.
+ // TODO(crbug.com/653056)
+ NSArray* peripherals = [low_energy_central_manager_
+ retrieveConnectedPeripheralsWithServices:connectedServices];
+#pragma clang diagnostic pop
+ for (CBPeripheral* peripheral in peripherals) {
+ LowEnergyDeviceUpdated(peripheral, nil /* advertisementData */,
+ 0 /* rssi */);
+ }
+}
+
BluetoothAdapter::UUIDList BluetoothAdapterMac::GetUUIDs() const {
NOTIMPLEMENTED();
return UUIDList();
@@ -513,40 +534,42 @@ void BluetoothAdapterMac::LowEnergyDeviceUpdated(
DCHECK(device_mac);
- // Get Advertised UUIDs
- BluetoothDevice::UUIDList advertised_uuids;
- NSArray* service_uuids =
- [advertisement_data objectForKey:CBAdvertisementDataServiceUUIDsKey];
- for (CBUUID* uuid in service_uuids) {
- advertised_uuids.push_back(BluetoothUUID([[uuid UUIDString] UTF8String]));
- }
- NSArray* overflow_service_uuids = [advertisement_data
- objectForKey:CBAdvertisementDataOverflowServiceUUIDsKey];
- for (CBUUID* uuid in overflow_service_uuids) {
- advertised_uuids.push_back(BluetoothUUID([[uuid UUIDString] UTF8String]));
- }
+ if (advertisement_data) {
+ // Get Advertised UUIDs
+ BluetoothDevice::UUIDList advertised_uuids;
+ NSArray* service_uuids =
+ [advertisement_data objectForKey:CBAdvertisementDataServiceUUIDsKey];
+ for (CBUUID* uuid in service_uuids) {
+ advertised_uuids.push_back(BluetoothUUID([[uuid UUIDString] UTF8String]));
+ }
+ NSArray* overflow_service_uuids = [advertisement_data
+ objectForKey:CBAdvertisementDataOverflowServiceUUIDsKey];
+ for (CBUUID* uuid in overflow_service_uuids) {
+ advertised_uuids.push_back(BluetoothUUID([[uuid UUIDString] UTF8String]));
+ }
- // Get Service Data.
- BluetoothDevice::ServiceDataMap service_data_map;
- NSDictionary* service_data =
- [advertisement_data objectForKey:CBAdvertisementDataServiceDataKey];
- for (CBUUID* uuid in service_data) {
- NSData* data = [service_data objectForKey:uuid];
- const uint8_t* bytes = static_cast<const uint8_t*>([data bytes]);
- size_t length = [data length];
- service_data_map.emplace(BluetoothUUID([[uuid UUIDString] UTF8String]),
- std::vector<uint8_t>(bytes, bytes + length));
- }
+ // Get Service Data.
+ BluetoothDevice::ServiceDataMap service_data_map;
+ NSDictionary* service_data =
+ [advertisement_data objectForKey:CBAdvertisementDataServiceDataKey];
+ for (CBUUID* uuid in service_data) {
+ NSData* data = [service_data objectForKey:uuid];
+ const uint8_t* bytes = static_cast<const uint8_t*>([data bytes]);
+ size_t length = [data length];
+ service_data_map.emplace(BluetoothUUID([[uuid UUIDString] UTF8String]),
+ std::vector<uint8_t>(bytes, bytes + length));
+ }
- // Get Tx Power.
- NSNumber* tx_power =
- [advertisement_data objectForKey:CBAdvertisementDataTxPowerLevelKey];
- int8_t clamped_tx_power = BluetoothDevice::ClampPower([tx_power intValue]);
+ // Get Tx Power.
+ NSNumber* tx_power =
+ [advertisement_data objectForKey:CBAdvertisementDataTxPowerLevelKey];
+ int8_t clamped_tx_power = BluetoothDevice::ClampPower([tx_power intValue]);
- device_mac->UpdateAdvertisementData(
- BluetoothDevice::ClampPower(rssi), std::move(advertised_uuids),
- std::move(service_data_map),
- tx_power == nil ? nullptr : &clamped_tx_power);
+ device_mac->UpdateAdvertisementData(
+ BluetoothDevice::ClampPower(rssi), std::move(advertised_uuids),
+ std::move(service_data_map),
+ tx_power == nil ? nullptr : &clamped_tx_power);
+ }
if (is_new_device) {
std::string device_address =
« no previous file with comments | « device/bluetooth/bluetooth_adapter_mac.h ('k') | device/bluetooth/bluetooth_adapter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698