igge - 2006-08-18

I have done some experimenting with the device discovery process using AvetanaBT and also Python (pybluez). The thing is that when using python I get the devices right away as the chip discovers them, whice usually takes about 1-2 secs. But using AvetanaBT it waits for the whole 10 secs before delivering them.

Obviously, on both Java and Python the whole discovery process takes 10 secs in total, but python calls the "device discovered" callback as soon as the devices are discovered, java waits until just before the discovery process is complete before it calls the callback.

Here are some logs from the programs interlieved with hcidump output to prove it.. :)

First python:

1155917436.850482 < HCI Command: Read BD ADDR (0x04|0x0009) plen 0
1155917436.853509 > HCI Event: Command Complete (0x0e) plen 10
1155917436.85: discovering...
1155917436.853930 < HCI Command: Inquiry (0x01|0x0001) plen 5
1155917436.857509 > HCI Event: Command Status (0x0f) plen 4
1155917437.51: found device: 00:09:2D:6A:AD:B1
1155917437.506416 > HCI Event: Inquiry Result (0x02) plen 15
1155917437.63: found device: 00:16:B8:1C:17:14
1155917437.634399 > HCI Event: Inquiry Result (0x02) plen 15
1155917441.98: complete...
1155917441.982794 > HCI Event: Inquiry Complete (0x01) plen 1

The numbers are timestamps, the "found device" stuff is printed by python, the "HCI Event: Inquiry Result" is when the chip found the device... Same thing in java:

1155916641.589: * DISCOVER
1155916641.594279 < HCI Command: Inquiry (0x01|0x0001) plen 5
1155916641.598304 > HCI Event: Command Status (0x0f) plen 4
1155916642.858128 > HCI Event: Inquiry Result (0x02) plen 15
1155916644.535897 > HCI Event: Inquiry Result (0x02) plen 15
1155916651.841879 > HCI Event: Inquiry Complete (0x01) plen 1
1155916651.845: discovered: 00092D6AADB1
1155916651.845: discovered: 0016B81C1714
1155916651.845: completed

So the results come in from the chip... but Java waits for 10 secs to deliver them.

(This is the case both using avetanaBT on linux and on Ericsson W810i, which are the devices I've tried).

Why is this? Can AvetanaBT be modified so that it delivers the results right away?