Bluetooth/zh-cn

这篇文章Article description::介绍了蓝牙控制器和蓝牙设备的配置和使用.

准备
本文假设 udev 和 USB 之前已经配置好.

内核
In most cases enabling RFCOMM ( CONFIG_RFCOMM ), HIDP ( CONFIG_BT_HIDP ), HCI USB ( CONFIG_BT_HCIBTUSB ) and/or HCI UART ( CONFIG_BT_HCIUART ) should be sufficient. The User-space I/O driver for HID input devices ( CONFIG_UHID ) should be enabled for Bluetooth keyboards and mice.

固件
大多数蓝牙控制器需要 firmware 才能运行. 如果 Linux 支持控制器， 通常会指示是否需要固件. 软件包应提供所需的固件，尽管某些设备可能需要仅从制造商处才能获得的固件.

USE 标记
BlueZ 是 Linux 蓝牙协议栈的实现，由 包提供.

通过将 USE 变量设置为 ，可以在系统范围内启用蓝牙支持：

Emerge
如果 USE 变量设置为 ，则系统需要更新：

安装 BlueZ:

权限
Permissions for Bluetooth devices is handled automatically by D-Bus, and access is granted to all users by default.

OpenRC
启动蓝牙：

开机时启动蓝牙：

systemd
启动蓝牙：

开机时启动蓝牙：

安装蓝牙控制器
显示控制器信息：

Where  is the name of the controller, and   (3rd line) indicates that the controller is enabled.

Enable the controller if indicates (with  ) (3rd line) that the controller is disabled:

In this case, query the state of the Bluetooth radio transmitter with :

可以与 软件包或 >=-2.31 软件包一起安装.

如果 指示（带有  ）控制器被阻止，则解锁控制器：

如果 指示（带有  ）控制器被阻塞，则通过物理开关或键盘功能键解锁控制器.

通过在 中设置   可以自动启用蓝牙控制器：

In some instances Bluetooth controllers may have been soft-blocked by power management tools in udev. Make sure state is set to  in the corresponding rule file, or remove the following line entirely:

配对设备
Bluetooth devices need to be paired with a Bluetooth controller before they can be used. This is done by entering a PIN (or other code) on both devices via an interaction agent. Certain devices such as headsets do not allow entering an arbitrary PIN. These devices use a static PIN, which is usually 0000, 1111, 1234 or 9999. There are also devices (e.g. Sony BD Remote Control) that do not require PIN entry, and attempting to enter a PIN when prompted will result in failure. Paring can be skipped with such devices.

This article only covers device pairing with, which is a command-line interaction agent provided by the package. If a graphical desktop environment is being used, device paring can be done with a graphical interaction agent. For KDE use, for GNOME use , and for GTK use or.

启动 ：

列出可用控制器：

显示一个控制器的信息：

设置默认控制器：

Power on the controller:

Enable the agent and set it as default:

Set the controller as discoverable (temporarily for 3 minutes) and pairable:

扫描设备：

将设备置于配对模式. 这一般涉及按下按钮或按钮组合，通常持续几秒钟.

发现设备 MAC 地址：

与设备配对：

按照提示输入 ：

如果被请求，允许服务授权：

信任设备：

连接设备：

显示设备信息：

现在设备已经配对完成：

Disable Bluetooth
To disable Bluetooth at runtime, run the following command:

To disable Bluetooth automatically on every boot, choose one of the following options:

Using udev to disable Bluetooth
When using UDEV, just install the following rule which will disable Bluetooth:

Using OpenRC to disable Bluetooth
When using, install the following script for local service and ensure it is executable:

Disable Bluetooth at kernel level
When the kernel has modular Bluetooth support, disable loading of Bluetooth modules:

TLP and laptop_mode
If laptop-mode-tools is installed or TLP make sure they're not disabling Bluetooth to save power.