如何打开和关闭蓝牙可见性模式?

Avi*_*Raj 13 command-line bluetooth

我已经通过sudo rfkill unblock bluetooth在终端上运行命令打开了我的蓝牙。我也想打开我的蓝牙可见性模式,这样只有我的设备会被检测到。我必须从命令行做的一切。

如何从命令行在 Ubuntu 14.04 中打开和关闭蓝牙的可见性模式?

Tak*_*kat 15

在 BlueZ >= 5 设备的命令行控制可以使用btmgmt工具完成:

sudo btmgmt
[mgmt]# help         # list commands
[mgmt]# info         # list device(s)
[mgmt]# select hciX  # select a known device by index X eg. hci0
[hci0]# discov yes   # make hci0 visible/discoverable
[hic0]# discov no    # make hci0 invisible
Run Code Online (Sandbox Code Playgroud)

在旧版本的 BlueZ 中,我们可以使用命令行工具hciconfig控制我们的蓝牙设备。

启用可见性

sudo hciconfig hciX piscan
Run Code Online (Sandbox Code Playgroud)

禁用可见性

sudo hciconfig hciX noscan
Run Code Online (Sandbox Code Playgroud)

替换hciX为您的设备(通常hci0

要查询您的蓝牙设备:

sudo hciconfig -a
Run Code Online (Sandbox Code Playgroud)