Lab setup
- A Linux development host or Raspberry Pi with a working Bluetooth controller.
- A headset supporting A2DP and HFP.
- BlueZ, PipeWire, WirePlumber, and
pipewire-pulse. bluetoothctl,wpctl,pactl,paplay, andparecord.- A local WAV file about 15 seconds long, named
test.wavin the examples.
The Linux host sends playback audio to the headset. With HFP, Linux is the Audio Gateway (AG) and the headset is the Hands-Free (HF) device.
1. Pair the headset and identify its audio card
Put the headset in pairing mode and start bluetoothctl.
power on
agent on
default-agent
scan on
Replace the example address with the headset’s actual address.
pair AA:BB:CC:DD:EE:FF
info AA:BB:CC:DD:EE:FF
If info shows that the headset is disconnected, connect it.
connect AA:BB:CC:DD:EE:FF
After Connected: yes appears, run scan off and quit. As your regular audio user, inspect the device and its profiles.
wpctl status
pactl list short cards
pactl list cards
Record the headset’s card name and the exact A2DP and HFP profile names listed under Profiles. Names can vary by stack and codec.
2. Verify A2DP music playback
Fill in the card and profile names.
card='YOUR_BLUETOOTH_CARD'
a2dp_profile='YOUR_A2DP_PROFILE'
pactl set-card-profile "$card" "$a2dp_profile"
pactl list short sinks
Copy the actual Bluetooth sink name and play the test clip.
bt_sink='YOUR_A2DP_SINK'
paplay --device="$bt_sink" ./test.wav
Confirm that the clip plays through the headset and record the profile and sink names.
3. Verify HFP playback and microphone capture at the same time
Select an available HFP profile and list the endpoints again. They may differ from the A2DP endpoints.
hfp_profile='YOUR_HFP_PROFILE'
pactl set-card-profile "$card" "$hfp_profile"
pactl list short sinks
pactl list short sources
Identify the headset’s HFP sink and microphone source. A source ending in .monitor captures the playback output, so select the actual headset microphone.
Start recording in Terminal A.
hfp_source='YOUR_HFP_MIC_SOURCE'
parecord --device="$hfp_source" --file-format=wav ./hfp-mic.wav
While recording continues, play the clip in Terminal B.
hfp_sink='YOUR_HFP_SINK'
paplay --device="$hfp_sink" ./test.wav
Speak into the headset microphone as the clip plays. Stop recording with Ctrl+C in Terminal A. Play the recording back in Terminal B, where hfp_sink is set.
paplay --device="$hfp_sink" ./hfp-mic.wav
Verify that you heard the clip during capture and can hear your speech in the recording. This checks the local duplex audio path. After integrating a call application, run an end-to-end test with a remote caller.
4. Switch back to A2DP
pactl set-card-profile "$card" "$a2dp_profile"
pactl list short sinks
Look up the A2DP sink again and replay test.wav.
| Stage | Expected result |
|---|---|
| A2DP | Music plays through the headset |
| HFP | Playback and microphone capture work simultaneously |
| Return to A2DP | Music playback resumes |
5. Integrate with Yocto
Include the Bluetooth controller driver and firmware, BlueZ, PipeWire, WirePlumber, and Bluetooth audio support. Keep the terminal tools for target-side profile and routing checks before integrating a player or call application.
If the headset is connected but missing from wpctl status, check that PipeWire and WirePlumber are running in the user session that runs the application. For a headless deployment, confirm that WirePlumber’s session policy grants that user access to Bluetooth audio devices.
References