# Perform Bluetooth HFP audio gateway functions

You can perform HFP audio gateway functions using the `bluetoothctl` menu and `paplay` commands.

Before you begin, [set up your device](https://docs.qualcomm.com/doc/80-70020-13/topic/bluez-hfp.html#section-rmp-dgv-mcc-navyanka-08-25-24-1227-32-765) and [configure the DUT for HFP audio gateway functions](https://docs.qualcomm.com/doc/80-70020-13/topic/bluez-hfp.html#section-jgk-r3v-mcc-navyanka-08-25-24-1246-49-237).

## Connect a remote device

To connect a remote device, run the following command from the `bluetoothctl` menu:

connect <bt_address>
    Copy to clipboard

**Parameters**

`<bt_address>` is the Bluetooth address of the remote device.

**Example**

To connect to a paired remote device with `<bt_address>` `20:19:D8:36:90:40`, run the following command:

connect 20:19:D8:36:90:40
    Copy to clipboard

**Sample output**

[Test]# connect 20:19:D8:36:90:40
    Attempting to connect to 20:19:D8:36:90:40
    [CHG] Device 20:19:D8:36:90:40 Connected: yes
    [CHG] Device 20:19:D8:36:90:40 UUIDs: 00001108-0000-1000-8000-00805f9b34fb
    [CHG] Device 20:19:D8:36:90:40 UUIDs: 0000110b-0000-1000-8000-00805f9b34fb
    [CHG] Device 20:19:D8:36:90:40 UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
    [CHG] Device 20:19:D8:36:90:40 UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
    [CHG] Device 20:19:D8:36:90:40 UUIDs: 0000111e-0000-1000-8000-00805f9b34fb
    [CHG] Device 20:19:D8:36:90:40 ServicesResolved: yes
    [CHG] Device 20:19:D8:36:90:40 Bonded: yes
    [CHG] Device 20:19:D8:36:90:40 Paired: yes
    [NEW] Endpoint /org/bluez/hci0/dev_20_19_D8_36_90_40/sep1
    [NEW] Transport /org/bluez/hci0/dev_20_19_D8_36_90_40/sep1/fd1
    Connection successful
    [CHG] Transport /org/bluez/hci0/dev_20_19_D8_36_90_40/sep1/fdl State: active
    [CHG] Transport /org/bluez/hci0/dev_20_19_D8_36_90_40/sep1/fd1 Volume: 0x0068 (104)
    [CHG] Transport /org/bluez/hci0/dev_20_19_D8_36_90_40/sep1/fd1 State: idle
    Copy to clipboard

## Verify audio gateway functionality

To verify the audio gateway functionality, do the following:

1. Create a dummy SCO as follows:

    1. Run SSH.
    2. Play a WAV file by running the following command:

paplay <file.wav> -v
            Copy to clipboard

        **Example**

        To play the `AG_playback.wav` file, run the following command:

paplay AG_playback.wav -v
            Copy to clipboard

        **Sample output**

sh-5.1# paplay AG_playback.wav -v
            Opening a playback stream with sample specification 's16le 2ch 8000Hz' and channel map 'front-left,front-right'
            Connection established.
            Stream successfully created.
            Buffer metrics: maxlength=4194304, tlength=64000, prebuf=63364, minreq=640
            Using sample spec 's16le 2ch 8000Hz', channel map 'front-left,front-right'.
            Connected to device bluez_sink.20_19_D8_36_90_40.handsfree_head_unit (index: 7, suspended: no).
            Stream started.
            Time: 2.003 sec; Latency: 2042009 usec.
            Copy to clipboard
2. Receive microphone data from the remote device by running the following command:

parec -v --rate=<rate> --format=<format> --channels=<channel_number> --file-format=<file_format audio_filepath> --device=<device_name>
        Copy to clipboard

    **Parameters**

    | Options | Parameter | Description | Example |
    | --- | --- | --- | --- |
    | `--rate` | `<rate>` | The specific sample rate to play the audio file. | `16000` |
    | `--format` | `<format>` | The specific sample format to play the audio file. | `s16le` |
    | `--channels` | `<channel_number>` | The specific number of channels to play the audio file. | `1` |
    | `--file-format` | `<file_format audio_filepath>` | The file format to play the audio file from a directory. | `wav /data/rec1.wav` |
    | `--device` | `<device_name>` | The device name of the source or sink to play the audio file. | `bluez_source.20_19_D8_36_90_40.handsfree_head_unit` |

    **Example**

    To receive microphone data from a remote device for the example values listed in the table, run the following command:

parec -v --rate=16000 --format=s16le --channels=1 --file-format=wav /data/rec1.wav --device=bluez_source.20_19_D8_36_90_40.handsfree_head_unit
        Copy to clipboard
3. Play the recorded microphone data and verify if the audio is clear.

## Disconnect a remote device

To disconnect a remote device, run the following command from the `bluetoothctl` menu:

disconnect <bt_address>
    Copy to clipboard

**Parameters**

`<bt_address>` is the Bluetooth address of the remote device.

**Example**

To disconnect a paired remote device with `<bt_address>` `20:19:D8:36:90:40`, run the following command:

disconnect 20:19:D8:36:90:40
    Copy to clipboard

**Sample output**

[MyHeadset]# disconnect 20:19:D8:36:90:40
    Attempting to disconnect from 20:19:D8:36:90:40
    [DEL] Transport /org/bluez/hci0/dev_20_19_D8_36_90_40/sep1/fd2
    [DEL] Endpoint /org/bluez/hci0/dev_20_19_D8_36_90_40/sep1
    [CHG] Device 20:19:D8:36:90:40 ServicesResolved: no
    Successful disconnected
    [CHG] Device 20:19:D8:36:90:40 Connected: no
    Copy to clipboard

Last Published: Jun 26, 2025

[Previous Topic
Perform Bluetooth HFP client functions](https://docs.qualcomm.com/bundle/publicresource/80-70020-13/topics/bluez-perform-bluetooth-hfp-client-functions.md) [Next Topic
Object Push Profile](https://docs.qualcomm.com/bundle/publicresource/80-70020-13/topics/bluez-opp.md)