Skip to contentSkip to conversation

What's the best way to go about device detection?

Bluez-users Rob Raper 2 participants 2 messages May 17, 2004 Bluetooth drivers

lore
Share & tools
lore

Rob Raper

author
#0 lore raw

Without involving any of my source code at alll, I can demonstrate one of my biggest problems. I'll first create a connection to an existing bluetooth device. It works fine. I can get an RSSI value or link value. Then, I'lll try a non-existent device. I get a connection timed out error fairly quickly. Great, that's exactly what I want and what I expect. What follows, however, is what is really causing me problems. I can no longer connect to the valid bt device. I just get errors for a long time. I can't disconnect either. How can I clear out the failed connection and move on without everything breaking down like this?

pluto62:~/bluez-utils-2.4/tools# hcitool cc 00:60:57:23:35:15
pluto62:~/bluez-utils-2.4/tools# hcitool rssi 00:60:57:23:35:15
RSSI return value: -1
pluto62:~/bluez-utils-2.4/tools# hcitool dc 00:60:57:23:35:15

So far so good...Now try an invalid address

pluto62:~/bluez-utils-2.4/tools# hcitool cc 00:60:57:23:35:14
Can't create connection: Connection timed out

As expected.

pluto62:~/bluez-utils-2.4/tools# hcitool dc 00:60:57:23:35:14
Disconnect failed: Input/output error

Why an input/output error? It's on the con list, how do I get it off?

pluto62:~/bluez-utils-2.4/tools# hcitool cc 00:60:57:23:35:15
Can't create connection: Input/output error

Uh oh.. why can't I connect to the bt adapter that worked before?

Quoted 38 lines

From: Marcel Holtmann <[email protected]>
To: Rob Raper <[email protected]>
CC: BlueZ Mailing List <[email protected]>
Subject: Re: [Bluez-users] What's the best way to go about device detection?
Date: Sun, 16 May 2004 22:20:24 +0200

Hi Rob,

Quoted 3 lines

Thanks for your reply. I'll have a look into RSSI. Is it
possible to use RSSI for detection, but then use RFCOMM to do the actual
communications? Once "linked" to a server they don't ever need to

talk to

Quoted 2 lines

multiple servers at the same time. It's just that other servers need to determine signal strength in order to decide when to perform a hand off.

this is what I said. The RSSI comes for free with an inquiry with RSSI command from the Bluetooth 1.2 specification. And while a connection is active you can retrieve it without any extra cost. Look at the hcitool info command and see how it finds the needed ACL handle of an existing connection.

And btw check your devices that they really support inquiry while they maintain an open ACL connection.

Quoted 3 lines

Here's the block of code that I'm currently using to do a scan. The old version which worked better was simply a verison of the "hcitool scan" routine modified to connect and check singal strength.

Sorry, but I won't read that code. It is too much nested and actually code that needs more than 80 chars in a row is way too complex.

Regards

Marcel

Quoted 9 lines

-------------------------------------------------------
This SF.Net email is sponsored by: SourceForge.net Broadband Sign-up now for SourceForge Broadband and get the fastest 6.0/768 connection for only $19.95/mo for the first 3 months!
http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click
_______________________________________________
Bluez-users mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

_________________________________________________________________
Watch LIVE baseball games on your computer with MLB.TV, included with MSN Premium! http://join.msn.click-url.com/go/onm00200439ave/direct/01/

-------------------------------------------------------
This SF.Net email is sponsored by: SourceForge.net Broadband Sign-up now for SourceForge Broadband and get the fastest 6.0/768 connection for only $19.95/mo for the first 3 months!
http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click
_______________________________________________
Bluez-users mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

maintainer
#1 lore raw

Hi Rob,

Quoted 20 lines

Without involving any of my source code at alll, I can demonstrate one of my
biggest problems. I'll first create a connection to an existing
bluetooth device. It works fine. I can get an RSSI value or link value.
Then, I'lll try a non-existent device. I get a connection timed out error
fairly quickly. Great, that's exactly what I want and what I expect. What follows, however, is what is really causing me problems. I can no longer
connect to the valid bt device. I just get errors for a long time. I
can't disconnect either. How can I clear out the failed connection and
move on without everything breaking down like this?

pluto62:~/bluez-utils-2.4/tools# hcitool cc 00:60:57:23:35:15
pluto62:~/bluez-utils-2.4/tools# hcitool rssi 00:60:57:23:35:15
RSSI return value: -1
pluto62:~/bluez-utils-2.4/tools# hcitool dc 00:60:57:23:35:15

So far so good...Now try an invalid address

pluto62:~/bluez-utils-2.4/tools# hcitool cc 00:60:57:23:35:14
Can't create connection: Connection timed out
Quoted 6 lines

As expected.

pluto62:~/bluez-utils-2.4/tools# hcitool dc 00:60:57:23:35:14
Disconnect failed: Input/output error

Why an input/output error? It's on the con list, how do I get it off?

if create_connection fails no ACL link is in the connection list and there is no need to disconnect it unless we have a bug in the Bluetooth core layer. However using the native HCI create_connection and disconnect functions is not a good idea and the timeout you see is not from the Bluetooth chip I think. If the create_connection process is still running you can't disconnect anything and in some cases you trouble the Bluetooth chip with such actions. Check with hcidump what is going on.

What kind of Bluetooth modules are you using? Show us "hciconfig -a".

Regards

Marcel

-------------------------------------------------------
This SF.Net email is sponsored by: SourceForge.net Broadband Sign-up now for SourceForge Broadband and get the fastest 6.0/768 connection for only $19.95/mo for the first 3 months!
http://ads.osdn.com/?ad_id=2562&alloc_id=6184&op=click
_______________________________________________
Bluez-users mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users