Bluetooth

This article describes the setup of Bluetooth controllers.

Prerequisites
This article assumes that udev, USB and/or PC-Card have been previously configured.

Kernel
Use the table below to determine which Bluetooth subsystem you need to enable. In most cases enabling RFCOMM, HIDP, HCI USB and/or HCI UART will be sufficient.

Software
Bluetooth user space support is provided by. Portage has ebuilds for BlueZ 4 (deprecated) and BlueZ 5.

You can enable Bluetooth support globally by adding bluetooth to the USE variable.

If you require BlueZ 4 you can mask BlueZ 5 to prevent it from being installed.

If you enabled the bluetooth USE flag globally you should update your system. This will automatically install BlueZ.

If you didn't enable the bluetooth USE flag globally you will need to manually install BlueZ.

Permissions
If you have the acl USE flag enabled globally and are using ConsoleKit or systemd, then permissions for Bluetooth devices will be handled automatically.

An alternative is to add the user you want to be able to access Bluetooth devices to the plugdev group.

Bring interface up at bootup time
In case you need to use trusted Bluetooth devices before a GUI is up and running, you can use an udev rule:

Starting
To start Bluetooth:

To start Bluetooth at boot:

Controller setup
Check that your Bluetooth adapter is working.

Device pairing
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. They always use the same PIN which is usually 0000 or 9999. If you don't know the PIN check your devices user manual.

This article only covers device pairing with command-line interaction agents. If you have a graphical desktop environment you can perform device paring with graphical interaction agents. You can use for KDE,  for GNOME and  for GTK+.

BlueZ 4
Device paring is done with, which requires that you enable the test-programs USE flag for.


 * Put the device into pairing mode. This generally involves pressing a button or a combinations of buttons, usually for several seconds.


 * Discover the device MAC address.

Where 00:1F:20:1D:1B:4B is the MAC address of your device.


 * Pair with the device.

Enter a PIN and press. Now enter the same PIN on your device.


 * If you have a graphical interaction agent (BlueDevil, GNOME Bluetooth etc.) installed you may receive the following message when pairing with the device.

In this case you need stop or disable the graphical interaction agent and attempt to pair with the device again.


 * Check the trust status of your device.

Where 0 is not trusted and 1 is trusted.


 * Trust the device so it can connect automatically.


 * Connect to the device. If the device is trusted you only need to do this once.


 * Your device is now paired.

BlueZ 5
Device paring is done with, which is available with all  installations.


 * Start bluetoothctl.


 * List the available controllers.


 * Display information about a controller.


 * Set the default controller.


 * Power on the controller.


 * Enable the agent and set it as default.


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


 * Scan for devices.


 * Put the device into pairing mode.


 * Discover the device MAC address.


 * Pair with the device.


 * If requested enter the PIN code.


 * Trust the device.


 * Connect to the device.


 * Display information about the device.