如何在目标c中看到蓝牙可用设备?

时间:2018-03-08 09:27:32

标签: ios objective-c ios11 core-bluetooth xcode9beta6

我在目标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中的任何设置都可以?

0 个答案:

没有答案