iosios8core-bluetoothbtle

iOS8 and BTLE | CBCentralManager unable to find peripherals


I have an iOS app that is connecting to a device (arduino) using a BTLE. Everything is working fine on my iPad iOS 7. After upgrading to iOS 8, the CBCentralManager is not finding any peripherals.

- (void)startScanningForSupportedUUIDs
{
   [self.centralManager scanForPeripheralsWithServices:nil options:nil];

}

I don't know what can be the problem.


Solution

  • I have the solution, for some reason in iOS 8 there is some delay after instantiate your CBManager. You need to start to scan when the CBCentralManager is on, in this method:

    -(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");
            NSArray         *uuidArray  = [NSArray arrayWithObjects:[CBUUID UUIDWithString:TRANSFER_SERVICE_UUID], nil];
            NSDictionary    *options    = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:CBCentralManagerScanOptionAllowDuplicatesKey];
            [centralManager scanForPeripheralsWithServices:uuidArray options:options];
        }
            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;
    }