PDA

View Full Version : Silent failure on connect to bluetooth headset using hcitool


sagemintblue
2nd July 2008, 07:34 PM
Hi all,

I've been looking around for ways I might further debug a bluetooth connectivity issue i'm having.

I recently purchased a Bluetooth USB adapter (Azio USB Micro Bluetooth Adapter BTD-V201) for my desktop. I'm running Fedora Core 7 (32-bit). The adapter seems to be working fine, as seen by the following status output:

# grep hcid /var/log/messages
Jul 2 12:27:30 seward hcid[2305]: HCI dev 0 registered
Jul 2 12:27:30 seward hcid[2305]: HCI dev 0 up
Jul 2 12:27:30 seward hcid[2305]: Device hci0 has been added
Jul 2 12:27:30 seward hcid[2305]: Starting security manager 0
Jul 2 12:27:30 seward hcid[2305]: Device hci0 has been activated
...

# /sbin/lsusb
Bus 003 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
...

# /etc/rc.d/init.d/bluetooth status
hcid (pid 2305) is running...
sdpd (pid 2311) is running...

# hcitool dev
Devices:
hci0 00:1B:DC:00:21:41

# /usr/sbin/hciconfig
hci0: Type: USB
BD Address: 00:1B:DC:00:21:41 ACL MTU: 310:10 SCO MTU: 64:8
UP RUNNING PSCAN
RX bytes:15581 acl:0 sco:0 events:490 errors:0
TX bytes:1919 acl:0 sco:0 commands:210 errors:0

When I place my Bluetooth headset (Jabra JX-10 version 1) in pairing mode so it's discoverable, hcitool scan properly finds the device:

# hcitool scan
Scanning ...
00:07:A4:D2:03:67 Jabra JX10

# hcitool info 00:07:A4:D2:03:67
Requesting information ...
BD Address: 00:07:A4:D2:03:67
LMP Version: 1.2 (0x2) LMP Subversion: 0x80e
Manufacturer: Cambridge Silicon Radio (10)
Features: 0xff 0xff 0x8b 0x78 0x18 0x18 0x00 0x80
<3-slot packets> <5-slot packets> <encryption> <slot offset>
<timing accuracy> <role switch> <hold mode> <sniff mode>
<park state> <RSSI> <channel quality> <SCO link> <HV2 packets>
<HV3 packets> <u-law log> <A-law log> <CVSD> <paging scheme>
<transparent SCO> <broadcast encrypt> <enhanced iscan>
<interlaced iscan> <interlaced pscan> <inquiry with RSSI>
<AFH cap. slave> <AFH class. slave> <AFH cap. master>
<AFH class. master> <extended features>

But when I try to connect to it via hcitool cc, it silently fails, with no added info in syslog or elsewhere that I can find...

# time hcitool cc 00:07:A4:D2:03:67

real 0m1.321s
user 0m0.000s
sys 0m0.001s

# hcitool con
Connections:



Any thoughts?? Also, here's the contents of my /etc/bluetooth/hcid.conf file:

# HCId options
options {
# Automatically initialize new devices
autoinit yes;

# Security Manager mode
# none - Security manager disabled
# auto - Use local PIN for incoming connections
# user - Always ask user for a PIN
#
security user;

# Pairing mode
# none - Pairing disabled
# multi - Allow pairing with already paired devices
# once - Pair once and deny successive attempts
pairing multi;

# Default PIN code for incoming connections
#passkey "PIN:0000";

# modify this script to include device pin when pairing
#pin_helper /etc/bluetooth/feed-pin.sh;
}

# Default settings for HCI devices
device {
# Local device name
# %d - device id
# %h - host name
name "%h-%d";

# Local device class
class 0x120104;

# Default packet type
#pkt_type DH1,DM1,HV1;

# Inquiry and Page scan
iscan enable; pscan enable;

# Default link mode
# none - no specific policy
# accept - always accept incoming connections
# master - become master on incoming connections,
# deny role switch on outgoing connections
lm accept;

# Default link policy
# none - no specific policy
# rswitch - allow role switch
# hold - allow hold mode
# sniff - allow sniff mode
# park - allow park mode
lp rswitch,hold,sniff,park;

# authentication / encryption
auth disable;
encrypt disable;
}

sagemintblue
2nd July 2008, 08:05 PM
so I noticed the hcidump command just now. Here's its output when running hcitool cc <mac address of headset>:

< HCI Command: Create Connection (0x01|0x0005) plen 13
> HCI Event: Command Status (0x0f) plen 4
> HCI Event: Connect Complete (0x03) plen 11
< HCI Command: Read Remote Supported Features (0x01|0x001b) plen 2
> HCI Event: Page Scan Repetition Mode Change (0x20) plen 7
> HCI Event: Max Slots Change (0x1b) plen 3
> HCI Event: Command Status (0x0f) plen 4
> HCI Event: Command Status (0x0f) plen 4
< HCI Command: Write Link Policy Settings (0x02|0x000d) plen 4
> HCI Event: Command Complete (0x0e) plen 6
< HCI Command: Remote Name Request (0x01|0x0019) plen 10
> HCI Event: Command Status (0x0f) plen 4
> HCI Event: Read Remote Supported Features (0x0b) plen 11
> HCI Event: Remote Name Req Complete (0x07) plen 255
< HCI Command: Disconnect (0x01|0x0006) plen 3
> HCI Event: Command Status (0x0f) plen 4
> HCI Event: Disconn Complete (0x05) plen 4

It seems like everything is working normally, but for whatever reason the connection is dropped almost immediately... Is this supposed to happen? What should I be doing to get the device to pair? I thought I had to first "hcitool cc" and then "hcitool auth"...

sagemintblue
2nd July 2008, 08:36 PM

the L2ping util "l2ping" gives me the following output:

# l2ping 00:07:A4:D2:03:67
Ping: 00:07:A4:D2:03:67 from 00:1B:DC:00:21:41 (data size 44) ...
4 bytes from 00:07:A4:D2:03:67 id 0 time 26.08ms
4 bytes from 00:07:A4:D2:03:67 id 1 time 25.12ms
4 bytes from 00:07:A4:D2:03:67 id 2 time 24.73ms
4 bytes from 00:07:A4:D2:03:67 id 3 time 25.34ms
4 bytes from 00:07:A4:D2:03:67 id 4 time 27.67ms
...

and the l2test util reports connection refused errors on relevant tests:

# l2test -u 00:07:A4:D2:03:67
l2test[7841]: Can't connect: Connection refused (111)

hcidump log of l2test -u:

< HCI Command: Create Connection (0x01|0x0005) plen 13
> HCI Event: Command Status (0x0f) plen 4
> HCI Event: Connect Complete (0x03) plen 11
< ACL data: handle 42 flags 0x02 dlen 12
L2CAP(s): Connect req: psm 10 scid 0x0040
< HCI Command: Read Remote Supported Features (0x01|0x001b) plen 2
> HCI Event: Page Scan Repetition Mode Change (0x20) plen 7
> HCI Event: Number of Completed Packets (0x13) plen 5
> HCI Event: Max Slots Change (0x1b) plen 3
> HCI Event: Command Status (0x0f) plen 4
> HCI Event: Command Status (0x0f) plen 4
< HCI Command: Write Link Policy Settings (0x02|0x000d) plen 4
> ACL data: handle 42 flags 0x02 dlen 16
L2CAP(s): Connect rsp: dcid 0x0000 scid 0x0040 result 2 status 0
Connection refused - PSM not supported
> HCI Event: Command Complete (0x0e) plen 6
< HCI Command: Remote Name Request (0x01|0x0019) plen 10
> HCI Event: Command Status (0x0f) plen 4
> HCI Event: Read Remote Supported Features (0x0b) plen 11
> HCI Event: Remote Name Req Complete (0x07) plen 255
< HCI Command: Disconnect (0x01|0x0006) plen 3
> HCI Event: Command Status (0x0f) plen 4
> HCI Event: Disconn Complete (0x05) plen 4

So, what does this "Connection refused - PSM not supported" mean?

sagemintblue
2nd July 2008, 08:43 PM
More output which might be of use, this time from the sdptool utility:

# sdptool record 00:07:A4:D2:03:67
Service Name: Hands-Free unit
Service RecHandle: 0x10002
Service Class ID List:
"Handsfree" (0x111e)
"Generic Audio" (0x1203)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 2
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Handsfree" (0x111e)
Version: 0x0101

Service Name: Headset
Service RecHandle: 0x10003
Service Class ID List:
"Headset" (0x1108)
"Generic Audio" (0x1203)
Protocol Descriptor List:
"L2CAP" (0x0100)
"RFCOMM" (0x0003)
Channel: 1
Language Base Attr List:
code_ISO639: 0x656e
encoding: 0x6a
base_offset: 0x100
Profile Descriptor List:
"Headset" (0x1108)
Version: 0x0100

sagemintblue
2nd July 2008, 09:41 PM
Using the rfcomm util i've been able to get one step closer to pairing--


back up the /etc/bluetooth/rfcomm.conf file
# mv /etc/bluetooth/rfcomm.conf /etc/bluetooth/rfcomm.conf.bak
get rid of any existing link keys stored for the bluetooth adapter
# rm -f /var/lib/bluetooth/<mac address of adapter>/linkkeys
restart bluetooth services
# /sbin/service bluetooth restart
exec rfcomm to create binding entry via bluetooth adapter (hci0 in my case) to remote bluetooth device (mac address + channel)
# rfcomm bind hci0 00:07:A4:D2:03:67 1
make sure the remote bluetooth device is on, in pairing mode
exec rfcomm to connect
# rfcomm connect hci0 00:07:A4:D2:03:67 1
gnome bluetooth manager prompts for PIN code.. type it in and hit okay.
the device SHOULD connect, but error message is displayed on console:
Can't create RFCOMM TTY: Address already in use


Googling this error message didn't turn up much for me yet.. Still searching..

sagemintblue
2nd July 2008, 09:56 PM
Okay, so releasing the device and re-attempting the connect did the trick.. I think..

# rfcomm release /dev/rfcomm0
# rfcomm connect hci0 00:07:A4:D2:03:67 1
Connected /dev/rfcomm0 to 00:07:A4:D2:03:67 on channel 1
Press CTRL-C for hangup
...

# hcitool con
Connections:
< ACL 00:07:A4:D2:03:67 handle 42 state 1 lm MASTER

But I still can't seem to connect using hcitool cc.. Strange.