I'm new to Linux and new to Bluetooth scripting too. What I have discovered so far is the following:
- Bluez is the default BT stack.
- BluezTools is a set of utilities you can use to more easily interact with Bluez
- DBus is the interface Bluez connects to while interacting directly with the hardware.
- PulseAudio is the subsystem responsible for producing audio on the system.
This makes sense. So let's say I have a set of BlueTooth headphones, what I would expect is (all after pairing and trusting), to be able to issue a command that can connect directly to a certain profile on the BT headphones.
The technical path I have in mind would be something like :
- Turn headphones on.
- Issue a BluezTools command - such as bt-audio -c
- Wait for the device to connect to the service I am after
- PulseAudio should now pick up a new output device
- Issue another command to change the audio from what it was to new output audio (the BT headphones).
- Enjoy a seamless listening experience.
This all seems logical, but the actual implementation is not like this, and I am looking for the WHY, so I can better understand the problem and try and fix it.
This is what actually happens:
- Turn headphones on.
- Issue a BluezTools command - such as bt-audio -c
- Wait for the device to connect to the service I am after
- PulseAudio should now pick up a new output device
- Issue a PulseAudio command to change the audio profile from telephone quality to high fidelity.
Let me expand on this a bit. The bluetooth headset offers 2 quality modes (telephone and high fidelity). Only 1 is really suitable for listening to music.
I would expect that the BT headphones expose each quality mode as a service, is this right? This assumption could be wrong, but I would expect something like
bt-audio -c highFidelityProfile
or
bt-audio -changeProfile highFidelityProfile
Instead it seems that Bluez just handles the RAW connection to the device, and from there you need to issue a : pacmd set-card-profile $INDEX a2dp
This just seems fundamentally wrong. Why is the quality control in the audio subsystem, hence requiring a different implementation for pulse or alsa, or any other sound sub system out there?
What am I missing? Why is it not possible to connect directly to a certain profile using Bluez / BluezTools etc?