View unanswered posts | View active topics It is currently Sat Mar 28, 2020 11:24 am

Reply to topic  [ 2 posts ] 
Enabling background scanning 
Author Message

Joined: Fri Oct 19, 2012 2:01 am
Posts: 2

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:
call gap_set_mode(gap_general_discoverable,gap_directed_connectable)

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...

Fri Jan 11, 2013 1:59 am
Site Admin

Joined: Thu Aug 02, 2012 11:36 am
Posts: 166
Hello Marius,
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?


Wed Jan 16, 2013 12:30 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software for PTF.