2
votes

I am currently working on one of the IOS BLE app and found some issues while advertising from Peripheral,

1) When app goes to background it doesent seems to be discovered by my Central app(I have even tried with LightBlue app which works well in foreground), from apple docs I have found that,

All service UUIDs contained in the value of the CBAdvertisementDataServiceUUIDsKey advertisement key are placed in a special “overflow” area; they can be discovered only by an iOS device that is explicitly scanning for them.

Does that means Central must be scanning particular Service UUIDs only? I was trying by passing nil as I need to discover all nearby peripherals.

2) Is there any way to pass custom advertisement data which can be read by an central without connecting the peripheral? Or Can I pass custom UUID instead of default one? I have tried different ways but not able to found which is helpful to pass custom data, i want to pass some user specific details from peripheral.

I heard that Mingleton is also based on BLE and it seems like that their app is working well in background, any idea what technique they have used?

2
The critical thing you must keep in mind is that BLE service UUIDs and "iBeacon" region UUIDs have absolutely nothing to do with each other.Chris Stratton

2 Answers

2
votes

The key is that the Bluetooth Low Energy stack of iOS allows background advertising when acting as a Peripheral. However, when advertising in background it is only possible to discover UUIDs that you know previously (this is mentioned in the BLE documentation of apple but it was also tested by us). Using the following call:

NSDictionary *scanOptions = @{CBCentralManagerScanOptionAllowDuplicatesKey:@(YES)}; [centralManager scanForPeripheralsWithServices:nil options:scanOptions];

Will find all the Peripherals around that are advertising in the foreground but none that is advertising in the background. So this is not a valid alternative.

The solution is to discover a service UUIDs that are already known. Therefore Centrals scan for other Peripherals with a General UUID already known by all the Devices. When they find the Peripheral, they connect to that peripheral and obtain a Specific UUID for that peripheral using services and characteristics. It is important to notice that you need to use 2 different UUIDs. The General UUID is always the same for all the Devices and allows us to find them , and distinguish them from other devices using BLE. The Specific UUID is different for all the Devices and allows us to identify and differentiate the AltBeacons form each other. It is important to know that the connection between the peripheral and the central happens only once, after that the central can remember the peripheral and it only needs to sense for the range afterwards. There is no need to reconnect (less battery usage).

We released open source framework that does this and much more. You can checkit out at: https://github.com/CharruaLabs/AltBeacon. Check the class AltBeacon.m to see how we implemented it.

1
votes
  1. Yes, you need to provide specific UUIDs to be able to discover.
  2. Doesn't seem like it. In fact, I've tried sniffing the advertisement packets of the same app while in foreground as well as background and the UUID bytes aren't even the same. It seems to be hashed while in the background. The localName is also ignored (you'll find that this is consistent with what is mentioned in Apple's Core Bluetooth Programming Guide).

As for Mingleton, based on this TechCrunch article:

Asked to explain how the technology works in more detail, Ekekezie said users would sign up with Facebook before being assigned a unique beacon configuration. “When another user detects your beacon configuration and then taps ‘See Who’s Nearby’ to see who it is, he or she pings our server to figure out who you are and if you’re relevant to him or her based on both of your stated preferences – for now just gender and age range,” he says.

I assume that the app is based entirely on iBeacon technology, and knowing that iBeacons currently can't advertise from the background, I would assume that the app needs to run in the foreground for it to work as intended.