[英]Is it possible to connect iPhone4S to MBA via CoreBluetooth?
我正在尝试通过蓝牙在iOS和OSX之间发送/接收数据。
由于GameKit不支持OSX,因此我需要使用其他选项。 iPhone4S和最新的Mac Book Air支持蓝牙4.0,因此我认为可以在这些设备之间建立连接。
但是我下面的示例代码不起作用,需要您的帮助。 尽管我只是创建CBCentralManager并开始扫描设备(手边有两个iPhone4S和MBA),但是–从未调用centralManager:didDiscoverPeripheral:advertisementData:RSSI:...
- (void)start {
self.mgr = [[[CBCentralManager alloc] initWithDelegate:self queue:nil] autorelease];
NSDictionary * opts = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], CBCentralManagerScanOptionAllowDuplicatesKey, nil];
[self.mgr scanForPeripheralsWithServices:nil options:opts];
}
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
{
// not called this delegate method...
}
我的代码有什么问题? 我想念什么吗?
对于iOS 5.x,您不能。 但是随着CoreBluetooth框架在iOS 6.x(尤其是CBPeripheralManager)中得到了增强,使得在两个BLE设备之间传输数据成为可能。
苹果公司刚刚发布了最新的示例代码 。
不,恐怕CoreBluetooth仅适用于低能耗设备(手表,健康监视器等)。无法使用此蓝牙配置文件将两个低能耗“主机”设备连接在一起。
我认为Dermot没有给我们正确的完整答案。
您应该查看此Apple技术说明 ,它清楚地说明您可以通过MBP使用Bluetooth LE aka CoreBluetooth API ,但必须插入Bluetooth LE USB适配器
从iOS 7.0和OS X Mavericks开始,我相信这是可能的。 查看两个操作系统的最新CoreBluetooth文档。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.