我想知道 iPhone 4s 可以连接两个蓝牙 4.0 设备吗?
我使用 Corebluetooth.framework 连接我的蓝牙4.0 设备,现在我有疑问,如果我们有两个设备,我可以同时连接两个设备吗?
非常感谢!
最佳答案
是的。
例如,请查看 Apple 的心率监测器样本 http://developer.apple.com/library/mac/#samplecode/HeartRateMonitor/Introduction/Intro.html%23//apple_ref/doc/uid/DTS40011322 。在 HeartRateMonitorAppDelegate.m 中,您会发现以下收集多个设备的方法:
- (void) centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)aPeripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
{
NSMutableArray *peripherals = [self mutableArrayValueForKey:@"heartRateMonitors"];
if( ![self.heartRateMonitors containsObject:aPeripheral] )
[peripherals addObject:aPeripheral];
/* Retreive already known devices */
if(autoConnect)
{
[manager retrievePeripherals:[NSArray arrayWithObject:(id)aPeripheral.UUID]];
}
}
在此特定示例中,应用程序仅与其中一个心率监测器连接,但您可以查看代码并轻松了解它如何连接到两个心率监测器(假设您愿意更新 UI 以显示两个心率) .
关于ios - iPhone 4s可以连接两个蓝牙4.0设备吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11772746/