Resolved CoreBluetooth not finding devices!

Discussion in 'iOS Programming' started by DennisBlah, Feb 25, 2014.

  1. DennisBlah, Feb 25, 2014
    Last edited: Feb 27, 2014

    DennisBlah macrumors 6502

    DennisBlah

    Joined:
    Dec 5, 2013
    Location:
    The Netherlands
    #1
    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!
     
  2. DennisBlah thread starter macrumors 6502

    DennisBlah

    Joined:
    Dec 5, 2013
    Location:
    The Netherlands
    #2
    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.
     
  3. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #3
    Mod Note: We actually recommend that you tag your thread as Resolved instead. Here's the sticky from this forum where we explain how you can do that: Forum Feature: Resolved Thread Prefix
     
  4. DennisBlah thread starter macrumors 6502

    DennisBlah

    Joined:
    Dec 5, 2013
    Location:
    The Netherlands

Share This Page