8
votes

When an iOS BLE peripheral enters the background state, the advertising packets are not emitted in the regular manner and they are placed in a special “overflow” area which is only detectable by another iOS device explicitly looking for this device.

The bluetooth-peripheral Background Execution Mode

That said, you should be aware that advertising while your app is in the background operates differently than when your app is in the foreground. In particular, when your app is advertising while in the background:

• The CBAdvertisementDataLocalNameKey advertisement key is ignored, and the local name of peripheral is not advertised.

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

Is there any way an Android central (scanner) can detect any advertised custom UUID without having to connect to the iOS peripheral?

1
@KaizerSozay nope. The only work around could be to... queue every other iOS device -> connect -> look for your serviceUUID -> if present, then do your thing -> disconnect. Yes, this is slow and not asynchronous as opposed to just reading the advertisement packets without connecting, but it's the only work around I know as of now.Ahimsa Das
An Android central (scanner) will be able to detect an iOS peripheral (advertiser) that's in the background state, but will not be able to read any custom serviceUUID without connecting to it. You can tell that it's an Apple device by reading the manufacturer ID - look for Apple.Ahimsa Das
Yes that's correct! You can try using this Blessed Library - but you'd have to write the queuing and connection logic by yourself based on your requirements / conditions.Ahimsa Das
You can't write a generic code which will work for every case. You'd have to define your own UUIDs, scanning / advertising conditions & settings. Please go through the Android & iOS BLE docs, you can easily implement it once you've clearly defined your use case and requirements. Also, Apple & Google have teamed up in efforts to use BLE for contact tracing the COVID-19 pandemic. We may see some changes in the core BLE stacks for better cross platform inter-operability.Ahimsa Das
Just perform a non-filtered scan and then manually look through each and every scanResult for your custom serviceUUID. If you can't find it here, then check if it's an Apple device and queue it for connecting (what we discussed above).Ahimsa Das

1 Answers

1
votes

With "overflow" area I guess they mean Scan Response Data. To get that data, a device must perform an active scan, rather than a passive scan. In an active scan, the scanner sends a scan request packet immediately after it detects an advertisement packet. The advertising device will only broadcast the scan response data if it detected a scan request.

Android devices only perform active scans, so you should be fine.

EDIT: the answer above is not correct. See http://www.davidgyoungtech.com/2020/05/07/hacking-the-overflow-area for correct information.