Re: Not receiving BLE events in background
Re: Not receiving BLE events in background
- Subject: Re: Not receiving BLE events in background
- From: "m.kroll" <email@hidden>
- Date: Mon, 20 Aug 2012 08:08:03 +0000 (GMT)
Hello Joakim,
what I did so far, running on an iPhone4S with iOS5.1.1 installed:
1. Created an Xcode Project with *-Info.plist settings as follows:
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
<string>bluetooth-le</string>
</array>
<key>UIBackgroundModes</key>
<array>
<string>bluetooth-central</string>
</array>
2. In the method - (void)applicationDidEnterBackground:(UIApplication *)application of my AppDelegate I'm calling:
NSArray *uuidArray = [NSArray arrayWithObjects:[CBUUID UUIDWithString:myUUIDtoScanFor], nil];
NSDictionary *options = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:CBCentralManagerScanOptionAllowDuplicatesKey];
[centralManager scanForPeripheralsWithServices:uuidArray options:options];
where the central is initialized like this:
centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:dispatch_get_main_queue()];
but
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI
is never called.
I reprogrammed my peripherals using a BlueGiga BLE112 module to use a 20ms advertising interval, but I still can't see them in my app.
Is point 2. the problem, that I need to invoke the scan method before?
Any help appreciated.
Kind Regards/Mit freundlichen GrĂ¼ssen,
Dr. Michael Kroll.
---
Blog: http://www.mkroll.mobi
Forum: http://forum.mkroll.mobi
On Aug 17, 2012, at 05:47 PM, Joakim Linde <email@hidden> wrote:
Hi Michael,
Not sure I got all the details of your issue.
Scanning for advertising peripherals is boosted then the app is in the foreground compared to a backgrounded app. A good "rule of thumb" for how long it will take to discover a device when the app is in the background is 55 times the advertising interval of the peripheral. So, if a peripheral is advertising every 20 ms it would be discovered in about 1 second on average. However, it it is only advertising once a second it would take a whole minute for it to be discovered.
Also, please note that you will only be able to discover the device when in the background, not track it. The app will only get the advertising packet the first advertising packet when backgrounded, the rest will be filtered out in order to save power.
Hope this helps.
Thanks,
Joakim
Ah ok thanks!
@Joakim: Could you please confirm, that the background scanning issues I'm dealing with are based on the fact, that I'm trying this on iOS5.1.1 ?
Thank you very much in advance,
Michael.
---
Blog: http://www.mkroll.mobi
Do not post admin requests to the list. They will be ignored.
Bluetooth-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden