iOS BLE background scanning -


i'm having trouble understanding how scanning performed when ios application in bacground. have simple test application scans devices , outputs results console. i've added bluetooth-central required background modes in info.plist should fine , i'm scanning device 1 specified service,

nsarray *cbuuidarray = [nsarray arraywithobjects:[cbuuid uuidwithstring:@"uuidfromuuidgen"],nil]; [self.centralmanager scanforperipheralswithservices:cbuuidarray options:@{ cbcentralmanagerscanoptionallowduplicateskey : @yes }]; 

when application in foreground i'm having 1 (or none) ble device connected power source ios detects , shows results quite frequently. when go background there no more results of first device expected since cbcentralmanagerscanoptionallowduplicateskey set no.

at point i'm powering second ble device , eagerly wait show in results. after 10 minutes of waiting nothing shows up. application not terminated since last notification comes applicationdidenterbackground , applicationwillterminate never called while working on task.

in quite accidental way discovered if app running , still scanning in background , ble scanning application (i'm using excelent blexplr) in foreground , starts scanning, application finaly receiving results in same time foreground appliaction. makes sense since advertising packets handled system , dispatched applications why doesn't application receive on it's own?

did have similar experience or knows can caused by? i've read apple resources regarding backgrounding , bluetooth no hints regarding issue. i'm working on ios 4s ios 5.1.1. main viewcontroller cbcentralmanagerdelegate delegate looks 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 

there's nothing more going on in application besides navigationcontroller initialization in application delegate.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -