开发者

Fast Bluetooth Name Lookup

I'm experiencing problems in fast detecting nearby bluetooth devices' names (human names, not BTADDR) I found a very interesting Python-based project here [http://code.google.com开发者_开发问答/p/python-bluetooth-scanner/] but the issue basically is that, while looking for BTADDR and RSSI is fast, detecting the "human" name of the device takes longer (even if they say it should work in the code)

I know I can look up for names with:

  1. the simple "hcitool scan" console command, which is slow
  2. the bluetooth.lookup_name(address) method of module PyBlueZ
  3. as written in the project, reported below

-

sock = bluetooth.bluez._gethcisock(device)
timeoutms = int(timeout * 1000)
try:
  name = bluetooth._bluetooth.hci_read_remote_name( sock, address, timeoutms )
except bluetooth._bt.error, e:
  print e
  logger.debug("Lookup Failed")
  name = None
sock.close()
return name

A brief insight: the system uses 2 dongles to detect nearby BT devices, if I make them looking up for names, they spend more time hence remaining locked, when a new device is discovered, devices are still locked in looking for the previous one's name and the whole software hangs. I'm running Ubuntu 10.10 in a VirtualBox in WindowsXP environment and a couple BT 2.1 dongles.

Apart from creating a list of "unnamed" devices to look for as soon as my dongles are done with the previous ones. Do you know any way I could do that faster?


Finding a remote device's friendly name is generally a two-step process. First, you perform an inquiry scan "discovering" nearby device that are discoverable. Second, you need to connect to the remote device and "ask" it for its friendly name. Part of the delay comes from the fact that these two steps are often not performed in an interleaved manner (i.e., a device is discovered and then the name is queried). Oftentimes, you run an inquiry scan until completion (which takes a while) and then you ask specific devices for their friendly names. (To interleave the discovery and name lookup, you would start the discovery, wait until you "discover" a new device, cancel the discovery, query for the name, then restart the discovery. Repeat until no new devices are found. Some stacks do this for you automatically. Some don't.)

If both devices support Extended Inquiry Response (added in the Bluetooth 2.1 specification), the friendly name is returned as part of the discovery process. This speeds things up considerably, but it needs to be supported further down in the stack.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜