Prerequisites
Before you begin, set up your device and go to the required menu as described in Set up the device for A2DP functions.
Connect a remote device
To connect a remote device in the A2DP source role, run the following command from the bluetoothctl menu:
Parameters
<bt_address> is the Bluetooth address of the remote device.
Example
To connect to a paired remote device with <bt_address> 17:1A:35:8D:A2:A4, run the following command:
connect 17:1A:35:8D:A2:A4
Sample output
[bluetooth]# connect 17:1A:35:8D:A2:A4
Attempting to connect to 17:1A:35:8D:A2:A4
[CHG] Device 17:1A:35:8D:A2:A4 Connected: yes
[CHG] Device 17:1A:35:8D:A2:A4 UUIDs: 0000110b-0000-1000-8000-00805f9b34fb
[CHG] Device 17:1A:35:8D:A2:A4 UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
[CHG] Device 17:1A:35:8D:A2:A4 UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
[CHG] Device 17:1A:35:8D:A2:A4 ServicesResolved: yes
[CHG] Device 17:1A:35:8D:A2:A4 Bonded: yes
[CHG] Device 17:1A:35:8D:A2:A4 Paired: yes
[NEW] Endpoint /org/bluez/hci0/dev_17_1A_35_8D_A2_A4/sep1
[NEW] Endpoint /org/bluez/hci0/dev_17_1A_35_8D_A2_A4/sep2
[NEW] Transport /org/bluez/hci0/dev_17_1A_35_8D_A2_A4/sep1/fd0
Connection successful
[CHG] Transport /org/bluez/hci0/dev_17_1A_35_8D_A2_A4/sep1/fd0 State: active
[CHG] Transport /org/bluez/hci0/dev_17_1A_35_8D_A2_A4/sep1/fd0 Volume: 0x0040 (64)
[CHG] Transport /org/bluez/hci0/dev_17_1A_35_8D_A2_A4/sep1/fd0 State: idle
[CHG] Transport /org/bluez/hci0/dev_17_1A_35_8D_A2_A4/sep1/fd0 Volume: 0x0044 (68)
[CHG] Transport /org/bluez/hci0/dev_17_1A_35_8D_A2_A4/sep1/fd0 Volume: 0x0040 (64)
[MySoundbar]#
List available transport
To list the available transport, run the following command from the menu transport submenu:
Sample output
[MySoundbar]# list
Transport /org/bluez/hci0/dev_17_1A_35_8D_A2_A4/sep1/fd0
To get the information about the codec capabilities of a transport, run the following command from the menu transport submenu:
Parameters
<transport> is the transport path.
Example
To get the information about the codec capabilities of <transport> /org/bluez/hci0/dev_17_1A_35_8D_A2_A4/sep1/fd0, run the following command:
show /org/bluez/hci0/dev_17_1A_35_8D_A2_A4/sep1/fd0
Sample output
[MySoundbar]# show /org/bluez/hci0/dev_17_1A_35_8D_A2_A4/sep1/fd0
Transport /org/bluez/hci0/dev_17_1A_35_8D_A2_A4/sep1/fd0
UUID: 0000110a-0000-1000-8000-00805f9b34fb
Codec: 0x00 (0)
Configuration: 0x21 (33)
Configuration: 0x15 (21)
Configuration: 0x02 (2)
Configuration: 0x35 (53)
Device: /org/bluez/hci0/dev_17_1A_35_8D_A2_A4
State: idle
Volume: 0x0040 (64)
Set absolute volume
Ensure that the DUT and the remote device support the setabsvolume feature.
To set the absolute volume of a transport, run the following command from the menu transport submenu:
volume <transport> [value]
Parameters
-
<transport> is the transport path.
-
[value] is the volume level.
Example
To set the absolute volume of <transport> /org/bluez/hci0/dev_17_1A_35_8D_A2_A4/sep1/fd0 as 50, run the following command:
volume /org/bluez/hci0/dev_17_1A_35_8D_A2_A4/sep1/fd0 50
Sample output
[MySoundbar]# volume /org/bluez/hci0/dev_17_1A_35_8D_A2_A4/sep1/fd0 50
Changing Volume succeeded
[CHG] Transport /org/bluez/hci0/dev_17_1A_35_8D_A2_A4/sep1/fd0 Volume: 0x0032 (50)
[MySoundbar]# volume /org/bluez/hci0/dev_17_1A_35_8D_A2_A4/sep1/fd0 10
Changing Volume succeeded
Play an audio file
The DUT doesn’t support an audio player. Use paplay commands to play music.Only PCM audio sample is supported.
To play songs from the DUT, do the following:
-
Run SSH.
-
Play a WAV file by running the following command:
paplay <audio_filepath> -v
Parameters
<audio_filepath> is the filepath of the WAV file.
Example
To play a WAV file at /tmp/playback.wav, run the following command:
paplay /tmp/playback.wav -v
Sample output
sh-5.1# paplay /tmp/playback.wav -v
Opening a playback stream with sample specification 's16le 2ch 44100Hz' and channel map 'front-left,front-right'.
Connection established.
Stream successfully created.
Buffer metrics: maxlength=4194304, tlength=352800, prebuf=349276, minreq=3528
Using sample spec 's16le 2ch 44100Hz', channel map 'front-left,front-right'.
Connected to device bluez_output.17:1A:35:8D:A2:A4 (index: 68, suspended: no).
Stream started.
Get a list of sinks
To get the list of sinks when multiple devices are connected, run the following command in SSH:
The pactl tool isn’t available by default. Enable and build the tool on your device.
Sample output
sh-5.1# pactl list sinks short
51 alsa_output.platform-sound.HiFi__Speaker__sink PipeWire s16le 2ch 48000Hz SUSPENDED
68 bluez_output.17:1A:35:8D:A2:A4 PipeWire float32le 2ch 48000Hz SUSPENDED
Play audio on a specific sink
To play audio on a specific sink when multiple devices are connected, run the following command in SSH:
paplay <audio_filepath> --device=<device_name> -v
Parameters
-
<audio_filepath> is the filepath of the WAV file.
-
<device_name> is the sink name.
Example
To play pcmtest.wav on the bluez_output.17:1A:35:8D:A2:A4 sink, run the following command:
paplay pcmtest.wav --device=bluez_output.17:1A:35:8D:A2:A4 -v
Sample output
sh-5.1# paplay pcmtest.wav --device=bluez_output.17:1A:35:8D:A2:A4 -v
Opening a playback stream with sample specification 's16le 2ch 44100Hz' and channel map 'front-left,front-right'.
Connection established.
Stream successfully created.
Buffer metrics: maxlength=4194304, tlength=352800, prebuf=349276, minreq=3528
Using sample spec 's16le 2ch 44100Hz', channel map 'front-left,front-right'.
Connected to device bluez_output.17:1A:35:8D:A2:A4 (index: 68, suspended: no).
Stream started.
Time: 2.925 sec; Latency: 2062081 usec.
Disconnect a remote device
To disconnect a remote device, run the following command from the bluetoothctl menu:
Parameters
<bt_address> is the Bluetooth address of the remote device.
Example
To disconnect a paired remote device with <bt_address> 17:1A:35:8D:A2:A4, run the following command:
disconnect 17:1A:35:8D:A2:A4
Sample output
[MySoundbar]# disconnect 17:1A:35:8D:A2:A4
Attempting to disconnect from 17:1A:35:8D:A2:A4
[DEL] Transport /org/bluez/hci0/dev_17_1A_35_8D_A2_A4/sep1/fd2
[DEL] Endpoint /org/bluez/hci0/dev_17_1A_35_8D_A2_A4/sep1
[DEL] Endpoint /org/bluez/hci0/dev_17_1A_35_8D_A2_A4/sep2
[CHG] Device 17:1A:35:8D:A2:A4 ServicesResolved: no
Successful disconnected
[CHG] Device 17:1A:35:8D:A2:A4 Connected: no