我在列出所有设备时遇到问题
IOBluetooth
框架。有没有一种方法不仅可以获得经典的设备,还可以获得BLE设备?
我的代码是
let ioBluetoothManager = IOBluetoothDeviceInquiry(delegate: self)
var ioDevices = [IOBluetoothDevice]()
...
ioBluetoothManager?.start()
...
func deviceInquiryStarted(_ sender: IOBluetoothDeviceInquiry!) {
print("started")
}
///
//IOBluetoothDeviceInquiryDelegate
///
func deviceInquiryDeviceFound(_ sender: IOBluetoothDeviceInquiry!, device: IOBluetoothDevice!) {
print("found device")
ioDevices.append(device)
scrubber.reloadData()
tableView.reloadData()
}
func deviceInquiryComplete(_ sender: IOBluetoothDeviceInquiry!, error: IOReturn, aborted: Bool) {
print("completed")
}
我知道我可以用corebuttouth来实现这一点,但我也需要过滤设备以符合特定的标准。
从
this
回答我知道我能做到,但这个回答缺乏细节。现在我只想看看经典蓝牙设备的列表。
有人能帮忙吗?
更新:
现在我找到了
.searchType
方法
kIOBluetoothDeviceSearchClassic
和
kIOBluetoothDeviceSearchLE
常量。在viewdidload中,我执行了以下操作:
ioBlutoothmanager.searchType = IOBluetoothDeviceSearchLE.rawValue
但它仍然只能找到经典的设备。
更新:
一直以来,它都工作得很正常,我没想到。它过滤了我不需要的所有设备,我也没有飞机来检查。