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