2012-01-12 44 views
4

我试图通过蓝牙在iOS和OSX之间发送/接收数据。是否可以通过CoreBluetooth将iPhone4S连接到MBA?

由于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... 
} 

这有什么错我的代码?我错过了什么吗?

回答

1

不,恐怕CoreBluetooth仅适用于低能耗设备(手表,健康监测器等)。 使用此蓝牙配置文件无法将两个低能量“主机”设备连接在一起。

0

我不认为德莫特给了我们一个正确的完整答案。

您应该检查这个Apple technical note,它清楚地解释说,你可以通过你的MBP使用蓝牙LE又名CoreBluetooth API,但你必须插入一个蓝牙LE USB适配器

1

对于iOS 5.x的你不能。但是随着iOS 6.x(尤其是CBPeripheralManager)的CoreBluetooth框架的增强,两个BLE设备之间的数据传输成为可能。

苹果刚刚发布了最新的sample code

0

从iOS 7.0和OS X Mavericks开始,我相信这是可能的。查看两种操作系统的最新CoreBluetooth文档。

相关问题