Bluetooth: Difference between revisions

From Alpine Linux
m (added WIP)
(added pairing instructions for bluetoothctl, formatting)
Line 1: Line 1:
{{Draft|Spotty internet is slowing me down}}
{{Draft|work in progress}}


[https://en.wikipedia.org/wiki/Bluetooth Bluetooth] is a standard for the short-range wireless interconnection of cellular phones, computers, and other electronic devices. [http://www.bluez.org/ BlueZ] is an implementation of the Bluetooth protocol stack for Linux, and it is provided by the {{Pkg|bluez}} package.
[https://en.wikipedia.org/wiki/Bluetooth Bluetooth] is a standard for the short-range wireless interconnection of cellular phones, computers, and other electronic devices. [http://www.bluez.org/ BlueZ] is an implementation of the Bluetooth protocol stack for Linux, and it is provided by the {{Pkg|bluez}} package.
Line 30: Line 30:
# rc-update add bluetooth default}}
# rc-update add bluetooth default}}


== Basic Configuration ==
Now, check the state of the Bluetooth radio transmitter using <code>rfkill</code>:
 
{{Cmd|$ rfkill list bluetooth}}
 
It should return something similar to:
 
0: hci0: Bluetooth
        Soft blocked: no
        Hard blocked: no
 
If the device is listed as blocked, it can be unblocked using the same tool:
 
{{Cmd|# rfkill unblock bluetooth}}
 
{{Note|It may be necessary to restart the Bluetooth service before continuing.}}
 
=== Front-ends ===
 
There are several front-ends available:
 
* The {{Pkg|bluez}} comes with the <code>bluetoothctl</code> front-end
* {{Pkg|blueman}}: a full-featured Bluetooth manager
* {{Pkg|bluedevil}}: the [[KDE]] Bluetooth manager
* {{Pkg|gnome-bluetooth}}: the [[Gnome]] Bluetooth manager
 
== Pairing ==
 
=== Using <code>bluetoothctl</code> ===
 
Begin by starting <code>bluetoothctl</code> and follow these basic steps:
 
{{Cmd|$ bluetoothctl}}
 
The prompt should display:
 
<span style="color:blue;">[bluetooth]</span>#
 
List the available controllers:
 
<span style="color:blue;">[bluetooth]</span># list
 
Display information about a controller:
 
<span style="color:blue;">[bluetooth]</span># show ''controller_mac_address''
 
Set the default controller:
 
<span style="color:blue;">[bluetooth]</span># select ''controller_mac_address''
 
Power on the controller:
 
<span style="color:blue;">[bluetooth]</span># power on
 
Enable the agent and set it as default:
 
<span style="color:blue;">[bluetooth]</span># agent on
<span style="color:blue;">[bluetooth]</span># default-agent
 
Set the controller as discoverable (temporarily for 3 minutes) and pairable:
 
<span style="color:blue;">[bluetooth]</span># discoverable on
<span style="color:blue;">[bluetooth]</span># pairable on
 
Scan for devices:
 
<span style="color:blue;">[bluetooth]</span># scan on
 
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:
 
<span style="color:blue;">[bluetooth]</span># devices
 
Pair with the device:
 
<span style="color:blue;">[bluetooth]</span># pair ''device_mac_address''
 
Enter the PIN if prompted:
 
<span style="color:red;">[agent]</span> PIN code: ####
 
Trust the device:
 
<span style="color:blue;">[bluetooth]</span># #trust ''device_mac_address''
 
Connect to the device:
 
<span style="color:blue;">[bluetooth]</span># connect ''device_mac_address''
 
Display information about the device:
 
<span style="color:blue;">[bluetooth]</span># info ''device_mac_address''
 
The device is now paired:
 
<span style="color:blue;">[bluetooth]</span># quit
 
== Configuration ==
 
=== Set adapter power state ===
 
If you would like the adapter to not be automatically enabled (e.g. on a portable device where you wish to save battery), set <code>AutoEnable=false</code> in <code>/etc/bluetooth/main.conf</code> in the <code>[Policy]</code> section:
 
 
{{Cat|/etc/bluetooth/main.conf|[Policy]
...
AutoEnable&#61;false
...}}


=== Battery Reporting ===
=== Battery Reporting ===


An experimental feature can be enabled in order to report device battery level:
An experimental feature can be enabled in order to report device battery level:


{{Cat|/etc/bluetooth/main.conf|[General]
{{Cat|/etc/bluetooth/main.conf|[General]
...
...
Experimental=true
Experimental&#61;true
...}}
...}}


== Basic Use ==
== Troubleshooting ==
 
{{Todo|add example for "no default controller" error and how to find missing drivers}}
 
== See Also ==


* [https://wiki.gentoo.org/wiki/Bluetooth Bluetooth entry on Gentoo Wiki]
* [https://wiki.archlinux.org/title/Bluetooth Bluetooth entry on ArchWiki]


[[Category:Multimedia]]
[[Category:Multimedia]]
[[Category:Hardware]]
[[Category:Hardware]]
[[Category:Newbie]]
[[Category:Newbie]]

Revision as of 09:09, 17 April 2023

This material is work-in-progress ...

work in progress
(Last edited by Bbbhltz on 17 Apr 2023.)

Bluetooth is a standard for the short-range wireless interconnection of cellular phones, computers, and other electronic devices. BlueZ is an implementation of the Bluetooth protocol stack for Linux, and it is provided by the bluez package.

This article describes the basic installation of Bluetooth controllers and devices.

Prerequisites and Basic Installation

Prerequisites

eudev should be installed and setup:

# setup-devd udev

Basic Installation

Basic installation is as follows:

  1. Install bluez
  2. Load the btusb kernel module
  3. Add user to the lp group
  4. Start and enable the Bluetooth service

# apk add bluez # apk add bluez-deprecated # modprobe btusb # adduser $USER lp # rc-service bluetooth start # rc-update add bluetooth default

Now, check the state of the Bluetooth radio transmitter using rfkill:

$ rfkill list bluetooth

It should return something similar to:

0: hci0: Bluetooth
        Soft blocked: no
        Hard blocked: no

If the device is listed as blocked, it can be unblocked using the same tool:

# rfkill unblock bluetooth

Note: It may be necessary to restart the Bluetooth service before continuing.

Front-ends

There are several front-ends available:

Pairing

Using bluetoothctl

Begin by starting bluetoothctl and follow these basic steps:

$ bluetoothctl

The prompt should display:

[bluetooth]#

List the available controllers:

[bluetooth]# list

Display information about a controller:

[bluetooth]# show controller_mac_address

Set the default controller:

[bluetooth]# select controller_mac_address

Power on the controller:

[bluetooth]# power on

Enable the agent and set it as default:

[bluetooth]# agent on
[bluetooth]# default-agent

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

[bluetooth]# discoverable on
[bluetooth]# pairable on

Scan for devices:

[bluetooth]# scan on

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:

[bluetooth]# devices

Pair with the device:

[bluetooth]# pair device_mac_address

Enter the PIN if prompted:

[agent] PIN code: ####

Trust the device:

[bluetooth]# #trust device_mac_address

Connect to the device:

[bluetooth]# connect device_mac_address

Display information about the device:

[bluetooth]# info device_mac_address

The device is now paired:

[bluetooth]# quit

Configuration

Set adapter power state

If you would like the adapter to not be automatically enabled (e.g. on a portable device where you wish to save battery), set AutoEnable=false in /etc/bluetooth/main.conf in the [Policy] section:


Contents of /etc/bluetooth/main.conf

[Policy] ... AutoEnable=false ...

Battery Reporting

An experimental feature can be enabled in order to report device battery level:


Contents of /etc/bluetooth/main.conf

[General] ... Experimental=true ...

Troubleshooting

Todo: add example for "no default controller" error and how to find missing drivers


See Also