WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: bluetooth startup script  (Read 551 times)

Online meo

  • Hero Member
  • *****
  • Posts: 772
Re: bluetooth startup script
« Reply #15 on: August 16, 2026, 12:54:46 PM »
Hi Juanito!

It might sound strange but I found something interesting on the internet. I am trying to use the onboard RPi bluetooth. So I just use the terminal. The commands go more or less like this:

$ blutetoothctl (which starts a box, i don't know what it's called)

>power on

>agent on

>default-agent

>scan on   (this starts an output and my earbud says "paring")

>trust (mac address of the listening device)

>pair (mac address ....up to here all seems good)

>connect (mac address....now comes the error message)
Failed to connect: org.bluez.Error.Failed br-connection-unknown

Kind greetings,
meo
"All that is very well," answered Candide, "but let us cultivate our garden." - Francois-Marie Arouet Voltaire

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1615
Re: bluetooth startup script
« Reply #16 on: August 16, 2026, 05:58:22 PM »
what are you using for your audio backend.

bluez just negotiates the connection, if there is no backend configuring audio, then it wont connect.

Online meo

  • Hero Member
  • *****
  • Posts: 772
Re: bluetooth startup script
« Reply #17 on: August 17, 2026, 04:04:38 AM »
Hi Paul_123!

Thanks for your comment. The sound is tied automatically to hdmi0. I never saw in the inctructions on the internet anything about any command about the sound. Maybe there should be. I'm just trying something that I saw on the internet about RPi and bluetooth.

Kind Regards,
meo
"All that is very well," answered Candide, "but let us cultivate our garden." - Francois-Marie Arouet Voltaire

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1615
Re: bluetooth startup script
« Reply #18 on: August 17, 2026, 06:42:21 AM »
The hdmi is a soundcard, not an audio backend.   You need something like pulse audio or bluealsa to do that.

Online meo

  • Hero Member
  • *****
  • Posts: 772
Re: bluetooth startup script
« Reply #19 on: August 17, 2026, 07:17:46 AM »
Hi Paul_123!

I use bluez-alsa.tcz if that is what you are wondering about.

Kind regards,
meo
"All that is very well," answered Candide, "but let us cultivate our garden." - Francois-Marie Arouet Voltaire

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 15764
Re: bluetooth startup script
« Reply #20 on: August 17, 2026, 08:59:38 AM »
So I tried using bluetoothctl:
Code: [Select]
tce-load -i bluez
./bt_start.sh [run bluetooth initialisation script]

Then pair and connect audio to bluetooth headphones:
Code: [Select]
sudo bluetoothctl
> power on
> agent on
> default-agent
[put headphones into pairing mode]
> scan on
> pair 00:1B:66:00:31:88
> trust 00:1B:66:00:31:88
> connect 00:1B:66:00:31:88
[this failed the first two times, on the third attempt it suceeded and the prompt changed]
[Sennheiser PXC310BT]>

I was then able to set the audio output to the headphones using pavucontrol and play music with xmms-pulse.

Using the above method the sound stutters and is poor quality - if I use blueman the sound is much better.

Offline Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1615
Re: bluetooth startup script
« Reply #21 on: August 17, 2026, 12:07:06 PM »
If you are using bluez-alsa,  then have you started bluealsad  (With what options.)   Then you will need to use the bluealsa - alsa plugin  as a audio card destination (Which has its own set of configuration requirements).

Doing what Juanito showed you would be better .....

Online meo

  • Hero Member
  • *****
  • Posts: 772
Re: bluetooth startup script
« Reply #22 on: August 17, 2026, 01:49:25 PM »
Hello Juanito!

Yes I am using bluetoothctl also but I have a problem that when the inear buds i use are identified and the name comes up in the prompt the buds shut down. It has been doing that all the time since I started using Bluetoothctl. One of them never has worked so I have communicated that to the owners of this mark of buds actually in Sweden. So in a couple of days I'll get a new pair. The only thing I can add now is that if something goes wrong doing like this stops the connection and you can start over:

> remove  mac address
> scan off

Restart whatever you were using (earphones reset to pairing for ex.)
Then it's possible just to start from scan on etc.

Kind greetings,
meo
« Last Edit: August 17, 2026, 01:54:43 PM by meo »
"All that is very well," answered Candide, "but let us cultivate our garden." - Francois-Marie Arouet Voltaire