How to Set Up Bluetooth in Linux

How to Set Up Bluetooth in Linux

Adding Bluetooth consists of four steps:
  1. enabling general Bluetooth support
  2. pairing the Bluetooth device with the computer
  3. configuring the computer to use the Bluetooth device
  4. automating the re-connection to the Bluetooth device when you login.

Getting Started

Install the required packages on your computer

If you’re on Ubuntu or an Ubuntu-based distro, run the following command:

sudo apt install bluetooth bluez bluez-tools rfkill
  • the bluez package provides the Bluetooth protocol stack.
  • the bluez-utils package provides the bluetoothctl utility.
  • The generic Bluetooth driver is the btusb kernel module.
Next, make sure your Bluetooth device is not blocked. You can verify that using the rfkill utility:

sudo rfkill list


0: phy0: Wireless LAN
 Soft blocked: no
 Hard blocked: no
2: dell-bluetooth: Bluetooth
 Soft blocked: yes
 Hard blocked: no

My laptop showed there is a "Soft blocked".
I turned on "Settings->Bluetooth", then get the following:


0: phy0: Wireless LAN
 Soft blocked: no
 Hard blocked: no
2: dell-bluetooth: Bluetooth
 Soft blocked: no
 Hard blocked: no
3: hci0: Bluetooth
 Soft blocked: no
 Hard blocked: no

You can also unblock it using:

sudo rfkill unblock bluetooth
Finally, make sure the Bluetooth service is active by running the following command,

systemctl status bluetooth
If it is not, then systemctl start Bluetooth will start it,

sudo service bluetooth start

Front-ends

Console

  • bluetoothctl — Pairing a device from the shell is one of the simplest and most reliable options.

Graphical

  • GNOME Bluetooth — GNOME's Bluetooth tool.
  • Bluedevil — KDE's Bluetooth tool.
  • Blueberry — Linux Mint's spin-off of GNOME Bluetooth, which works in all desktop environments.
  • Blueman — A full featured Bluetooth manager.
  • Install the blueman package which helps you pair and manage Bluetooth devices.
    On Ubuntu use the following:
    
    sudo apt-get install blueman
    	

Scanning then Pairing and Connecting to Devices

Launch the Bluetooth Manager from your applications launcher: By default, your Bluetooth device is hidden. You need to make it visible so that it can be discovered by other devices.
Go to “Adaptor -> Preferences” and make sure the setting to “Always visible” or “Temporarily visible,”.
Next, start scanning for Bluetooth devices by clicking “Search” and wait for a few moments for the scan to complete.

All visible and discoverable Bluetooth devices will be listed in the Bluetooth manager.

To pair the speaker with the computer -- in other words, to link them together.

  1. Right-click the relevant entry on the list and click “Pair.” This will initialise a pairing request which the other device will have to accept.
  2. Next, enter a PIN code in the dialog box and click OK.
  3. Finally, go to your device and enter the same PIN to confirm the pairing
If everything goes well, the devices will be paired.

Configuring the computer to use the Bluetooth device

Automating the re-connection to the Bluetooth device when you login

Re-connection is a matter of a few clicks, but you can automate with a two line Bash script to send instructions to bluetoothctl:

#!/bin/bash
#echo -e 'connect SPEAKER-ID' | bluetoothctl
Set the script to autostart as you login to your desktop.

Logitech x300 Mobile Wireless Stereo Speaker

Technical Specifications
  • Bluetooth: A2DP, 30 ft wireless range
  • Phone calls: Bluetooth-Hands-Free Profile (HFP1.6)
  • Battery: 5-hour
  • Dimensions: 5.9″ L x 2.8″ W x 2.7″ H
  • Weight: 12.5 oz.
Usage note:
  • the battery needed 4 hours to fully charge after being completely depleted
  • As the speaker is charging (and powered off) the status light very slowly flashes red until it is completely charged at which time the light shuts off.
The first time you power on the speaker, the light of the power LED:
  • it flashes red when charging
  • it flashes blue when not charging and is ready to be paired
For pairings, you must hold the Bluetooth button down for 3 seconds after which you hear a rapid succession of tones and the status light then flashes slowly indicating it is ready to be paired.

Serial Port Connection with Bluetooth

留言

熱門文章