How do I see bluetooth available devices in objective c?

749 views Asked by At

I wrote code in objective c to see available list of nearest present bluetooth device. But there are not show any devices.I shows my code bellow to see and tell where am I wrong. I use iPhone se for testing which install iOS 11.1 and bluetooth version 4.2. My output is:

CoreBluetooth BLE hardware is powered off

refreshPreferences: HangTracerEnabled: 0

refreshPreferences: HangTracerDuration: 500

refreshPreferences: ActivationLoggingEnabled: 0

ActivationLoggingTaskedOffByDA:0

CoreBluetooth BLE hardware is powered on and ready

But after that on screen their is not any device shows My code is follows to call scan peripheral:

- (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;
    }
}

so where did I wrong or any setting will do in iPhone?

0

There are 0 answers