我想在iPhone和医疗设备之间建立连接,提供有关心脏的信息。我很快就会得到有关蓝牙协议的信息。目前我无法使用苹果的蓝牙库。 CoreBluetooth或IOBluetooth是否更适合连接到非MFI设备?
以下是我发现的一些代码(link)它应该找到所有设备,但它不起作用。我尝试了不同的方法来设置。
import IOBluetooth
import XCPlayground
class BlueDelegate : IOBluetoothDeviceInquiryDelegate{
func deviceInquiryComplete(sender: IOBluetoothDeviceInquiry, error: IOReturn, aborted: Bool) {
aborted
println("called")
var devices = sender.foundDevices()
for device : AnyObject in devices {
if let thingy = device as? IOBluetoothDevice {
thingy.getAddress()
}
}
}
}
var delegate = BlueDelegate()
var inquiry = IOBluetoothDeviceInquiry(delegate: delegate)
inquiry.start()
XCPSetExecutionShouldContinueIndefinitely()
我也尝试使用CoreBluetooth,但它也没有调用委托方法。