In bluez, we can find the BlueZ tools: */bluez/tools/*

It supports several useful hci(host control interface) interface control tools.

You can see the android bluetooth architecture: Android Bluetooth

I listed about bluez hci commands how to, as follows:

(1) hcitool

   hcitool [-h]
hcitool [-i <hciX>] [command [command parameters]]

Commands
dev Display local devices

inq Inquire remote devices. For each discovered device, Bluetooth
device address, clock offset and class are printed.

scan Inquire remote devices. For each discovered device, device name
is printed.

name <bdaddr>
Print device name of remote device with Bluetooth address
bdaddr.

info <bdaddr>
Print device name, version and supported features of remote
device with Bluetooth address bdaddr.

cmd <ogf> <ocf> [parameters]
Submit an arbitrary HCI command to local device. ogf, ocf and
parameters are hexadecimal bytes

con Display active baseband connections

cc [--role=m|s] [--pkt-type=<ptype>] <bdaddr>
Create baseband connection to remote device with Bluetooth
address bdaddr. Option --pkt-type specifies a list of allowed
packet types. <ptype> is a comma-separated list of packet
types, where the possible packet types are DM1, DM3, DM5, DH1,
DH3, DH5, HV1, HV2, HV3. Default is to allow all packet types.
Option --role can have value m (do not allow role switch, stay
master) or s (allow role switch, become slave if the peer asks
to become master). Default is m.

dc <bdaddr>
Delete baseband connection from remote device with Bluetooth
address bdaddr.

sr <bdaddr> <role>
Switch role for the baseband connection from the remote device
to master or slave.

cpt <bdaddr> <packet types>
Change packet types for baseband connection to device with Blue-
tooth address bdaddr. packet types is a comma-separated list of
packet types, where the possible packet types are DM1, DM3, DM5,
DH1, DH3, DH5, HV1, HV2, HV3.

rssi <bdaddr>
Display received signal strength information for the connection
to the device with Bluetooth address bdaddr.

lq <bdaddr>
Display link quality for the connection to the device with Blue-
tooth address bdaddr.

tpl <bdaddr> [type]
Display transmit power level for the connection to the device
with Bluetooth address bdaddr. The type can be 0 for the cur-
rent transmit power level (which is default) or 1 for the maxi-
mum transmit power level.

afh <bdaddr>
Display AFH channel map for the connection to the device with
Bluetooth address bdaddr.

lst <bdaddr> [value]
With no value, displays link supervision timeout for the connec-
tion to the device with Bluetooth address bdaddr. If value is
given, sets the link supervision timeout for that connection to
value slots, or to infinite if value is 0.

auth <bdaddr>
Request authentication for the device with Bluetooth address
bdaddr.

enc <bdaddr> [encrypt enable]
Enable or disable the encryption for the device with Bluetooth
address bdaddr.

key <bdaddr>
Change the connection link key for the device with Bluetooth
address bdaddr.

clkoff <bdaddr>
Read the clock offset for the device with Bluetooth address
bdaddr.

clock <bdaddr> [which clock]
Read the clock for the device with Bluetooth address bdaddr.
The clock can be 0 for the local clock or 1 for the piconet
clock (which is default).

(2) hciconfig

hciconfig -h
hciconfig [-a]
hciconfig [-a] [command [command parameters]]

Commands
up
Open and initialize HCI device.
down
Close HCI device.
reset
Reset HCI device.
rstat
Reset statistic counters.
auth
Enable authentication (sets device to security mode 3).
noauth
Disable authentication.
encrypt
Enable encryption (sets device to security mode 3).
noencrypt
Disable encryption.
secmgr
Enable security manager (current kernel support is limited).
nosecmgr
Disable security manager.
piscan
Enable page and inquiry scan.
noscan
Disable page and inquiry scan.
iscan
Enable inquiry scan, disable page scan.
pscan
Enable page scan, disable inquiry scan.
ptype [type]
With no type , displays the current packet types. Otherwise, all the packet types specified by type are set. type is a comma-separated list of packet types, where the possible packet types are DM1, DM3, DM5, DH1, DH3, DH5, HV1, HV2, HV3.
name [name]
With no name, prints local name. Otherwise, sets local name to name.
class [class]
With no class, prints class of device. Otherwise, sets class of device to class. class is a 24-bit hex number describing the class of device, as specified in section 1.2 of the Bluetooth Assigned Numers document.
voice [voice]
With no voice, prints voice setting. Otherwise, sets voice setting to voice. voice is a 16-bit hex number describing the voice setting.
iac [iac]
With no iac, prints the current IAC setting. Otherwise, sets the IAC to iac.
inqmode [mode]
With no mode, prints out the current inquiry mode. Otherwise, sets inquiry mode to mode.
inqdata [data]
With no name, prints out the current inquiry data. Otherwise, sets inquiry data to data.
inqtype [type]
With no type, prints out the current inquiry scan type. Otherwise, sets inquiry scan type to type.
inqparams [win:int]
With no win:int, prints inquiry scan window and interval. Otherwise, sets inquiry scan window to win slots and inquiry scan interval to int slots.
pageparms [win:int]
With no win:int, prints page scan window and interval. Otherwise, sets page scan window to win slots and page scan interval to int slots.
pageto [to]
With no to, prints page timeout. Otherwise, sets page timeout to .I to slots.
afhmode [mode]
With no mode, prints out the current AFH mode. Otherwise, sets AFH mode to mode.
aclmtu mtu:pkt
Sets ACL MTU to to mtu bytes and ACL buffer size to pkt packets.
scomtu mtu:pkt
Sets SCO MTU to mtu bytes and SCO buffer size to pkt packets.
putkey <bdaddr>
This command stores the link key for bdaddr on the device.
delkey <bdaddr>
This command deletes the stored link key for bdaddr from the device.
commands
Display supported commands.
features
Display device features.
version
Display version information.
revision
Display revision information.
lm [mode]
With no mode , prints link mode. MASTER or SLAVE mean, respectively, to ask to become master or to remain slave when a connection request comes in. The additional keyword ACCEPT means that baseband connections will be accepted even if there are no listening AF_BLUETOOTH sockets. mode is NONE or a comma-separated list of keywords, where possible keywords are MASTER and ACCEPT . NONE sets link policy to the default behaviour of remaining slave and not accepting baseband connections when there are no listening AF_BLUETOOTH sockets. If MASTER is present, the device will ask to become master if a connection request comes in. If ACCEPT is present, the device will accept baseband connections even when there are no listening AF_BLUETOOTH sockets.

(3) hciattach

hciattach [-n] [-p] [-t timeout] tty type|id speed flow

commands

-n
Don't detach from controlling terminal.
-p
Print the PID when detaching.
-t timeout
Specify an initialization timeout. (Default is 5 seconds.)
tty
This specifies the serial device to attach. A leading /dev can be omitted. Examples: /dev/ttyS1 ttyS2
type|id
The type or id of the Bluetooth device that is to be attached, i.e. vendor or other device specific identifier. Currently supported types are
type
description
any
Unspecified HCI_UART interface, no vendor specific options
ericsson
Ericsson based modules
digi
Digianswer based cards
xircom
Xircom PCMCIA cards: Credit Card Adapter and Real Port Adapter
csr
CSR Casira serial adapter or BrainBoxes serial dongle (BL642)
bboxes
BrainBoxes PCMCIA card (BL620)
swave
Silicon Wave kits
bcsp

Serial adapters using CSR chips with BCSP serial protocol

Supported IDs are (manufacturer id, product id)

0x0105, 0x080a
Xircom PCMCIA cards: Credit Card Adapter and Real Port Adapter
0x0160, 0x0002
BrainBoxes PCMCIA card (BL620)
speed
The speed specifies the UART speed to use. Baudrates higher than 115.200bps require vendor specific initializations that are not implemented for all types of devices. In general the following speeds are supported:

9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600

Supported vendor devices are automatically initialised to their respective best settings.

flow
If the keyword flow is appended to the list of options then hardware flow control is forced on the serial link ( CRTSCTS ). All above mentioned device types have flow set by default. To force no flow control use noflow instead.

 

(4)l2ping

l2ping  [ -S source addr ] [ -s size ] [ -c count ] [ -t timeout ] [ -f] < bd_addr >

commands
-S source addr
Select address to be used as source address for the request.

-s size
The size of the data packets to be sent.

-c count
Send count number of packets then exit.

-c timeout
Wait timeout for the response.

-f Kind of flood ping. Use with care! It reduces the delay time
between packets to 0.

bd_addr
The Bluetooth MAC address to be pinged in dotted hex notation
like 01:02:03:ab:cd:ef or 01:EF:cd:aB:02:03


(5) hcidump
hcidump [-h]
hcidump [option [option...]] [filter]

commands
-h Prints usage info and exits

-i <hciX>
Data is read from hciX, which must be the name of an installed
Bluetooth device. If not specified, and if -r option is not set,
data is read from the first available Bluetooth device.

-l <len>, --snap-len=<len>
Sets max length of processed packets to len.

-p <psm>, --psm=<psm>
Sets default Protocol Service Multiplexer to psm.

-m <compid>, --manufacturer=<compid>
Sets default company id for manufacturer to compid.

-w <file>, --save-dump=<file>
Parse output is not printed to screen, instead data read from
device is saved in file file. The saved dump file can be subse-
quently parsed with option -r.

-r <file>, --read-dump=<file>
Data is not read from a Bluetooth device, but from file file.
file is crated with option -w.

-s <host>, --send-dump=<host>
Parse output is not printed to screen, instead data read from
device is send to host host.

-n <host>, --recv-dump=<host>
Data is not read from a Bluetooth device, but from host host.

-t, --timestamp
Prepend a time stamp to every packet.

-a, --ascii
For every packet, not only is the packet type displayed, but
also all data in ASCII.

-x, --hex
For every packet, not only is the packet type displayed, but
also all data in hex.

-X, --ext
For every packet, not only is the packet type displayed, but
also all data in hex and ASCII.

-R, --raw
Raw mode: do not display packet type, only data.

-B, --bpa
BPA mode: only display vendor specific data packets.

-C, --cmtp
Sets the PSM value for the CAPI Message Transport Protocol

-H, --hcrp
Sets the PSM value for the Hardcopy Control Channel

-O, --obex
Sets the RFCOMM channel value for the Object Exchange protocol

-V, --verbose
Enables a more verbose decoding of every packet.




You can use these hci tool to debug for your bluetooth, when you fall-in debug cycle.
HCI is a protocal layer, you can know more from google.





arrow
arrow
    全站熱搜

    owenhuangtw 發表在 痞客邦 留言(0) 人氣()