You are not logged in.
I am using GNOME with arch linux. I have bluetooth speakers to be connected. They have been already connected manually and trusted. Now i want to automate the connection. The following command works fine to connect with the device after going to the bluetoothctl shell,
[bluetooth]# connect C2:9C:E8:1C:85:50
Attempting to connect to C2:9C:E8:1C:85:50
[CHG] Device C2:9C:E8:1C:85:50 Connected: yes
Connection successful
But I want to do this from a script so I tried the following command,
echo -e "connect C2:9C:E8:1C:85:50" | bluetoothctl
[bluetooth]# connect C2:9C:E8:1C:85:50
Device C2:9C:E8:1C:85:50 not available
This doesnt connect and it says not available. What can be done?
Offline
Hi, I tackled this problem long time ago and finally got the solution .
Firstly, you have to pair device as described here: https://wiki.archlinux.org/index.php/Bluetooth_Headset.
Then run
bluetoothctl
[bluetooth]# power on
turn you headset on, if message connected:yes, connected:no appears, you have to set that you trust your dev. Simply doing by
trust `mac addr`
Now the devices should connect automatically after command `power on`.
Script to turn bluetooth on is straightforward:
# systemctl start bluetooth (if not already started)
# hciconfig hci0 up
The first cmd starts bluetooth daemon, the second one is equivalent to `power on`. Be careful, hci0 is your "bluetooth server". If you have more bluetooth devices on PC, the number could change over reboot. Current number can be obtained by `hciconfig`. You could make a script which parses this output and finds the correct number according to mac address. Just ask, if you need this.
Offline