Index: device/bluetooth/bluetooth_low_energy_device_mac.mm |
diff --git a/device/bluetooth/bluetooth_low_energy_device_mac.mm b/device/bluetooth/bluetooth_low_energy_device_mac.mm |
index b8c47f4552fecb6d30312d02bb47c422c36274ea..f53a67793d0a76f755f0c03ad9161bcb10eca84c 100644 |
--- a/device/bluetooth/bluetooth_low_energy_device_mac.mm |
+++ b/device/bluetooth/bluetooth_low_energy_device_mac.mm |
@@ -258,10 +258,48 @@ void BluetoothLowEnergyDeviceMac::DidDiscoverPrimaryServices(NSError* error) { |
adapter_->NotifyGattServiceAdded(gatt_service); |
} |
} |
- // TODO(http://crbug.com/609064): Services are fully discovered once all |
- // characteristics have been found. |
- SetGattServicesDiscoveryComplete(true); |
- adapter_->NotifyGattServicesDiscovered(this); |
+ for (GattServiceMap::const_iterator it = gatt_services_.begin(); |
+ it != gatt_services_.end(); ++it) { |
+ device::BluetoothRemoteGattService* gatt_service = it->second; |
+ device::BluetoothRemoteGattServiceMac* gatt_service_mac = |
+ static_cast<BluetoothRemoteGattServiceMac*>(gatt_service); |
+ [GetPeripheral() discoverCharacteristics:nil |
+ forService:gatt_service_mac->GetService()]; |
+ } |
+} |
+ |
+void BluetoothLowEnergyDeviceMac::DidDiscoverCharacteristics( |
+ CBService* cb_service, |
+ NSError* error) { |
+ if (error) { |
+ // TODO(http://crbug.com/609320): Need to pass the error. |
+ // TODO(http://crbug.com/609844): Decide what to do if we fail to discover |
+ // a device services. |
+ VLOG(1) << "Can't discover characteristics: " |
+ << error.localizedDescription.UTF8String << " (" << error.domain |
+ << ": " << error.code << ")"; |
+ return; |
+ } |
+ BluetoothRemoteGattServiceMac* gatt_service = |
+ GetBluetoothRemoteGattService(cb_service); |
+ DCHECK(gatt_service); |
+ gatt_service->DidDiscoverCharacteristics(); |
+ // Does all services have been discovered? |
scheib
2016/06/10 21:59:30
blank line, then
"Notify when all services have be
jlebel
2016/06/10 23:02:45
Done.
|
+ bool discovery_complete = true; |
+ for (GattServiceMap::const_iterator it = gatt_services_.begin(); |
+ it != gatt_services_.end(); ++it) { |
+ device::BluetoothRemoteGattService* gatt_service = it->second; |
+ device::BluetoothRemoteGattServiceMac* gatt_service_mac = |
+ static_cast<BluetoothRemoteGattServiceMac*>(gatt_service); |
+ discovery_complete = gatt_service_mac->IsDiscoveryComplete(); |
+ if (!discovery_complete) { |
+ break; |
+ } |
+ } |
+ if (discovery_complete) { |
+ SetGattServicesDiscoveryComplete(true); |
+ adapter_->NotifyGattServicesDiscovered(this); |
+ } |
} |
void BluetoothLowEnergyDeviceMac::DidModifyServices( |