Linux Commands Examples

A great documentation place for Linux commands

hcitool

configure Bluetooth connections

Synopsis

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


add an example, a script, a trick and tips

: email address (won't be displayed)
: name

Step 2

Thanks for this example ! - It will be moderated and published shortly.

Feel free to post other examples
Oops ! There is a tiny cockup. A damn 404 cockup. Please contact the loosy team who maintains and develops this wonderful site by clicking in the mighty feedback button on the side of the page. Say what happened. Thanks!

examples

11
source
            
hcitool cmd 0x03 0x03
hcitool cmd 0x03 0x05 0x02 0x00 0x02
hcitool cmd 0x03 0x1A 0x03
hcitool cmd 0x06 0x03
3
source
            
for s in $(/usr/bin/hcitool con); do
if [ "$s" == "$DEVICE" ]; then
echo "$DEVICE connected already"
if [ -z "$(/usr/bin/hcitool cc $DEVICE 2>&1)" ]; then
echo "$DEVICE connected"
/usr/bin/hcitool rssi $DEVICE
1
source
            
hciconfig hci0 up
hcitool cmd 0x06 0x0003
hcitool cmd 0x03 0x0005 0x02 0x00 0x02
hcitool cmd 0x03 0x001A 0x03
hcitool cmd 0x03 0x0020 0x00
hcitool cmd 0x03 0x0020 0x00
hcitool cmd 0x03 0x0022 0x00
0
source
            
echo getting localhost bluetooth
hcitool dev
echo Inquiring other bluetooth devices
sdptool search SP
0
source
            
echo "hcitool scan"
hcitool scan
GPS=`hcitool scan | grep -e 'iBT-GPS' -e 'Bluetooth GPS' | head -1| sed 's/ //g'`
echo "hcitool info $GPS_MAC"
hcitool info $GPS_MAC
echo ""
echo "-----------------------------------"

description

hcitool is used to configure Bluetooth connections and send some special command to Bluetooth devices. If no command is given, or if the option -h is used, hcitool prints some usage information and exits.

options

-h

Gives a list of possible commands

-i <hciX>

The command is applied to device hciX , which must be the name of an installed Bluetooth device. If not specified, the command will be sent to the first available Bluetooth device.

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 are 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.

spinq

Start periodic inquiry process. No inquiry results are printed.

epinq

Exit periodic inquiry process.

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> [reason]

Delete baseband connection from remote device with Bluetooth address bdaddr. The reason can be one of the Bluetooth HCI error codes. Default is 19 for user ended connections. The value must be given in decimal.

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 Bluetooth 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 Bluetooth 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 current transmit power level (which is default) or 1 for the maximum transmit power level.

afh <bdaddr>

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

lp <bdaddr> [value]

With no value, displays link policy settings for the connection to the device with Bluetooth address bdaddr. If value is given, sets the link policy settings for that connection to value. Possible values are RSWITCH, HOLD, SNIFF and PARK.

lst <bdaddr> [value]

With no value, displays link supervision timeout for the connection 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).


authors

Written by Maxim Krasnyansky <maxk[:at:]qualcomm[:dot:]com> and Marcel Holtmann <marcel[:at:]holtmann[:dot:]org>

man page by Fabrizio Gennari <fabrizio.gennari[:at:]philips[:dot:]com>

How can this site be more helpful to YOU ?


give  feedback