Bluetoothctl

From DikapediaV2
Jump to: navigation, search

Bluetoothctl is a command-line tool used to interact with the Bluetooth subsystem on Linux systems. It provides a text-based interface for managing Bluetooth devices, including discovering, pairing, connecting, and configuring Bluetooth devices.

Key Features of Bluetoothctl:

  • Device Discovery: Scan for nearby Bluetooth devices.
  • Pairing: Pair with Bluetooth devices.
  • Connecting: Establish a connection with paired devices.
  • Trusting: Mark devices as trusted to allow automatic connections in the future.
  • Agent Management: Manage Bluetooth agents, which handle pairing requests and PIN/passkey entry.
  • Power Control: Turn Bluetooth on or off.
  • Device Information: Retrieve information about connected and discovered devices.


Reference: https://usercomp.com/news/1466027/bluetooth-headset-pairing-issue-in-linux


Check bluetooth service


$ sudo systemctl status bluetooth

Enable Bluetooth Adapter


Use rfkill command.

$ rfkill list all
$ sudo rfkill unblock bluetooth

Scan Bluetooth Devices


$ sudo bluetoothctl scan on
Discovery started
.
.
.

See Bluetooth Devices


$ bluetoothctl devices

$ bluetoothctl devices | grep -i mx
Device D6:A3:C1:F9:2C:21 MX Master 3S
Device C7:A2:BB:7F:F3:49 MX Anywhere 2S

Pair and Connect a Bluetooth Device


$ dzdo bluetoothctl pair <device MAC>

$ dzdo bluetoothctl pair D6:A3:C1:F9:2C:21
Attempting to pair with D6:A3:C1:F9:2C:21
[CHG] Device D6:A3:C1:F9:2C:21 Paired: yes
Pairing successful

Once the pairing is complete, you need to connect the Bluetooth device:

$ sudo bluetoothctl connect D6:A3:C1:F9:2C:21
 Attempting to connect to D6:A3:C1:F9:2C:21
 Connection successful

Trusting a Bluetooth Device


If the pairing failed due to error "AuthenticationRejected", you may have to trust it first:

$ dzdo bluetoothctl pair D6:A3:C1:F9:2C:21
Attempting to pair with D6:A3:C1:F9:2C:21
Failed to pair: org.bluez.Error.AuthenticationRejected

$ dzdo bluetoothctl trust D6:A3:C1:F9:2C:21
[CHG] Device D6:A3:C1:F9:2C:21 Trusted: yes
Changing D6:A3:C1:F9:2C:21 trust succeeded

$ dzdo bluetoothctl pair D6:A3:C1:F9:2C:21
Attempting to pair with D6:A3:C1:F9:2C:21
[CHG] Device D6:A3:C1:F9:2C:21 Paired: yes
Pairing successful