【发布时间】:2016-05-06 19:07:17
【问题描述】:
我目前正在使用 CoreBluetooth 扫描我之前使用特定标识符连接的外围设备,然后仅连接到外围设备。我知道我可以通过使用服务扫描外围设备来做到这一点,然后与标识符进行比较,如果条件满足,然后按照以下代码连接到外围设备
func discoverDevices(){
centralManager.scanForPeripheralsWithServices([CBUUID(string: "1234")], options: nil)
}
func centralManager(central: CBCentralManager, didDiscoverPeripheral peripheral: CBPeripheral, advertisementData: [String : AnyObject], RSSI: NSNumber) {
if peripheral.identifier == NSUUID(UUIDString: "AD4612DG87-7512-683D-79RT-234DFG987RUI{
self.centralManager.connectPeripheral(peripheral, options: nil)
}
}
有没有其他适当的方法可以直接扫描特定的外围设备?谢谢
【问题讨论】:
标签: swift core-bluetooth identifier peripherals