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

Unified Diff: device/bluetooth/bluetooth_adapter_mac.mm

Issue 1538173003: Implementing GATT connection/disconnect on OS X. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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 1d51e702226fe5ba1ea92833b8c2b1b6705e746d..a4680b0a57f84669559a556a4fbc330e3436bf0e 100644
--- a/device/bluetooth/bluetooth_adapter_mac.mm
+++ b/device/bluetooth/bluetooth_adapter_mac.mm
@@ -536,4 +536,31 @@ void BluetoothAdapterMac::AddPairedDevices() {
}
}
+void BluetoothAdapterMac::CreateGattConnection(
+ BluetoothLowEnergyDeviceMac* deviceMac) {
+ [low_energy_central_manager_ connectPeripheral:deviceMac->peripheral_
+ options:nil];
+}
+
+void BluetoothAdapterMac::DidConnectPeripheral(CBPeripheral* peripheral) {
+ std::string device_address =
+ BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(peripheral);
+ // Try to find device from |devices_| with key |device_address|,
+ // if has no entry in the map, disconnect the peripheral.
+ DevicesMap::const_iterator iter = devices_.find(device_address);
+ if (iter == devices_.end()) {
+ [low_energy_central_manager_ cancelPeripheralConnection:peripheral];
+ return;
+ }
+ BluetoothLowEnergyDeviceMac* device_mac =
+ static_cast<BluetoothLowEnergyDeviceMac*>(iter->second);
+ device_mac->GattConnected();
+}
+
+void BluetoothAdapterMac::DisconnectGatt(
+ BluetoothLowEnergyDeviceMac* deviceMac) {
+ [low_energy_central_manager_
+ cancelPeripheralConnection:deviceMac->peripheral_];
+}
+
} // namespace device

Powered by Google App Engine
This is Rietveld 408576698