CoreBluetoothを介してiPhone4sをMBAに接続することは可能ですか?
-
27-10-2019 - |
質問
Bluetooth経由でiOSとOSX間でデータを送信/受信しようとしています。
GameKitはOSXをサポートしていないため、他のオプションを使用する必要があります。 iPhone4sと最新のMac Book AirはBluetooth 4.0をサポートしているため、これらのデバイス間の接続を確立することが可能だと思います。
しかし、以下の私のサンプルコードは機能せず、あなたの助けが必要です。 CBCentralManagerを作成して、デバイスをスキャンし始め(2つのiPhone4と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...
}
私のコードの何が問題になっていますか?私は何かが足りませんか?
解決
いいえ、CoreBluetoothは、このBluetoothプロファイルを使用して2つの低エネルギー「ホスト」デバイスを一緒に接続することはできません。
他のヒント
iOS 5.xの場合、できません。しかし、iOS 6.x(特にCbperipheralManager)でCoreBluetoothフレームワークが増強されているため、2つのBLEデバイス間でデータを転送することが可能です。
Appleは最新情報を公開しました サンプルコード.
ダーモットが私たちに正しい完全な答えを与えてくれたとは思わない。
これを確認する必要があります Appleテクニカルノート, 、それはあなたが使用できることを明確に説明しています Bluetooth le aka corebluetooth api MBPを介してaをプラグインする必要があります Bluetooth le USBアダプター
iOS 7.0およびOS X Mavericksの時点で、これが可能だと思います。両方のオペレーティングシステムの最新のCoreBluetoothドキュメントを確認してください。