Re: Background and locked iOS device BTLE scanning behavior changes in iOS 7
Re: Background and locked iOS device BTLE scanning behavior changes in iOS 7
- Subject: Re: Background and locked iOS device BTLE scanning behavior changes in iOS 7
- From: William Henderson <email@hidden>
- Date: Tue, 01 Oct 2013 11:01:04 -0700
Yep, that's pretty much the strategy we use (connect, discover, read from characteristic). And, of course, disconnect and ignore further packets from any peripherals advertising other services. Slow and error-prone, but it works.
On Tuesday, October 1, 2013 at 10:58 AM, Brian Fudge wrote:
William,
It is correct that the advertisement packets do not include service UUIDs when an iOS device is in the background, but this does not prevent didDiscoverPeripheral events from firing on OSX or other bluetooth scanning devices. The trick is that you need to provide a characteristic that contains a unique identifier like the identifierForVendor to correctly identify the peripheral since iOS also rotates the device UUID periodically. It takes longer to confirm a discovery because you have to connect, discoverServices, and read a characteristic, but it is a workable solution.
I do agree that you need to use nil for the service UUIDs when discovering services on CoreBluetooth on OSX.
Thanks for your input. I'll submit a TSI to Apple and follow up with more information if I get some.
Brian
On Sep 28, 2013, at 10:05 AM, William Henderson <
email@hidden> wrote:
Hi Brian,
I'm surprised you had this working on iOS 6. Based on my testing, this never worked. What I can tell you is that whenever an iOS device goes into the background, it changes its advertisement packets to not include any service UUIDs. This is documented in the CoreBluetooth Programming Guide:
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.
What I've found is that the only way for an iOS device or Mac to find a backgrounded iOS device is to have the scanning device scan for all services (i.e. pass nil to scanForPeripheralsWithServices:). And, as has been discussed elsewhere on this list, scanning in the background only works if you explicitly pass an array of services into scanForPeripheralsWithServices.
In sum, as far as I know you can't do background-to-background iOS device discovery – both central and peripherals exhibit special behaviors while in the background that make this impossible. As you say, it's possible when one device is in the foreground, one device is a hardware peripheral, or the central is a Mac (OS X doesn't yet have 'background' mode). I'm unclear whether this is intentional or not. The CB Programming Guide seems to imply that background to background should be possible, but my findings and prior discussion on the list has indicated the opposite.
On Friday, September 27, 2013 at 9:06 PM, Brian Fudge wrote:
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Bluetooth-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden