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

Unified Diff: device/bluetooth/bluetooth_low_energy_device_mac.mm

Issue 1950033002: bluetooth: mac: Initial BluetoothRemoteGattCharacteristicMac implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@servicescan_cleanup
Patch Set: Fixing the build Created 4 years, 6 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_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..04c400a781bc86a8df6c9076b44e533b36c1cd95 100644
--- a/device/bluetooth/bluetooth_low_energy_device_mac.mm
+++ b/device/bluetooth/bluetooth_low_energy_device_mac.mm
@@ -239,7 +239,7 @@ void BluetoothLowEnergyDeviceMac::DisconnectGatt() {
void BluetoothLowEnergyDeviceMac::DidDiscoverPrimaryServices(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
+ // TODO(http://crbug.com/609844): Decide what to do if discover failed
// a device services.
VLOG(1) << "Can't discover primary services: "
<< error.localizedDescription.UTF8String << " (" << error.domain
@@ -258,10 +258,44 @@ 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);
+ gatt_service_mac->DiscoverCharacteristics();
+ }
+}
+
+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 discover failed
+ 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();
+
+ // Notify when all services have been discovered.
+ bool discovery_complete =
+ std::find_if_not(
+ gatt_services_.begin(), gatt_services_.end(),
+ [](std::pair<std::string, BluetoothRemoteGattService*> pair) {
+ BluetoothRemoteGattService* gatt_service = pair.second;
+ return static_cast<BluetoothRemoteGattServiceMac*>(gatt_service)
+ ->IsDiscoveryComplete();
+ }) == gatt_services_.end();
+ if (discovery_complete) {
+ SetGattServicesDiscoveryComplete(true);
+ adapter_->NotifyGattServicesDiscovered(this);
+ }
}
void BluetoothLowEnergyDeviceMac::DidModifyServices(
« no previous file with comments | « device/bluetooth/bluetooth_low_energy_device_mac.h ('k') | device/bluetooth/bluetooth_low_energy_peripheral_delegate.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698