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

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: Removing chromium.gyp_env Created 4 years, 11 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 72554ed21b458129818ec0f12243a6be8a58cd7a..ece07d663e19524dc59fbabb5cca40d8828a80a1 100644
--- a/device/bluetooth/bluetooth_adapter_mac.mm
+++ b/device/bluetooth/bluetooth_adapter_mac.mm
@@ -232,6 +232,10 @@ void BluetoothAdapterMac::SetCentralManagerForTesting(
low_energy_central_manager_.get());
}
+CBCentralManager* BluetoothAdapterMac::GetCentralManagerForTesting() {
+ return low_energy_central_manager_;
+}
+
void BluetoothAdapterMac::RemovePairingDelegateInternal(
BluetoothDevice::PairingDelegate* pairing_delegate) {
}
@@ -537,4 +541,31 @@ void BluetoothAdapterMac::AddPairedDevices() {
}
}
+void BluetoothAdapterMac::CreateGattConnection(
+ BluetoothLowEnergyDeviceMac* device_mac) {
+ [low_energy_central_manager_ connectPeripheral:device_mac->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* device_mac) {
+ [low_energy_central_manager_
+ cancelPeripheralConnection:device_mac->peripheral_];
+}
+
} // namespace device

Powered by Google App Engine
This is Rietveld 408576698