“How to scan Bluetooth devices”的版本间的差异
来自百问网嵌入式Linux wiki
(未显示1个用户的2个中间版本) | |||
第1行: | 第1行: | ||
+ | {{DISPLAYTITLE:如何扫描蓝牙设备}} | ||
+ | =如何扫描蓝牙设备= | ||
+ | ==扫描可用的蓝牙设备== | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | Board $> hcitool scan | ||
+ | Scanning ... | ||
+ | A0:AF:BD:3B:26:61 lmecxl0923 | ||
+ | B0:55:08:40:33:84 HUAWEI P8 lite 2017 | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | ==将设备设置为可见== | ||
+ | : 设置我们的蓝牙设备对其他蓝牙设备的可见性。 | ||
+ | |||
+ | :: 启用可见性: | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | Board $> hciconfig hciX piscan | ||
+ | </syntaxhighlight> | ||
+ | : (hciX对应于可用的蓝牙硬件:hci0) | ||
+ | |||
+ | :: 禁用可见性: | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | Board $> hciconfig hciX noscan | ||
+ | </syntaxhighlight> | ||
+ | : (hciX对应于可用的蓝牙硬件:hci0) | ||
+ | |||
+ | ==如何通过蓝牙/系统扫描== | ||
+ | : Systemd 提供了用于蓝牙管理的工具:bluetoothctl。 | ||
+ | : 使用蓝牙进行扫描、配对和连接的示例会话过程: | ||
+ | <syntaxhighlight lang="bash"> | ||
+ | Board $> 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] | ||
+ | </syntaxhighlight> | ||
+ | |||
[[Category:Linux_Operating_System]] | [[Category:Linux_Operating_System]] | ||
[[Category:Networking]] | [[Category:Networking]] | ||
[[Category:Bluetooth]] | [[Category:Bluetooth]] |
2020年1月10日 (五) 10:43的最新版本
如何扫描蓝牙设备
扫描可用的蓝牙设备
Board $> hcitool scan
Scanning ...
A0:AF:BD:3B:26:61 lmecxl0923
B0:55:08:40:33:84 HUAWEI P8 lite 2017
将设备设置为可见
- 设置我们的蓝牙设备对其他蓝牙设备的可见性。
- 启用可见性:
Board $> hciconfig hciX piscan
- (hciX对应于可用的蓝牙硬件:hci0)
- 禁用可见性:
Board $> hciconfig hciX noscan
- (hciX对应于可用的蓝牙硬件:hci0)
如何通过蓝牙/系统扫描
- Systemd 提供了用于蓝牙管理的工具:bluetoothctl。
- 使用蓝牙进行扫描、配对和连接的示例会话过程:
Board $> 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]