终端中的蓝牙

Gro*_*ile 3 linux shell terminal bluetooth

我想在不使用蓝牙 GUI 的情况下在终端中查看蓝牙适配器的详细信息。最初蓝牙在终端和 GUI 中都是关闭的。

我在终端中针对不同功能的命令

查看蓝牙的状态(在某些情况下它会显示活动/非活动和状态,而在其他一些情况下只会显示活动/非活动)

sudo /etc/init.d/bluetooth status
Run Code Online (Sandbox Code Playgroud)

打开蓝牙

sudo /etc/init.d/bluetooth start
Run Code Online (Sandbox Code Playgroud)

关闭蓝牙

sudo /etc/init.d/bluetooth stop
Run Code Online (Sandbox Code Playgroud)

查看蓝牙适配器详情

hciconfig
Run Code Online (Sandbox Code Playgroud)

我可以在设置 GUI 中的蓝牙 GUI 的帮助下查看适配器详细信息。

我通过按顺序执行以下步骤研究了不同情况下蓝牙的状态:

1.通过终端开启蓝牙

  • 状态 =“正在运行”
  • 活动 = “活动(运行)”
  • 蓝牙适配器详细信息:不显示任何内容

2.通过终端关闭蓝牙

  • 状态 = 未显示
  • 活动 = “不活动(死)”
  • 蓝牙适配器详细信息:不显示任何内容

3.通过GUI打开蓝牙

  • 状态 =“正在运行”
  • 活动 = “活动(运行)”
  • 蓝牙适配器详细信息:显示适配器详细信息

4.通过终端关闭蓝牙,但在GUI中没有变化

  • 状态 = "退出"
  • 活动 = “不活动(死)”
  • 蓝牙适配器详细信息:显示适配器详细信息

5.通过终端开启蓝牙

  • 状态 =“正在运行”
  • 活动 = “活动(运行)”
  • 蓝牙适配器详细信息:显示适配器详细信息

6.通过终端关闭蓝牙,但在GUI中没有变化

  • 状态 = "退出"
  • 活动 = “不活动(死)”
  • 蓝牙适配器详细信息:显示适配器详细信息

7.在GUI中关闭蓝牙

  • 状态 = 未显示
  • 活动 = “不活动(死)”
  • 蓝牙适配器详细信息:不显示任何内容

有人可以帮助我我的命令有什么问题吗?另外,为什么它可以与 GUI 一起正常工作?GUI实际上是做什么的?

VeR*_*eRo 5

试试这个工具:

bluetoothctl
Run Code Online (Sandbox Code Playgroud)

这是安装指南:(https://wiki.archlinux.org/index.php/bluetooth#Installation

它为您提供了很多可能性:

Menu main:
Available commands:
-------------------
advertise                                         Advertise Options Submenu
scan                                              Scan Options Submenu
gatt                                              Generic Attribute Submenu
list                                              List available controllers
show [ctrl]                                       Controller information
select <ctrl>                                     Select default controller
devices                                           List available devices
paired-devices                                    List paired devices
system-alias <name>                               Set controller alias
reset-alias                                       Reset controller alias
power <on/off>                                    Set controller power
pairable <on/off>                                 Set controller pairable mode
discoverable <on/off>                             Set controller discoverable mode
agent <on/off/capability>                         Enable/disable agent with given capability
default-agent                                     Set agent as the default one
advertise <on/off/type>                           Enable/disable advertising with given type
set-alias <alias>                                 Set device alias
scan <on/off>                                     Scan for devices
info [dev]                                        Device information
pair [dev]                                        Pair with device
trust [dev]                                       Trust device
untrust [dev]                                     Untrust device
block [dev]                                       Block device
unblock [dev]                                     Unblock device
remove <dev>                                      Remove device
connect <dev>                                     Connect device
disconnect [dev]                                  Disconnect device
menu <name>                                       Select submenu
version                                           Display version
quit                                              Quit program
exit                                              Quit program
help                                              Display help about this program
Run Code Online (Sandbox Code Playgroud)

您甚至可以深入了解广告政策等:

# menu advertise 
Menu advertise:
Available commands:
-------------------
uuids [uuid1 uuid2 ...]                           Set/Get advertise uuids
service [uuid] [data=xx xx ...]                   Set/Get advertise service data
manufacturer [id] [data=xx xx ...]                Set/Get advertise manufacturer data
tx-power [on/off]                                 Show/Enable/Disable TX power to be advertised
name [on/off/name]                                Configure local name to be advertised
appearance [on/off/value]                         Configure custom appearance to be advertised
duration [seconds]                                Set/Get advertise duration
timeout [seconds]                                 Set/Get advertise timeout
clear [uuids/service/manufacturer/config-name...] Clear advertise config
back                                              Return to main menu
version                                           Display version
quit                                              Quit program
exit                                              Quit program
help                                              Display help about this program
Run Code Online (Sandbox Code Playgroud)

这是您可以直接提取(和设置)的大量信息。