linux - 终端中的蓝牙

标签 linux shell terminal bluetooth

我想在不使用蓝牙 GUI 的情况下在终端中查看蓝牙适配器的详细信息。最初,蓝牙在终端和 GUI 中均处于关闭状态。

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

查看蓝牙状态(有的会显示active/inactive和status,有的只显示active/inactive)

sudo /etc/init.d/bluetooth status

打开蓝牙

sudo /etc/init.d/bluetooth start

关闭蓝牙

sudo /etc/init.d/bluetooth stop

查看蓝牙适配器详情

hciconfig

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

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

1。通过终端打开蓝牙

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

2。通过终端关闭蓝牙

  • 状态 = 未显示
  • Active = "inactive (dead)"
  • 蓝牙适配器详细信息:不显示任何内容

3。通过 GUI 打开蓝牙

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

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

  • Status = "正在退出"
  • Active = "inactive (dead)"
  • 蓝牙适配器详细信息:显示适配器详细信息

5。通过终端打开蓝牙

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

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

  • Status = "正在退出"
  • Active = "inactive (dead)"
  • 蓝牙适配器详细信息:显示适配器详细信息

7.在 GUI 中关闭蓝牙

  • 状态 = 未显示
  • Active = "inactive (dead)"
  • 蓝牙适配器详细信息:不显示任何内容

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

最佳答案

试试这个工具:

bluetoothctl

安装指南如下: ( 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

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

# 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

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

关于linux - 终端中的蓝牙,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39490971/

相关文章:

linux - systemtap的内部结构

linux - shell 中的整数加法

c++ - 检测 `cout` 是否输出到正确接受颜色的终端?

linux - 修改 ls 输出以在目录前显示 [+]

c - 给出 5 个参数,但在终端中只得到 3 个参数

android - 如何永久删除SD卡上的数据

Linux vnc端口关闭

linux - 需要读取文件并将结果用作 shell 脚本中的命名变量

android - Ubuntu/Elementary OS 无法设置 ANDROID_HOME

java - 完全传递值生成