How long does it take to scan for Bluetooth devices in range of an iPhone?

12,155

Solution 1

Not sure what the API will let you do but the Bluetooth Host Controller Interface (HCI) command underlying this is the 'Inquiry Command'

This will let you inquire about devices either for a fixed time and/or a fixed number of responses.

I'm a Bluetooth neophyte, not an expert but...

To get at least 1 response from a Bluetooth device that is in a low power mode takes 1.28 seconds, so inquiry time is in multiples of that period up to a maximum of 61.44 seconds (48 periods), so the time range is 1 (1.28 seconds) to 48 (61.44 seconds).

There might be several devices that could respond in a single 1.28 second period though.

You can also specify the number of responses you will accept (1..255) or 0 for unlimited e.g. until the time runs out.

You can also cancel an inquiry, if you found a particular device you were looking for.

Unscientific test from my desk using a CSR bluetooth chip with Bluetooth 2.1 +EDR firmware running inquiry on the chip with debug output via the chip UART. Ran each inquiry 10 times and took an average of the results:

  • 1 period inquiry time (1.28 seconds) yeilded an average of 10 unique bluetooth addresses.
  • 5 period inquiry time (6.4 seconds) yielded an average of 23 unique bluetooth addresses.
  • 10 period inquiry time (12.8 seconds) yielded an average of 29 unique bluetooth addresses.

I say 'unique', actually the results repeated a lot of the same addresses over and over, this may be implementation dependent though and the Apple API may only return unique addresses.

However, this is not representative of the 'real world' as most of the Bluetooth Devices around here (my office) are not in a low power mode. I guess, I could filter out PCs, laptops and test kit by Class of Device. That would get mobile phones, headsets that were discoverable etc...

Inquiry can also be combined with RSSI to get the the devices with the strongest signal but they may not necessarily be the closest.

For your scenario you might want to do an inquiry bases on time and number of devices e.g 4 * 1.28 seconds or 10 devices.

To summarise: The shortest time you can do an inquiry for is 1.28 seconds and that could get 10+/-? devices in the area IF they are awake and near by.

If you've got a saturated Bluetooth environment or (a microwave oven going in the same room) it could take longer to find all the devices within range.

Solution 2

I know this is an old question, but I thought I might add something for anyone who finds this question later.

As Simon Peverett mentions, device discovery is performed by an underlying "Inquiry Command" that is carried out by the Bluetooth Host Controller Interface. In the Bluetooth spec V4.0, Volume 2, Part E, Section 6.1.4, the spec says:

When general inquiry is initiated by a Bluetooth device, the INQUIRY state shall last TGAP(100) or longer, unless the inquirer collects enough responses and determines to abort the INQUIRY state earlier.

Elsewhere, TGAP(100) is explained to be 10.24 seconds and is described as the recommended value for the time span that a Bluetooth device performs device discovery.

In other words, a good baseline for the minimum amount of time to perform an inquiry is 10.24 seconds, or 8 of the 1.28 second periods that the Inquiry Command measures time by.

Share:
12,155
Tai Squared
Author by

Tai Squared

Java/C# software developer

Updated on July 28, 2022

Comments

  • Tai Squared
    Tai Squared almost 2 years

    I know the iPhone Bluetooth capabilities won't be accessible through the SDK until 3.0, but how long should it take to find devices in the area? Is it dependent on the number of devices in the area? If there are around 5 devices in range, should a scan to discover all of them take <5 seconds, or >30 seconds?

    I know there are a lot of unknown factors, but I'm trying to determine if I can do a Bluetooth scan on startup if the time is minimal, or if I have to tell the user it is about to do a scan and there could be a long delay. I am unable to test this in the real world as the other Bluetooth devices aren't available, but I am trying to get a sense of how it could be designed.

  • rpetrich
    rpetrich about 15 years
    Not iPhone specific, but this is still a VERY good answer. A++++ would read again.