Swift - 如何检查蓝牙连接两个iPad

时间:2017-01-17 12:52:02

标签: ios swift ipad bluetooth

我是新手。如果我用蓝牙连接另一台iPad,如何显示连接状态。我希望标签显示连接状态。

func centralManagerDidUpdateState(_ central: CBCentralManager) {
    guard central.state == .poweredOn else {
        return
    }
    centralManager.scanForPeripherals(withServices: nil, options: nil)
}
func centralManager(_ central: CBCentralManager, didDiscover peripheral: CBPeripheral, advertisementData: [String : Any], rssi RSSI: NSNumber) {
    print("Find the device: \(peripheral.name)")
    guard peripheral.name == "My Bluetooth Device" || peripheral.name == "iPhone" else {
        return
    }      
    central.stopScan()
    uuid = peripheral.identifier
    connectPeripheral = peripheral
    connectPeripheral.delegate = self
    central.connect(peripheral, options: nil)
}

0 个答案:

没有答案