IOS BLE source scan

I'm having trouble understanding how scanning is performed when an iOS application is in the bacground. I have a very simple test application that simply scans devices and displays the results to the console. I added bluetooth-central to the required background modes in Info.plist, so I have to be fine, and I scan the device with one specified service, i.e.

NSArray *cbuuidArray = [NSArray arrayWithObjects:[CBUUID UUIDWithString:@"UUIDFromUUIDGEN"],nil]; [self.centralManager scanForPeripheralsWithServices:cbuuidArray options:@{ CBCentralManagerScanOptionAllowDuplicatesKey : @YES }]; 

When the application is in the foreground, I only have one (or none) BLE device connected to a power source, so iOS detects it and shows the results quite often. When I step into the background, there are no longer the results of the first device that is expected, since CBCentralManagerScanOptionAllowDuplicatesKey set to NO.

At this point, I am launching the second BLE device and am looking forward to displaying it in the results. After 10 minutes of waiting nothing appears. The application is not completed, since my last notification comes from applicationDidEnterBackground and applicationWillTerminate never called while working on the task.

In a completely random way, I found that if my application is running and still scanning in the background, and another BLE scanning application (I use excelent BLExplr ) is in the foreground and starts scanning, my application finally receives the results at the same time as foreground application. This makes sense since the ad packages are processed by the system and sent to the applications, but why does my application receive nothing from it?

Did anyone have a similar experience or did he know that this could be caused? I probably read all of Apple's resources regarding background and bluetooth without any hint of this problem. I am working on iOS 4 with iOS 5.1.1. My main ViewController , which is a delegate of CBCentralManagerDelegate , looks like this.

 @implementation MainViewController - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization self.centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil]; } return self; } #pragma mark - #pragma mark CBCentralManagerDelegate methods - (void)centralManagerDidUpdateState:(CBCentralManager *)central { if( central.state == CBCentralManagerStatePoweredOn ){ NSArray *cbuuidArray = [NSArray arrayWithObjects: [CBUUID UUIDWithString:@"UUID"], nil]; [self.centralManager scanForPeripheralsWithServices:cbuuidArray options:@{ CBCentralManagerScanOptionAllowDuplicatesKey : @YES }]; } } - (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI { NSLog(@"%s / peripheral: %@, adData: %@, RSSI: %@" , __PRETTY_FUNCTION__ , peripheral, advertisementData, RSSI); NSLog(@"Periphal name: %@", peripheral.name); } #pragma mark - #pragma mark CBPeripheralDelegate methods @end 

Nothing else happens in the application, except for the initialization of the NavigationController in the deletion of the application.

+8
ios background bluetooth-lowenergy network-scan
source share

No one has answered this question yet.

See related questions:

23
Core Bluetooth advertises and scans in the background
6
IOS Corebluetooth advertising and scanning in the background
3
How to scan a BLE device in the background without a library?
2
Sometimes a BLE scan response does not include kCBAdvDataLocalName
one
BLE iOS background advertising
0
iOS bluetooth background scan with custom uuid
0
Wake app from background while BLE interacting
0
IOS Developmentpement: BLE background scanning
0
Do not get the full peripheral name BLE
0
iOS - Scan BLE in the background

All Articles