简体   繁体   中英

Is it possible to connect iPhone4S to MBA via CoreBluetooth?

I'm trying to send/receive data between iOS and OSX via Bluetooth.

Because GameKit doesn't support OSX, I need to use other options. iPhone4S and latest Mac Book Air support Bluetooth 4.0, so I think it is possible to establish a connection between these devices.

But my sample codes below doesn't work and need your help. Though I just create CBCentralManager and start to scan devices(having two iPhone4S and MBA at hand), – centralManager:didDiscoverPeripheral:advertisementData:RSSI: is never called...

- (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...
}

What's wrong with my code? Am I missing something?

For iOS 5.x you cannot. But as CoreBluetooth framework has been augmented in iOS 6.x (, especially the CBPeripheralManager), transferring data between two BLE devices is made possible.

Apple has just published the latest sample code .

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

I don't think Dermot gave us a correct full answer.

You should check on this Apple technical note , it clearly explains that you can use Bluetooth LE aka CoreBluetooth API through your MBP but you have to plug a Bluetooth LE USB adapter

As of iOS 7.0 and OS X Mavericks, I believe this is possible. Check the latest CoreBluetooth documentation for both operating systems.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM