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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "device/bluetooth/bluetooth_adapter_mac.h" 5 #include "device/bluetooth/bluetooth_adapter_mac.h"
6 6
7 #import <IOBluetooth/objc/IOBluetoothDevice.h> 7 #import <IOBluetooth/objc/IOBluetoothDevice.h>
8 #import <IOBluetooth/objc/IOBluetoothHostController.h> 8 #import <IOBluetooth/objc/IOBluetoothHostController.h>
9 9
10 #include <string> 10 #include <string>
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 } 529 }
530 } 530 }
531 531
532 void BluetoothAdapterMac::AddPairedDevices() { 532 void BluetoothAdapterMac::AddPairedDevices() {
533 // Add any new paired devices. 533 // Add any new paired devices.
534 for (IOBluetoothDevice* device in [IOBluetoothDevice pairedDevices]) { 534 for (IOBluetoothDevice* device in [IOBluetoothDevice pairedDevices]) {
535 ClassicDeviceAdded(device); 535 ClassicDeviceAdded(device);
536 } 536 }
537 } 537 }
538 538
539 void BluetoothAdapterMac::CreateGattConnection(
540 BluetoothLowEnergyDeviceMac* deviceMac) {
541 [low_energy_central_manager_ connectPeripheral:deviceMac->peripheral_
542 options:nil];
543 }
544
545 void BluetoothAdapterMac::DidConnectPeripheral(CBPeripheral* peripheral) {
546 std::string device_address =
547 BluetoothLowEnergyDeviceMac::GetPeripheralHashAddress(peripheral);
548 // Try to find device from |devices_| with key |device_address|,
549 // if has no entry in the map, disconnect the peripheral.
550 DevicesMap::const_iterator iter = devices_.find(device_address);
551 if (iter == devices_.end()) {
552 [low_energy_central_manager_ cancelPeripheralConnection:peripheral];
553 return;
554 }
555 BluetoothLowEnergyDeviceMac* device_mac =
556 static_cast<BluetoothLowEnergyDeviceMac*>(iter->second);
557 device_mac->GattConnected();
558 }
559
560 void BluetoothAdapterMac::DisconnectGatt(
561 BluetoothLowEnergyDeviceMac* deviceMac) {
562 [low_energy_central_manager_
563 cancelPeripheralConnection:deviceMac->peripheral_];
564 }
565
539 } // namespace device 566 } // namespace device
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698