如何使用corebluetooth连接两个iPhone?

时间:2012-08-28 08:40:04

标签: iphone ios5 ios6 core-bluetooth

我可以使用核心蓝牙框架连接两个idevice吗?我正在使用以下代码片段:

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

[cBCM scanForPeripheralsWithServices:nil options:nil];


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

}

但代表们根本没有解雇。任何解决方案?

1 个答案:

答案 0 :(得分:1)

您应该尝试didDiscoverCharacteristicsForService,而不是尝试触发didDiscoverPeripheral,而didDiscoverChar...会触发所有的传播。只有在外围设备属性中找到特定特征时,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]; } 触发时,您可以尝试按

打印出来
{{1}}