Home » Linux Kernel » Linux Device Drivers » Bluetooth driver » Use hcitool to get Bluetooth device information

Use hcitool to get Bluetooth device information

Below commands are shown for communication between Linux Laptop and Samsung Mobile to get Mobile bluetooth device information using hcitool. For this, first make sure laptop bluetooth is turned ON and then switch ON the Bluetooth of Mobile and Make it discoverable/visible to all nearby bluetooth devices.

Lets try to understand what is hcitool,

$ whatis hcitool

hcitool (1) – configure Bluetooth connections

$ hcitool --help 

hcitool – HCI Tool ver 5.37
Usage:
hcitool [options] [command parameters]
Options:
–help Display help
-i dev HCI device
Commands:
dev Display local devices
inq Inquire remote devices
scan Scan for remote devices
name Get name from remote device
info Get information from remote device
spinq Start periodic inquiry
epinq Exit periodic inquiry
cmd Submit arbitrary HCI commands
con Display active connections
cc Create connection to remote device
dc Disconnect from remote device
sr Switch master/slave role
cpt Change connection packet type
rssi Display connection RSSI
lq Display link quality
tpl Display transmit power level
afh Display AFH channel map
lp Set/display link policy settings
lst Set/display link supervision timeout
auth Request authentication
enc Set connection encryption
key Change connection link key
clkoff Read clock offset
clock Read local or remote clock
lescan Start LE scan
leinfo Get LE remote information
lewladd Add device to LE White List
lewlrm Remove device from LE White List
lewlsz Read size of LE White List
lewlclr Clear LE White List
lerladd Add device to LE Resolving List
lerlrm Remove device from LE Resolving List
lerlclr Clear LE Resolving List
lerlsz Read size of LE Resolving List
lerlon Enable LE Address Resolution
lerloff Disable LE Address Resolution
lecc Create a LE Connection
ledc Disconnect a LE Connection
lecup LE Connection Update

For more information on the usage of each command use:
hcitool –help

So, hcitool supports above subcommands to identify information.

Lets try to scan ( Scan for remote devices ) all the devices nearby our laptop, for that use command,

$ hcitool scan
Scanning ...
	9C:65:B0:A0:1E:BD	MY Mobile (GT-I9300I)

Inquire remote devices, for this we need to use below command,

$ hcitool inq
Inquiring ...
 9C:65:B0:A0:1E:BD clock offset: 0x2bf1 class: 0x5a020c

Get name from remote device

$ hcitool name "9C:65:B0:A0:1E:BD"
MY Mobile (GT-I9300I)

Get information from remote device

$ sudo hcitool info 9C:65:B0:A0:1E:BD

password for myuser: Requesting information … BD Address: 9C:65:B0:A0:1E:BD OUI Company: Samsung Electronics Co.,Ltd (9C-65-B0) Device Name: MY Mobile (GT-I9300I) LMP Version: 4.0 (0x6) LMP Subversion: 0x7d3 Manufacturer: Qualcomm (29) Features page 0: 0xff 0xfe 0x8f 0xfe 0xd8 0x3f 0x5b 0x87 <3-slot packets> <5-slot packets> <3-slot EDR ACL> <5-slot EDR ACL> Features page 1: 0x03 0x00 0x00 0x00 0x00 0x00 0x00 0x00 Features page 2: 0x00 0x03 0x00 0x00 0x00 0x00 0x00 0x00

Now pair the mobile with Laptop to create connection ( pair from GUI)

con – Display active connections

$ sudo hcitool con
Connections:
< ACL 38:EC:E4:50:2C:F7 handle 11 state 1 lm MASTER AUTH ENCRYPT

rssi – Display connection RSSI

$ sudo hcitool rssi 38:EC:E4:50:2C:F7
RSSI return value: 0

Displaying Information about the Laptop Bluetooth Device

Display local devices

$ hcitool dev
Devices:
	hci0	70:1A:04:59:69:04 

Submit arbitrary HCI commands

$ sudo hcitool cmd 0x03 0x0013 0x41 0x42 0x43 0x44
 HCI Event: 0x0e plen 4
  01 13 0C 00 

Subscribe our Rurban Life YouTube Channel.. "Rural Life, Urban LifeStyle"

Leave a Comment