hciconfig 和 hcitool 是 Linux 中的命令行工具,用于管理 Bluetooth 设备。下面是这两个工具的常用用法:
hciconfig
- hciconfig -a:显示所有可用的 Bluetooth 设备的详细信息。
- hciconfig hci0 up:启用 hci0 设备。
- hciconfig hci0 down:禁用 hci0 设备。
- hciconfig hci0 reset:重置 hci0 设备。
- hciconfig hci0 piscan:启用 hci0 设备的可发现模式。
- hciconfig hci0 noscan:禁用 hci0 设备的可发现模式。
hcitool
- hcitool scan:扫描周围的可见 Bluetooth 设备。
- hcitool dev:显示已连接的 Bluetooth 设备的列表。
- hcitool con:显示已建立连接的 Bluetooth 设备的列表。
- hcitool lq :显示与指定蓝牙地址的设备的信号质量。
- hcitool cc :尝试与指定蓝牙地址的设备建立连接。
- hcitool dc :断开与指定蓝牙地址的设备的连接。
注意:hci0、hci1 等表示蓝牙设备的名称可能会有所不同,请查看 hciconfig -a 输出的信息以获取正确的设备名称。