How to scan Bluetooth devices

Stable: 26.11.2021 - 13:23 / Revision: 04.10.2021 - 11:56

I am here to prevent the first-page-empty bug!

Template:ArticleMainWriter Template:ArticleApprovedVersion


1 Scan for available Bluetooth devices

 hcitool scan
Scanning ...
       A0:AF:BD:3B:26:61       lmecxl0923
       B0:55:08:40:33:84       HUAWEI P8 lite 2017

2 Setting the device to Visible

To control the visiblity of our Bluetooth device to other Bluetooth hardware.

  • to enable visibility:
 hciconfig hciX piscan

(hciX corresponds to the available Bluetooth hardware: hci0)

  • To disable visibility:
 hciconfig hciX noscan

(hciX corresponds to the available Bluetooth hardware: hci0)

3 How to scan via bluetoothd/systemd

Systemd provides a tool for Bluetooth management: bluetoothctl.
Example session with bluetoothclt for scanning, pairing, connecting:

 bluetoothctl
[NEW] Controller 43:43:A1:12:1F:AC stm32mp1 [default]
Agent registered
[bluetooth]# power on
Changing power on succeeded
[CHG] Controller 43:43:A1:12:1F:AC Powered: yes
[bluetooth]# agent on
Agent is already registered
[bluetooth]# default-agent
Default agent request successful
[bluetooth]# scan on
Discovery started
[CHG] Controller 43:43:A1:12:1F:AC Discovering: yes
[NEW] Device D8:DB:36:D1:39:88 STM
...
[bluetooth]# scan off
[CHG] Controller 43:43:A1:12:1F:AC Discovering: no
Discovery stopped
[bluetooth]#pair D8:DB:36:D1:39:88
Pairing successful
[bluetooth]# connect D8:DB:36:D1:39:88
Connection successful
[STM]# quit
Agent unregistered
[DEL] Controller 43:43:A1:12:1F:AC stm32mp1 [default]
IMPORTANT NOTICE – READ CAREFULLY
STMicroelectronics NV and its subsidiaries ("ST") reserve the right to make changes, corrections, enhancements, modifications, and improvements to ST products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on ST products before placing orders. ST products are sold pursuant to ST’s terms and conditions of sale in place at the time of order acknowledgment.

Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or the design of purchasers’ products.

No license, express or implied, to any intellectual property right is granted by ST herein.

Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product.

ST and the ST logo are trademarks of ST. For additional information about ST trademarks, refer to www.st.com/trademarks. All other product or service names are the property of their respective owners.

Information in this document supersedes and replaces information previously supplied in any prior versions of this document.