【问题标题】:How to connect two iPhone using corebluetooth?如何使用corebluetooth连接两部iPhone?
【发布时间】:2012-08-22 17:52:58
【问题描述】:
我可以使用核心蓝牙框架连接两个idevice吗?我正在使用以下代码sn-p:
cBCM = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
[cBCM scanForPeripheralsWithServices:nil options:nil];
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error {
}
但代表们根本没有开火。有什么解决办法吗?
【问题讨论】:
标签:
iphone
ios5
ios6
core-bluetooth
【解决方案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];
}