如何使用corebluetooth连接两个iPhone?
问题描述:
可以通过蓝牙核心框架,我连接两个的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 {
}
但代表们不触发的。任何解决方案
答
而不是试图发射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];
}
尝试打印出它的名字