iOS CoreBluetooth not finding devices!

DennisBlah

macrumors 6502
Original poster
Dec 5, 2013
485
2
The Netherlands
Hi all!

I'm expanding my testing application for iPhone and iPad's. Now comming to the point to test the Bluetooth adapter.
I'm at the point to scan for devices, however the code doesn't seem to pick up any device :( (I'm trying to find the Apple Bluetooth Headset)

here is what I'm trying to do:
Code:
i imported
<CoreBluetooth/CoreBluetooth.h> and <CoreBluetooth/CBService.h> to my viewcontroller and added
<CBCentralManagerDelegate, CBPeripheralDelegate>
after the interface

in the viewDidLoad:
cBCM = [[CBCentralManager alloc] initWithDelegate:self queue:nil];

added the function:
- (void)centralManagerDidUpdateState:(CBCentralManager *)central {
    cBReady = false;
    switch (central.state) {
        case CBCentralManagerStatePoweredOff:
            NSLog(@"CoreBluetooth BLE hardware is powered off");
            break;
        case CBCentralManagerStatePoweredOn:
            NSLog(@"CoreBluetooth BLE hardware is powered on and ready");
            cBReady = true;
            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;
    }
}

For this it works fine, it sees if the bluetooth is on or off. But now the scanning part:
I added an button with the call:
Code:
-(IBAction)startScan {
    [cBCM scanForPeripheralsWithServices:nil options:nil];
}

and the function

-  (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI {
    
    
    NSLog([NSString stringWithFormat:@"%@",[advertisementData description]]);
}
But it didnt find anything.
I also tried to use an loop through an array of UUID's

"1811", @"180F", @"1810", @"1805", @"1818", @"1816", @"180A", @"1800", @"1801", @"1808", @"1809", @"180D", @"1812", @"1802", @"1803", @"1819", @"1807", @"180E", @"1806", @"1814", @"1813", @"1804"


But the code wont find anything. Anyone have any idea why? And how to fix this?

Cheers!
 
Last edited:

DennisBlah

macrumors 6502
Original poster
Dec 5, 2013
485
2
The Netherlands
Solved

The reason that CoreBluetooth does not find the device is that CoreBluetooth is based on BT4.0 devices. Which will not recognize regular BT3 or BLE devices.

Using the BluetoothManager.framework with custom headers.

Close thread.