سؤال

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?

هل كانت مفيدة؟

المحلول

No, im afraid CoreBluetooth is only for Low Energy devices (watches, health monitors etc...) It is not possible to connect two Low Energy "Host" devices together using this Bluetooth Profile.

نصائح أخرى

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.

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top