The problem is that there is no Audio Sink defined. Check with
rpi ~$ bluetoothctl show
Controller DC:A6:32:7F:38:48 (public)
Name: raspberrypi
Alias: raspberrypi
Class: 0x00480000
Powered: yes
Discoverable: no
Pairable: yes
UUID: Headset AG (00001112-0000-1000-8000-00805f9b34fb)
UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
UUID: A/V Remote Control (0000110e-0000-1000-8000-00805f9b34fb)
UUID: Generic Access Profile (00001800-0000-1000-8000-00805f9b34fb)
UUID: PnP Information (00001200-0000-1000-8000-00805f9b34fb)
UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
UUID: Audio Source (0000110a-0000-1000-8000-00805f9b34fb)
UUID: Handsfree Audio Gateway (0000111f-0000-1000-8000-00805f9b34fb)
Modalias: usb:v1D6Bp0246d0532
Discovering: no
rpi ~$
As you can see, you will find an Audio Source but no Audio Sink, that is needed to provide a service to output audio. Out of the box RaspiOS uses alsa for audio services and with bluetooth bluealsa
is needed:
rpi $ bluealsa --help
Usage:
bluealsa [OPTION]...
Options:
-h, --help print this help and exit
-V, --version print version and exit
-B, --dbus=NAME D-Bus service name suffix
-S, --syslog send output to syslog
-i, --device=hciX HCI device to use
-p, --profile=NAME enable BT profile
--a2dp-force-mono force monophonic sound
--a2dp-force-audio-cd force 44.1 kHz sampling
--a2dp-keep-alive=SEC keep A2DP transport alive
--a2dp-volume control volume natively
Available BT profiles:
- a2dp-source Advanced Audio Source (SBC)
- a2dp-sink Advanced Audio Sink (SBC)
- hfp-hf Hands-Free (v1.7)
- hfp-ag Hands-Free Audio Gateway (v1.7)
- hsp-hs Headset (v1.2)
- hsp-ag Headset Audio Gateway (v1.2)
By default only output profiles are enabled, which includes A2DP Source and
HSP/HFP Audio Gateways. If one wants to enable other set of profiles, it is
required to explicitly specify all of them using `-p NAME` options.
Please note the comment at the end. To have an audio sink enabled we have to use at least option p a2db-sink
but also others. It doesn't hurt to enable all available profiles:
bluealsa -p a2dp-source -p a2dp-sink -p hfp-hf -p hfp-ag -p hsp-hs -p hsp-ag
bluealsa
is started with a service:
rpi ~$ systemctl status bluealsa.service
● bluealsa.service - BluezALSA proxy
Loaded: loaded (/lib/systemd/system/bluealsa.service; static; vendor preset: enabled)
Active: active (running) since Sun 2020-09-27 11:50:29 BST; 2h 44min ago
Main PID: 739 (bluealsa)
Tasks: 3 (limit: 4915)
CGroup: /system.slice/bluealsa.service
└─739 /usr/bin/bluealsa
Sep 27 11:50:29 raspberrypi systemd[1]: Started BluezALSA proxy.
Here you can see in the CGroup that 739 /usr/bin/bluealsa
is started without the additional option, so we have to modify it. I prefer to use a drop-in file with:
rpi ~$ sudo systemctl edit bluealsa.service
In the empty editor insert these statements, save them and quit the editor.
[Service]
# Empty ExecStart to disable the old one
ExecStart=
ExecStart=/usr/bin/bluealsa -p a2dp-source -p a2dp-sink -p hfp-hf -p hfp-ag -p hsp-hs -p hsp-ag
Check the runtime property:
rpi ~$ systemctl show --property=ExecStart bluealsa
ExecStart={ path=/usr/bin/bluealsa ; argv[]=/usr/bin/bluealsa -p a2dp-source -p a2dp-sink -p hfp-hf -p hfp-ag -p hsp-hs -p hsp-ag ; ignore_errors=no ; start_time=[Sun 2020-09-27 15:23:05 BST] ; stop_time=[n/a] ; pid=728 ; code=(null) ; status=0/0 }
You can also list the complete service with systemctl cat bluealsa.service
.
Now reboot. You must unpair the smartphone in its bluetooth settings and on the RasPi:
rpi ~$ bluetoothctl
Agent registered
[bluetooth]# paired-devices
Device 14:A3:64:06:9F:DB Ingo (Galaxy S5)
[bluetooth]# remove 14:A3:64:06:9F:DB
[DEL] Device 14:A3:64:06:9F:DB Ingo (Galaxy S5)
Device has been removed
Now pair it again. Then you should be able to connect the smartphone. To simplify things I recommend to trust the device before pairing!
[bluetooth]# scan on
--- snip ---
[bluetooth]# scan off
--- snip ---
[bluetooth]# devices
Device 14:A3:64:06:9F:DB Ingo (Galaxy S5)
[bluetooth]# trust 14:A3:64:06:9F:DB
[CHG] Device 14:A3:64:06:9F:DB Trusted: yes
Changing 14:A3:64:06:9F:DB trust succeeded
[bluetooth]# pair 14:A3:64:06:9F:DB
--- snip ---
Pairing successful
[CHG] Device 14:A3:64:06:9F:DB ServicesResolved: no
[CHG] Device 14:A3:64:06:9F:DB Connected: no
[bluetooth]# connect 14:A3:64:06:9F:DB
Attempting to connect to 14:A3:64:06:9F:DB
[CHG] Device 14:A3:64:06:9F:DB Connected: yes
Connection successful
[CHG] Device 14:A3:64:06:9F:DB ServicesResolved: yes
[Ingo (Galaxy S5)]
References:
(1) Ubuntu - pairing
{2] Pairing Agents in BlueZ stack