3.2 hcitool scan for bluetooth devices

澳门微尼斯人手机版,Before start scanning make sure that your bluetooth device is turned on
and not blocked, you can check that with the rfkill command:

sudo rfkill list

If the bluetooth device is blocked (soft or hard blocked), unblock it
with the rfkill command again:

sudo rfkill unblock bluetooth

Bring up the bluetooth device with hciconfig command and start scanning,
make sure the target device’s bluetooth is on and It’s discoverable:

sudo hciconfig hci0 up
hcitool scan

Wait few moment to complete the hcitool scan or hcitool lescan, the
results will be something like bellow:

澳门微尼斯人手机版 1

澳门微尼斯人手机版 2

Here 00:1A:7D:DA:71:0A is the bluetooth MAC address and SHEN-PC is the
name of the bluetooth device, i.e. an PC.

note: use hcitool lescan will forever scan ble devices, if use
ctrl+c stop it, it will show error(ref to LINKS
to solve):

hcitool lescan
Set scan parameters failed: Input/output error


 澳门微尼斯人手机版 3

澳门微尼斯人手机版 4



3.3 bluetooth service discovery

Now we have the bluetooth MAC address of the target device, use the
sdptool command to know which services (like DUN, Handsfree audio) are
available on that target device.

sdptool browse 28:ED:6A:A0:26:B7

You can also use the interactive bluetoothctl tool for this purpose.

If the target device is present, you can ping it with l2ping command,
requires root privilege:

➜  bluez-5.50  sudo l2ping 94:87:E0:B3:AC:6F
Ping: 94:87:E0:B3:AC:6F from B8:27:EB:8E:CC:51 (data size 44) ...
44 bytes from 94:87:E0:B3:AC:6F id 0 time 53.94ms
44 bytes from 94:87:E0:B3:AC:6F id 1 time 77.12ms
44 bytes from 94:87:E0:B3:AC:6F id 2 time 38.63ms
44 bytes from 94:87:E0:B3:AC:6F id 3 time 46.13ms
44 bytes from 94:87:E0:B3:AC:6F id 4 time 59.96ms
5 sent, 5 received, 0% loss

So, bluetooth service discovery is useful to determine the type of the
device, like if it’s a bluetooth mp3 player or it’s a keyboard.

澳门微尼斯人手机版 5



3.1 setup bluetooth service

Start the bluetooth service and enable automatic startup, assuming
you’re using systemd as the init daemon:

sudo systemctl start bluetooth.service
sudo systemctl enable bluetooth.service



1. Introduction

Bluez is the default Bluetooth protocol stack on Linux. It should be
present and installed on your Linux distribution. If not, building and
installing from source is not too difficult:

  • Download the latest stable source release of Bluez from here. Unzip
    the compressed file you downloaded.
  • Install the headers and libraries required for Bluez compilation:

澳门微尼斯人手机版 6

              *cout<<“you select cancel”<<endl*;

澳门微尼斯人手机版 7澳门微尼斯人手机版 8


  • 1.Bluetooth on Modern Linux by Szymon
  • 2.dbus-python
  • 3.Linux bluetooth setup with bluez and
  • 4.hcitool lescan shows I/O

澳门微尼斯人手机版 9




电子邮件地址不会被公开。 必填项已用*标注