|Dr. Michael Kroll's Mobile Computing Forum
|Enabling background scanning
|Page 1 of 1|
|Author:||longway77 [ Fri Jan 11, 2013 1:59 am ]|
|Post subject:||Enabling background scanning|
I'm just trying to figure out how to enable scanning for peripherals in background, so far i did the following:
- I added core-bluetooth in the UIBackgroundModes in the .plist
- In my App delegate, I'm listening for state changes with applicationDidEnterBackground and I'm calling my CBCentralManager with the arguments:
NSArray* serviceUUIDs = [NSArray arrayWithObject:[CBUUID UUIDWithString:@"67a45dd0-4(...)"]];
[mgr scanForPeripheralsWithServices:serviceUUIDs options:nil];
I have a delegate set up which should just NSlog something to my debugger, but I see no result.
Meanwhile I have my BLED112 configured with an advertising service in the gatt.xml:
<service uuid="67a45dd0-4533-11e2-bcfd-0800200c9a66" advertise="true">
And I invoked some BGscript which sets the advertising mode:
My iOS app successfully gets my device in the foreground but ignores it while in background. I know there's some difficulties with devices that have already been found, can I somehow force the BLED112 to change the uuid more often? From documentation I get that it should change about every 15min.
Did I set the advertising mode correct? It's so much documentation, I'm a little overwhelmed. I do not actually want my device to be connactable, but I had to because it did not broadcast its service otherwise.
Thanks for any help
Alright, so I got that one fixed without being too sure about what I did. I did a connect and reconnect to every peripheral that was already discovered and I added a local notification instead of an NSLog which shows up in a more or less unpredictable manner if it bothers at all.
Now if I could just get my dongle not to accept connections but to broadcast its services cause for unknown reasons those connections seem to freeze the advertising sometimes. Despite me setting the mode again in the disconnect event...
|Author:||mkroll [ Wed Jan 16, 2013 12:30 pm ]|
|Post subject:||Re: Enabling background scanning|
I was playing around with this kind of problems some months ago.
I was unable to discovery anything in the background, even when I scan for devices advertising a particular service.
I have similar problems with a BLE112 powered device to be not connectable.
You can use the BLE112's internal whitelist feature but it is unusable for iOS since iOS devices are using random UUIDs to connect to peripherals.
I managed it another way in firmware now to restrict devices to connect if they are not allowed.
Yes, it seems that the app can connect to a known peripheral in the background. But I was bot yet able to get a Local Notification or an NSLog printed if a new device is discovered in the Background.
Have you tried iOS6B4 to discover in the background yet? Any differences?
|Page 1 of 1||All times are UTC + 1 hour [ DST ]|
|Powered by phpBB® Forum Software © phpBB Group