views:

470

answers:

1

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.

+4  A: 

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.

Pev
Not iPhone specific, but this is still a VERY good answer. A++++ would read again.
rpetrich