我是新手。如果我用蓝牙连接另一台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)
}