APC Australia

Get Bluetooth working in Ubuntu

Nick Peers reveals how to get your Bluetooth-capable equipment recognised and working in Linux. Let’s hear it for cable-free connectivi­ty!

-

When it comes to wireless communicat­ion to and from your PC, it’s easy to overlook Bluetooth. Yet its low-power requiremen­ts make it ideal for all wireless scenarios, not least hooking up wireless input devices to your PC. Why clutter up your USB ports with wireless adapters for keyboards and mice when you can pair them with Bluetooth, for example?

That’s not to say Bluetooth is perfect — far from it, particular­ly where Linux is concerned. Bluetooth implementa­tion is improving and becoming easier to manage, but it can still fall over at the slightest provocatio­n, particular­ly when attempting more complex tasks like streaming audio or sending files to and from mobile devices. We’ll not only show you how to get Bluetooth working, but reveal some tricks to help troublesho­ot annoying problems when they arise.

Many modern-day PCs and laptops come with Bluetooth built-in, but you can add Bluetooth functonali­ty for as little as $10 with a USB adapter. Look for an adapter that supports Bluetooth 4.0 or 4.1. Even if it doesn’t explicitly support Linux most should still work, but try to source one that has been successful­ly used by others — Google the name and your distro or ‘Linux’ to see what comes up.

UNDER STARTER’S ORDERS

These days, most Bluetooth adapters are plug and play. It’s likely the basic packages required to use Bluetooth are already installed, but to be on the safe side run the following commands from a Terminal window:

$ sudo apt-get update

$ sudo apt-get install bluetooth bluez bluez-tools rfkill

Now you need to verify that your Bluetooth adapter has been detected: $ sudo rfkill list It should list your Bluetooth adapter and both SOFT and HARD should be set to Unblocked. If this isn’t the case, issue the following command:

$ sudo rfkill unblock bluetooth

This should ensure that the Bluetooth adapter functions correctly. If the adapter doesn’t appear, try $ lsusb Does your adapter appear in this list? If so, type hciconfig and hit Enter. It should list the device as hci0 , in which case, to find out the manufactur­er type: $ hciconfig -a hci0 Try wiki.ubuntu.com/HardwareSu­pport Components­BluetoothU­sbAdapters to see if your device is listed, complete with instructio­ns to help you get it working.

Still no luck? Try the following command: $ dmesg | grep bluetooth Look to see if there’s a Direct firmware load failure, which indicates the firmware is missing. You’ll need to track this down and copy it to the indicated folder under /lib/firmware/ — those with internal Wi-Fi/Bluetooth adapters sporting Broadcom chipsets should start their search at github.com/winterhear­t/ broadcom-bt-firmware for example.

Failing that, make a note of its name and Google that with ‘Ubuntu’ to find out more about it and if it there’s a known problem. One issue we’ve come across is that newer chips may not be recognised in the kernel you’re currently running. So if updating Ubuntu doesn’t work, and you’re a dab hand with Linux, consider updating to the latest version of the kernel. If that sounds tricky, try the Ubuntu Kernel Update Utility, a GUI tool:

$ sudo apt-add-repository -y ppa:teejee2008/ppa

$ sudo apt-get updateshar­e files bluetooth linux

$ sudo apt-get install ukuu

Launch it and you’ll see a list of all available versions. Choose a higher version and install it — if Linux fails to boot properly, you should be able to fall back to your original kernel via the grub menu (look under the Advanced Options menu) at boot, then try a lower version. If your adapter still stubbornly refuses to work, try a different one — as we said earlier, they don’t break the bank.

Once your Bluetooth adapter has been detected, check the status of the Bluetooth service: $ sudo service bluetooth status If it’s not running: $ sudo service bluetooth start

SET UP BLUETOOTH DEVICES

You can close the Terminal window now. If all is well, you can now do everything you want to through the Gnome desktop. The step-by-step guide (final page) reveals the straightfo­rward way to pair, connect and configure devices using the built-in Settings tool.

This should work in most circumstan­ces, but while certain devices are likely to work flawlessly — mice and keyboards, for example — others may cause a few headaches, specifical­ly sound devices. The key is to be patient — don’t rush to click a button. Other times you may need to reboot your PC and try pairing or reconnecti­ng again.

It’s also worth checking out the box on Blueman for an alternativ­e tool that gives you more control over the pairing, connection and management process, plus provides more verbose communicat­ion should errors occur. Furthermor­e, don’t forget to resort to Googling your device and ‘Linux’ or ‘Ubuntu’ to see if anyone else has gone down the same route.

AUDIO TO WIRELESS DEVICES

Using Bluetooth to stream audio is a popular use of the wireless technology, particular­ly given the proliferat­ion of cheap Bluetooth headphones, headsets and speakers. Again, Google any potential buy to see how others have got on with it. Once paired and connected, visit Settings > Sound where you should see the device in question is now available under Output (if it’s a headset, it should also appear under Input).

You’ll see your device has been allocated a profile — typically ‘Hi-Fidelity Playback (A2DP Sink) ‘for a speaker, or ‘Headset Head Unit (HSP/HFP)’ for a headset — and you may find it supports multiple profiles via its drop-down menu. For now, though, stick with the default and click Test Speaker to check it’s working (you may need to click this a few times or even switch outputs before the connection clicks in and you hear a response).

With the device now set for both Output and — if applicable — Input, you can now attempt to use your device in conjunctio­n with an app like Rhythmbox. If no sound comes out of it, try temporaril­y switching back to your PC’s speakers in Settings > Sound before clicking your Bluetooth device again — you should find that things now work correctly.

MUSIC TO YOUR PC

Another good use for Bluetooth is to use it to stream audio from your phone or other audio device to your PC’s more powerful speakers rather than the other way around. First, check your device is configured to output to your PC — in Android, for example, navigating to ‘Bluetooth Settings’ and tapping the Settings cog next to your PC’s entry should provide options for outputting phone and/or media audio to your PC choose the latter for your music.

Now navigate to ‘Settings > Sound’, select the Input tab and check to see if your device appears as an option, indicating it’s supported. Click the Profile dropdown menu to see what’s supported. ‘High Fidelity Capture (A2DP Source)’ is the typical option.

Should you experience poor quality — stuttering sound, for example — then there are several remedies to try. First, move your device closer to your PC’s Bluetooth adapter (particular­ly true with older models). Second, disable Wi-Fi on your device (or switch to a 5GHz network if possible — Bluetooth functions on 2.4GHz). Last, but not necessaril­y least, install and launch the PulseAudio Volume Control program

$ sudo apt-get install pavucontro­l

Switch to the ‘Input Devices’ tab, expand Advanced underneath your device’s entry and then increase the Latency offset figure to 2,000 ms.

SENDING FILES

Bluetooth is also useful for shunting files to and from your phone or tablet. For Android, open Bluetooth settings on your mobile to put it in discovery mode, and it should eventually appear in the list of available Bluetooth devices on your PC (your PC will also appear under Available devices on your mobile). Click to connect — a PIN code should appear on both Android and PC screens (you may need to access the PIN on your Android device via a notificati­on). If they match, click Confirm on your PC (and tap Pair on the Android device).

Technicall­y, you should now be able to share files from your phone to your PC. Open an app, select the file and tap the Share button. Select Bluetooth from the pop-up menu, verify your PC is listed as connected and then tap it. Switch back to your PC where you should see a notificati­on pop up telling you the file is incoming — roll your mouse over this and click Accept to receive it.

The transfer will take longer than a normal file transfer due to the low speed (24Mbps maxium for v3 devices onwards) of the Bluetooth connection (this is particular­ly true for v2 and older Bluetooth adapters), and the file will appear in your Downloads folder when complete. Keep an eye on the file’s progress via your mobile’s notificati­ons, or wait for the notificati­on of a successful transfer pops up.

The process can be hit and miss — you may end up with a string of errors. Try disconnect­ing and reconnecti­ng the mobile to see if that solves things.

It’s also technicall­y possible to send files from your PC to your mobile. Click the device under ‘Settings > Bluetooth’ and choose ‘Send Files…’ Browse to and pick your file, then click Select. Note, only certain file types — such as images — are allowed. Again, you’ll need to accept the connection, albeit this time through your mobile’s notificati­ons. A progress bar keeps you informed — complete with transfer speed. Once done, files are stored in a special Bluetooth folder on your tablet or phone.

SHARE A NETWORK

It’s theoretica­lly possible to share your mobile’s internet connection with your PC — both Android and iOS support this feature (the process for pairing iOS to Ubuntu is the same as Android, although you’ll need to initiate the connection from your iPhone). If you click the Bluetooth icon in the top-right corner you’ll see your mobile is listed as an available option — clicking this reveals a Connect to Internet option.

Before flicking this switch, however, you need to configure your phone to enable tethering through its Bluetooth connection. In Android, go to ‘Settings > More…’ under ‘Wireless & Networks’, choose ‘Tethering & Portable Hotspot’ and make sure ‘Bluetooth Tethering’ is switched on. iPhone users should go to ‘Settings > Mobile Data > Personal Hotspot’ and switch it on.

Once complete, return to the Bluetooth icon and click ‘Connect to Internet’. If successful, you’ll be able to browse using your phone’s internet connection. Disconnect from the same dialogue. Blueman users can also initiate a connection directly from the app itself — just right-click your phone’s entry and choose ‘Network Access Point’ to connect and gain internet access.

NO VIKING REFERENCES

Things may run smoothly for a while, but eventually something will fall over — for example, while we could successful­ly pair, connect and listen to music through a Bluetooth Aether Cone speaker following the procedure outlined earlier, the connection would be lost after a period of inactivity. The only way to bring the speaker back online was to remove it,

then go through the whole re-pairing and reconnecti­ng process again. Long story short, more hassle than it was worth — on the other hand, the speaker also supports AirPlay, which worked far better through Ubuntu.

Start with $ sudo apt-get install pulseaudio-module-raop paprefs then launch paprefs and tick the AirTunes box which is under ‘Network Access’.

Often you don’t need quite such drastic measures. Sometimes a simple reboot will fix the problem, or you might need to simply disconnect the two before reconnecti­ng. Failing that, disabling Bluetooth on both devices (if possible), rebooting your PC and then attempting to reconnect from scratch may be the fix you’re looking for.

And if that doesn’t work, consider removing the device and starting again from scratch, pairing it as a new device.

But what happens if Bluetooth itself stops working? One user reported Bluetooth no longer working after manually putting Ubuntu 18.04 into suspend (we’ve had no problems doing this, so it’s not universal by any means). Rebooting, disabling and re-enabling Bluetooth had no effect, neither did restarting the Bluetooth service, reinstalli­ng the key packages or running rfkill. In the end he was able to get things working by booting from a live CD, disabling Bluetooth from there, then rebooting – things worked normally again.

Another user has created a workaround for this problem by creating a blank script: $ sudo nano /lib/systemd/ system-sleep/bluetooth Type the following lines: #!/bin/bash if [ “${1}” == “post” ]; then sleep 5 service bluetooth restart fi Save and exit, then make the script executable: $ chmod /lib/systemd/systemslee­p/bluetooth

Remember, you’ll only need this script if Bluetooth falls over after suspending your PC.

Struggling to find a specific solution for your problem? The Ask Ubuntu ( askubuntu.com) forums are filled with queries from fellow Bluetooth users — start with ‘Bluetooth Ubuntu 18.04’ and narrow your search parameters from there. Or widen the search terms to Google to bring in other sources, too.

 ??  ?? Problems getting your adapter working? Make use of Linux’s hardware tools to check that your device has been recognised.
Problems getting your adapter working? Make use of Linux’s hardware tools to check that your device has been recognised.
 ??  ?? Once connected, you’ll find handy shortcuts to the relevant part of Settings to configure your Bluetooth device.
Once connected, you’ll find handy shortcuts to the relevant part of Settings to configure your Bluetooth device.
 ??  ?? Audio setup can be a little tricky, but once your speaker or headset is recognised, configure it via Settings>Sound.
Audio setup can be a little tricky, but once your speaker or headset is recognised, configure it via Settings>Sound.

Newspapers in English

Newspapers from Australia