1

我可以使用核心蓝牙框架连接两个 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尝试使用didDiscoverPeripheralwhich 将在所有外围设备上开火。仅当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];
}
于 2012-11-30T13:14:59.727 回答