2012-08-28 46 views
1

可以通过蓝牙核心框架,我连接两个的iDevice我使用下面的代码片段:如何使用corebluetooth连接两个iPhone?

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

[cBCM scanForPeripheralsWithServices:nil options:nil]; 


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

} 

但代表们不触发的。任何解决方案

回答

1

而不是试图发射didDiscoverCharacteristicsForService你应该尝试didDiscoverPeripheral这将在所有periperals触发。 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]; 
} 
尝试打印出它的名字