Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CoreBluetooth Central Manager cannot discover peripheral in background

I have an application that is utilizing Bluetooth 4.0 LE. The application allows the device to act as a Central and a Peripheral.

I want the application to run in the background. I have included the UIBackgroundModes with "bluetooth-central" and "bluetooth-peripheral" in the info.plist already.

I am running the application on two different devices that are Bluetooth 4.0 LE enabled.

When both devices are running in the foreground, everything works perfectly and information is passed both ways.

When one device is running in the foreground and the other is running in the background, the device running in the background is able to scan and advertise, but unable to discover the other device that is running in the background. The device that is running in the foreground is able to discover and connect to the device that is running in the background.

After reading through Apple's Core Bluetooth Programming Guide, I know that connecting to another device and sharing information BOTH ways is possible.

I can post any more information upon request. Thank you.

like image 727
tagabek Avatar asked Aug 23 '13 21:08

tagabek


1 Answers

When the peripheral app is backgrounded, the advertised services are pushed to the "overflow area" and the peripheral name is not advertised at all. Additionally, the advertisement interval is raised. In theory, the iOS BLE stack should handle this case and request for the overflow area data but it does not do so. At the same time, the scanning on the backgrounded central is also slowed down, and additionally it requires specific service UUIDs to work. (You cannot scan in the background with nil services)

As a consequence, scanning for backgrounded devices on a backgrounded central is not possible.

Either this is a bug or a feature, only Apple knows. Open a radar and tell them your issue. The more of us do this, the better chance we get response.

like image 158
allprog Avatar answered Nov 08 '22 22:11

allprog