我在目标 c 中编写了代码,以查看最近存在的蓝牙设备的可用列表。但是没有显示任何设备。我在下面显示我的代码以查看并告诉我哪里错了。我使用 iPhone se 测试安装 iOS 11.1 和蓝牙版本 4.2。我的输出是:
CoreBluetooth BLE 硬件已断电
refreshPreferences:HangTracerEnabled:0
refreshPreferences:HangTracerDuration:500
refreshPreferences:ActivationLoggingEnabled:0
ActivationLoggingTaskedOffByDA:0
CoreBluetooth BLE 硬件已开机并准备就绪
但之后在屏幕上他们不是任何设备显示我的代码如下调用扫描外围设备:
- (void)centralManagerDidUpdateState:(CBCentralManager *)central
{
switch (central.state)
{
case CBCentralManagerStatePoweredOff:
NSLog(@"CoreBluetooth BLE hardware is powered off");
break;
case CBCentralManagerStatePoweredOn:
NSLog(@"CoreBluetooth BLE hardware is powered on and ready");
[self.centralManager scanForPeripheralsWithServices:nil options:nil];
break;
case CBCentralManagerStateResetting:
NSLog(@"CoreBluetooth BLE hardware is resetting");
break;
case CBCentralManagerStateUnauthorized:
NSLog(@"CoreBluetooth BLE state is unauthorized");
break;
case CBCentralManagerStateUnknown:
NSLog(@"CoreBluetooth BLE state is unknown");
break;
case CBCentralManagerStateUnsupported:
NSLog(@"CoreBluetooth BLE hardware is unsupported on this platform");
break;
default:
break;
}
}
那么我在哪里做错了,或者任何设置都可以在 iPhone 中执行?