Please see comments inline below.
On Feb 7, 2012, at 11:04 AM, Gutierrez, Gerald wrote:
Hello Bluetooth experts,
I'm doing some further investigation into CoreBluetooth. Session backgrounding is a mystery to me. Some questions:
#1 For example, I created a small app, set UIBackgroundModes to bluetooth-central and created a recurring NSTimer to increment a counter. When I run this app, the timer runs but stops when I put the app in the background. It resumes when I put the app back in the foreground. Is this proper behavior or am I missing something?
Once you have the Bluetooth privilege to run in the background, this gives you the privilege to run Bluetooth related code. However, it does not give you a carte blanche to run in the background. Meaning, the App get to run when there is Bluetooth events that needs to be serviced. One example of this would be logging heart rate events from a heart rate monitor. So, you can't use the Bluetooth privilege as a back door to get other background privileges. In your case, the timer is a non-Bluetooth event and so Bluetooth privileges will unfortunately not help you.
#2 Backing up a bit, is it possible for me to run arbitrary code?
Not arbitrary code, but relevant code. See response to #1.
#3 Another open question to me is audio. I'd like to be able to play background audio (not just a sound clip from a local notification) while an LE app is in the background. It's not obvious to me whether this is possible or not.
To play audio you need audio background privileges. It is not possible to use your Bluetooth privileges for this.
#4 Assuming I can run arbitrary code while in the background, if I post a local notification, will that notification be shown as a popup or do I simply get a callback in the AppDelegate?
The notification will be shown. This way, an App in the background servicing a Bluetooth event can alert the user.
You are welcome.