【发布时间】:2014-03-08 20:48:02
【问题描述】:
我在我的应用程序中使用核心蓝牙框架。
我知道如何扫描外围设备并从中获取值。(如心率监视器)
但我想要的是检索周围支持 BLE 4.0 和蓝牙的 iPhone 设备列表。
我参考了下面的链接..
Uses CoreBluetooth For Getting Peripherals not the Devices List
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI {
// I'm not sure how to make this work
NSLog (@"Discovered peripheral: %@", [peripheral name]);
[self.list addObject:peripheral.name]; // add peripheral name to foundarray
NSLog (@"UUID peripheral: %@", [peripheral UUID]);
NSLog (@"peripheral services before connected: %@", [peripheral services]);
NSLog(@"adversting data %@",[NSString stringWithFormat:@"%@",[advertisementData description]]);
NSLog(@"foundArray is %@", self.list);
}
- (void)centralManagerDidUpdateState:(CBCentralManager *)central {
NSLog(@"Central manager's state is updated to: %@", central);
if(central.state == CBCentralManagerStatePoweredOn)
{
//okay your good to go and can now scan
}
else
{
//Unable to use CentralManager methods so print out the central.state and find out why
}
}
我不知道苹果是否提供这个..
任何建议或想法将不胜感激..
提前致谢..
【问题讨论】:
-
BLE 从 iPhone 4S 及更高版本、iPad 3 及更高版本开始支持。您不会通过代码获得列表。无论如何,看到 CBCentralManager 状态应该会告诉你设备是否支持 BLE (
CBCentralManagerStateUnsupported)。
标签: ios objective-c core-bluetooth