1

コア Bluetooth フレームワークを使用して 2 つの idevice を接続できますか?次のコード スニペットを使用しています。

cBCM = [[CBCentralManager alloc] initWithDelegate:self queue:nil];

[cBCM scanForPeripheralsWithServices:nil options:nil];


- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error {

}

しかし、デリゲートはまったく発砲していません。解決策はありますか?

4

1 に答える 1

1

起動しようとする代わりに、すべてのペリフェラルでdidDiscoverCharacteristicsForService起動する を試す必要があります。didDiscoverPeripheraldidDiscoverChar...、周辺機器のプロパティ内で特定の特性が見つかった場合にのみトリガーされます。

トリガーすると、そのdidDiscover...名前を印刷してみることができます

// Discovered peripheral
- (void) centralManager:(CBCentralManager *)central 
didDiscoverPeripheral:(CBPeripheral *)peripheral 
  advertisementData:(NSDictionary *)advertisementData 
               RSSI:(NSNumber *)RSSI 
{
    // Print out the name parameter of the discovered peripheral
    @NSSlog ("Discovered peripheral: %@", [peripheral name];
}
于 2012-11-30T13:14:59.727 に答える