hcidump

Hcidump tool is provided by BlueZ and is a good tool to help developers to analysis protocol issues of Bluetooth for BlueZ stack.

Currently, the most useful option for me is ‘sudo hcidump -XtV’. I used this tool to locate a PAN issue between 2 Ubuntu 8.10 PC. The problem is that it will report ‘Connection refused(111)” when try to use PAN profile.

Here is the data analysis:

2009-06-05 03:24:31.564605 < HCI Command: Create Connection (0×01|0×0005) plen 13
bdaddr 00:15:83:06:9F:E4 ptype 0xcc18 rswitch 0×01 clkoffset 0×0000
Packet type: DM1 DM3 DM5 DH1 DH3 DH5
2009-06-05 03:24:31.606035 > HCI Event: Command Status (0x0f) plen 4
Create Connection (0×01|0×0005) status 0×00 ncmd 1
2009-06-05 03:24:32.012032 > HCI Event: Connect Complete (0×03) plen 11
status 0×00 handle 42 bdaddr 00:15:83:06:9F:E4 type ACL encrypt 0×00
2009-06-05 03:24:32.012138 < HCI Command: Read Remote Supported Features (0×01|0x001b) plen 2
handle 42
2009-06-05 03:24:32.013989 > HCI Event: Page Scan Repetition Mode Change (0×20) plen 7
bdaddr 00:15:83:06:9F:E4 mode 1
2009-06-05 03:24:32.015982 > HCI Event: Max Slots Change (0x1b) plen 3
handle 42 slots 5
2009-06-05 03:24:32.018983 > HCI Event: Command Status (0x0f) plen 4
Read Remote Supported Features (0×01|0x001b) status 0×00 ncmd 1
2009-06-05 03:24:32.027987 > HCI Event: Read Remote Supported Features (0x0b) plen 11
status 0×00 handle 42
Features: 0xff 0xff 0x8f 0xfe 0x9b 0xf9 0×00 0×80
2009-06-05 03:24:32.028158 < ACL data: handle 42 flags 0×02 dlen 10
L2CAP(s): Info req: type 2
2009-06-05 03:24:32.035984 > HCI Event: Number of Completed Packets (0×13) plen 5
handle 42 packets 1
2009-06-05 03:24:32.039982 > ACL data: handle 42 flags 0×02 dlen 16
L2CAP(s): Info rsp: type 2 result 0
Extended feature mask 0×0000
2009-06-05 03:24:32.040122 < ACL data: handle 42 flags 0×02 dlen 12
L2CAP(s): Connect req: psm 15 scid 0×0040

======================>> L2CAP connect command: 1st time

2009-06-05 03:24:32.045999 > HCI Event: Number of Completed Packets (0×13) plen 5
handle 42 packets 1
2009-06-05 03:24:32.052000 > ACL data: handle 42 flags 0×02 dlen 16
L2CAP(s): Connect rsp: dcid 0×0040 scid 0×0040 result 1 status 0

Connection pending – No futher information available=======================>> pending, need more time

2009-06-05 03:24:32.054999 > ACL data: handle 42 flags 0×02 dlen 10
L2CAP(s): Info req: type 2
2009-06-05 03:24:32.055130 < ACL data: handle 42 flags 0×02 dlen 16
L2CAP(s): Info rsp: type 2 result 0
Extended feature mask 0×0000
2009-06-05 03:24:32.060998 > HCI Event: Number of Completed Packets (0×13) plen 5
handle 42 packets 1
2009-06-05 03:24:32.068999 > ACL data: handle 42 flags 0×02 dlen 16
L2CAP(s): Connect rsp: dcid 0×0040 scid 0×0040 result 1 status 1

Connection pending – Authentication pending   ===================>> wait for authentication

2009-06-05 03:24:32.101999 > HCI Event: Link Key Request (0×17) plen 6
bdaddr 00:15:83:06:9F:E4
2009-06-05 03:24:32.124584 < HCI Command: Remote Name Request (0×01|0×0019) plen 10
bdaddr 00:15:83:06:9F:E4 mode 2 clkoffset 0×0000
2009-06-05 03:24:32.127995 > HCI Event: Command Status (0x0f) plen 4
Remote Name Request (0×01|0×0019) status 0×00 ncmd 1
2009-06-05 03:24:32.128035 < HCI Command: Link Key Request Reply (0×01|0x000b) plen 22
bdaddr 00:15:83:06:9F:E4 key CFE97F82CB4E1913A882BD9B9C61DC76
2009-06-05 03:24:32.141006 > HCI Event: Command Complete (0x0e) plen 10
Link Key Request Reply (0×01|0x000b) ncmd 1
status 0×00 bdaddr 00:15:83:06:9F:E4
2009-06-05 03:24:32.198008 > HCI Event: Remote Name Req Complete (0×07) plen 255
status 0×00 bdaddr 00:15:83:06:9F:E4 name ‘llei-t61-u810-nm-0′
2009-06-05 03:24:32.228036 > HCI Event: Encrypt Change (0×08) plen 4
status 0×00 handle 42 encrypt 0×01
2009-06-05 03:24:32.228047 > ACL data: handle 42 flags 0×02 dlen 16
L2CAP(s): Connect rsp: dcid 0×0040 scid 0×0040 result 0 status 0

Connection successful               =======================>> successful!!!!

2009-06-05 03:24:32.228256 < ACL data: handle 42 flags 0×02 dlen 12
L2CAP(s): Connect req: psm 15 scid 0×0040

===================>> Stupid, send connect command again!!!

2009-06-05 03:24:32.228281 < ACL data: handle 42 flags 0×02 dlen 16
L2CAP(s): Config req: dcid 0×0040 flags 0×00 clen 4
MTU 1691
2009-06-05 03:24:32.233983 > HCI Event: Number of Completed Packets (0×13) plen 5
handle 42 packets 1
2009-06-05 03:24:32.235982 > HCI Event: Number of Completed Packets (0×13) plen 5
handle 42 packets 1
2009-06-05 03:24:32.241982 > ACL data: handle 42 flags 0×02 dlen 16
L2CAP(s): Connect rsp: dcid 0×0000 scid 0×0040 result 4 status 0

Connection refused – no resources available  ===============>> Refused by the GN for the second time…

2009-06-05 03:24:32.244981 > ACL data: handle 42 flags 0×02 dlen 18
L2CAP(s): Config rsp: scid 0×0040 flags 0×00 result 0 clen 4
MTU 1691
2009-06-05 03:24:32.246982 > ACL data: handle 42 flags 0×02 dlen 16
L2CAP(s): Config req: dcid 0×0040 flags 0×00 clen 4
MTU 1691
2009-06-05 03:24:32.247098 < ACL data: handle 42 flags 0×02 dlen 10
L2CAP(s): Command rej: reason 0

===================>> Rejected

Command not understood
2009-06-05 03:24:32.251980 > HCI Event: Number of Completed Packets (0×13) plen 5
handle 42 packets 1
2009-06-05 03:24:34.240949 < HCI Command: Disconnect (0×01|0×0006) plen 3
handle 42 reason 0×13
Reason: Remote User Terminated Connection
2009-06-05 03:24:34.244013 > HCI Event: Command Status (0x0f) plen 4
Disconnect (0×01|0×0006) status 0×00 ncmd 1
2009-06-05 03:24:34.250017 > HCI Event: Disconn Complete (0×05) plen 4
status 0×00 handle 42 reason 0×16
Reason: Connection Terminated by Local Host

你可能感兴趣的:(hcidump)