I'm trying to translate an Android app I developed that finds all peripherals around the central and returns them to the user. Then the user can connect to one (or more) of them to do other things.
Problem: Once a device gets connected with CoreBluetooth, it is no longer returned during a scan. It should be re-acquired through the known devices list that does not give any information about the vicinity of the devices returned.
Is there a simpler way than trying to connect to each known device to know if it is in range ?
EDIT: Known devices are indeed returned during a scan, I was working on BLE devices that did not have the same advertising name and GAPP name, which confused me when rescanning after the first connection to a device :)
You know a device is in range if you can see it advertising.
There are multiple forms of advertising:
Some devices only advertise a subset of the services they offer once you connect. The reason for this is there are only 31 bytes of advertising data that you can send, and if you use a Bluetooth standard Service, it'll be two bytes for each service. if you use a custom service, it's 16 bytes just to advertise that service!
It can also advertise its list of services, so you know what you can use to connect to it to do.
That means that you should parse the advertising data returned; doing this is in the scope of this Stack Overflow question.