Connect to a Bluetooth device via Terminal
I managed to do so via bluez-tools:
sudo apt-get install bluez-tools
List of devices to get the MAC address of my device:
bt-device -l
and successfully connect to it:
bt-audio -c 01:02:03:04:05:06
Keep in mind that the bt-audio
feature has been reimplemented probably some time in 2016, so bt-audio
is likely no longer available as such.
To do it with the built-in utils, you can follow this slightly more manual process using bluetoothctl
.
hcitool scan # to get the MAC address of your device
bluetoothctl
agent on
scan on # wait for your device's address to show up here
scan off
trust MAC_ADDRESS
pair MAC_ADDRRESS
connect MAC_ADDRESS
The posts in this Github issue suggest a way to script it, but that did not work for me since I needed to manually wait for the scan to yield results.
I did to sudo apt-get install bluez-tools
, because I did use it at some point.
After being able to find the device from hcitool scan
,
I ran bluez-simple-agent hci0 X
where X is the mac address of the device I was adding. This created the connection to the device.
Then I ran hciconfig scan
and it seems to have automatically started the connection.