|
|
Line 42: |
Line 42: |
| root@cl-rootfs:~# hcitool scan | | root@cl-rootfs:~# hcitool scan |
| Scanning ... | | Scanning ... |
− | </pre>
| |
− |
| |
− | ==== Bluez5 & PulseAudio ====
| |
− | Debian stretch/sid is using BlueZ 5 and PluseAudio 5, which are fairly new.<br>
| |
− | BlueZ 5 dropped support for alsa, so the solution for now is to use PulseAudio.<br>
| |
− | PulseAudio 5 only supports the A2DP profile and not HSP/HFP. <br>
| |
− | * Software to install {{filename|pulseaudio}}, {{filename|pulseaudio-module-bluetooth}}
| |
− | {{Note|{{filename|debian-image.tar.bz2}} has all these packages pre-installed. Continue to the [[#Start PulseAudio | Start PulseAudio]] section if you use this root filesystem.}}
| |
− | ===== Install and configure PulseAudio =====
| |
− | <pre>
| |
− | root@cl-rootfs:~# apt-get install --no-install-recommends pulseaudio pulseaudio-module-bluetooth
| |
− | </pre>
| |
− | * Create a systemd service for running pulseaudio as the pulse user.
| |
− | <pre>
| |
− | root@cl-rootfs:~# cat << eof > /etc/systemd/system/pulseaudio.service
| |
− | [Unit]
| |
− | Description=Pulse Audio
| |
− |
| |
− | [Service]
| |
− | Type=simple
| |
− | ExecStart=/usr/bin/pulseaudio --system --disallow-exit --disable-shm
| |
− |
| |
− | [Install]
| |
− | WantedBy=multi-user.target
| |
− | eof
| |
− |
| |
− | root@cl-rootfs:~# chown pulse:pulse /etc/systemd/system/pulseaudio.service
| |
− | </pre>
| |
− |
| |
− | * Create a dbus configuration file for running pulseaudio. Give the pulse user permission to use Bluetooth.
| |
− | <pre>
| |
− | root@cl-rootfs:~# cat << eof > /etc/dbus-1/system.d/pulseaudio-bluetooth.conf
| |
− | <busconfig>
| |
− |
| |
− | <policy user="pulse">
| |
− | <allow send_destination="org.bluez"/>
| |
− | </policy>
| |
− |
| |
− | </busconfig>
| |
− | eof
| |
− |
| |
− | root@cl-rootfs:~# chmod 0666 /etc/dbus-1/system.d/pulseaudio-bluetooth.conf
| |
− | </pre>
| |
− | * Paste the following lines to the end of /etc/pulse/system.pa:
| |
− | <pre>
| |
− | root@cl-rootfs:~# cat << eof >> /etc/pulse/system.pa
| |
− | ### Automatically load driver modules for Bluetooth hardware
| |
− | .ifexists module-bluetooth-policy.so
| |
− | load-module module-bluetooth-policy
| |
− | .endif
| |
− |
| |
− | .ifexists module-bluetooth-discover.so
| |
− | load-module module-bluetooth-discover
| |
− | .endif
| |
− | eof
| |
− | </pre>
| |
− | * Create {{filename|/var/run/pulse/.config/pulse}} directory. Change its ownership.
| |
− | <pre>
| |
− | root@cl-rootfs:~# mkdir -p /var/run/pulse/.config/pulse
| |
− | root@cl-rootfs:~# chown -R pulse:pulse /var/run/pulse
| |
− | </pre>
| |
− | * Make the root belong to the pulse-access,audio groups
| |
− | <pre>
| |
− | root@cl-rootfs:~# usermod -a -G pulse-access,audio root
| |
− | </pre>
| |
− |
| |
− | ===== Start PulseAudio =====
| |
− | * Start PulseAudio service
| |
− | <pre>
| |
− | root@cl-rootfs:~# systemctl daemon-reload
| |
− | root@cl-rootfs:~# systemctl start pulseaudio.service
| |
− | </pre>
| |
− | * Make sure that the service is active, running and reports on no errors.
| |
− | <pre>
| |
− | root@cl-rootfs:~# systemctl status pulseaudio.service
| |
− | Loaded: loaded (/etc/systemd/system/pulseaudio.service; disabled)
| |
− | Active: active (running) since Mon 2015-07-20 12:00:13 UTC; 1min 34s ago
| |
− | Main PID: 805 (pulseaudio)
| |
− | CGroup: /system.slice/pulseaudio.service
| |
− | └─805 /usr/bin/pulseaudio --system --disallow-exit --disable-shm
| |
− | </pre>
| |
− |
| |
− | ===== Bluez5 pairing =====
| |
− | PulseAudio 5.x supports A2DP per default.<br>
| |
− | Make sure the following packages are installed:
| |
− | pulseaudio pulseaudio-module-bluetooth pulseaudio-utils, bluez, bluez-tools.
| |
− | {{Note|Without {{filename|pulseaudio-module-bluetooth}} you won't be able to connect after the next pairing and you won't get any usable error messages.}}
| |
− |
| |
− | * Start the Bluetooth system:
| |
− | <pre>
| |
− | root@cl-rootfs:~# systemctl start bluetooth
| |
− | </pre>
| |
− | Now we can use the {{cmd|bluetoothctl}} command line utility to pair and connect. Run
| |
− | <pre>
| |
− | root@cl-rootfs:~# bluetoothctl
| |
− | [bluetooth]#
| |
− | </pre>
| |
− | to be greeted by its internal command prompt.Then enter:
| |
− | <pre>
| |
− | [bluetooth]# power on
| |
− | [bluetooth]# agent on
| |
− | [bluetooth]# default-agent
| |
− | [bluetooth]# scan
| |
− | </pre>
| |
− | Now make sure that your headset is in pairing mode. It should be discovered shortly. For example,
| |
− | <pre>
| |
− | [NEW] Device 00:07:A4:F2:B3:CB Motorola HT820
| |
− | </pre>
| |
− | shows a device that calls itself "Motorola HT820" and has MAC address 00:07:A4:F2:B3:CB.
| |
− | We will now use that MAC address to initiate the pairing:
| |
− | <pre>
| |
− | [bluetooth]# pair 00:07:A4:F2:B3:CB
| |
− | </pre>
| |
− | After pairing, you also need to explicitly connect the device:
| |
− | <pre>
| |
− | [bluetooth]# connect 00:07:A4:F2:B3:CB
| |
− | </pre>
| |
− | If everything works correctly, you now have a separate output device in PulseAudio.<br>
| |
− | You can now disable scanning again and exit the program:
| |
− | <pre>
| |
− | [bluetooth]# scan off
| |
− | [bluetooth]# exit
| |
− | </pre>
| |
− |
| |
− | ===== Playback using PulseAudio =====
| |
− | {{Note|Next examples assume that the device mac address is '''00_07_A4_F2_B3_CB'''}}
| |
− | * Show the PulseAudio device
| |
− | <pre>
| |
− | root@cl-rootfs:~# pactl list cards | awk '/00_07_A4_F2_B3_CB/' RS=""
| |
− | Card #1
| |
− | Name: bluez_card.00_07_A4_F2_B3_CB
| |
− | Driver: module-bluez5-device.c
| |
− | Owner Module: 13
| |
− | Properties:
| |
− | device.description = "Motorola HT820"
| |
− | device.string = "00:07:A4:F2:B3:CB"
| |
− | device.api = "bluez"
| |
− | device.class = "sound"
| |
− | device.bus = "bluetooth"
| |
− | device.form_factor = "headset"
| |
− | bluez.path = "/org/bluez/hci0/dev_00_07_A4_F2_B3_CB"
| |
− | bluez.class = "0x240404"
| |
− | bluez.alias = "Motorola HT820"
| |
− | device.icon_name = "audio-headset-bluetooth"
| |
− | device.intended_roles = "phone"
| |
− | Profiles:
| |
− | headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 20, available: no)
| |
− | a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 10, available: yes)
| |
− | off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
| |
− | Active Profile: a2dp_sink
| |
− | Ports:
| |
− | headset-output: Headset (priority: 0, latency offset: 0 usec)
| |
− | Part of profile(s): headset_head_unit, a2dp_sink
| |
− | headset-input: Headset (priority: 0, latency offset: 0 usec, not available)
| |
− | Part of profile(s): headset_head_unit
| |
− | </pre>
| |
− | :* Make sure the active card profile is a2dp_sink. Otherwise switch to it:
| |
− | <pre>
| |
− | # pactl set-card-profile 1 a2dp_sink
| |
− | </pre>
| |
− | :* Show the PulseAudio sink
| |
− | <pre>
| |
− | root@cl-rootfs:~# pactl list sinks | awk '/00_07_A4_F2_B3_CB/' RS=""
| |
− | Sink #1
| |
− | State: SUSPENDED
| |
− | Name: bluez_sink.00_07_A4_F2_B3_CB
| |
− | Description: Motorola HT820
| |
− | Driver: module-bluez5-device.c
| |
− | Sample Specification: s16le 2ch 48000Hz
| |
− | Channel Map: front-left,front-right
| |
− | Owner Module: 13
| |
− | Mute: no
| |
− | Volume: front-left: 65536 / 100% / 0.00 dB, front-right: 65536 / 100% / 0.00 dB
| |
− | balance 0.00
| |
− | Base Volume: 65536 / 100% / 0.00 dB
| |
− | Monitor Source: bluez_sink.00_07_A4_F2_B3_CB.monitor
| |
− | Latency: 0 usec, configured 0 usec
| |
− | Flags: HARDWARE DECIBEL_VOLUME LATENCY
| |
− | Properties:
| |
− | bluetooth.protocol = "a2dp_sink"
| |
− | device.description = "Motorola HT820"
| |
− | device.string = "00:07:A4:F2:B3:CB"
| |
− | device.api = "bluez"
| |
− | device.class = "sound"
| |
− | device.bus = "bluetooth"
| |
− | device.form_factor = "headset"
| |
− | bluez.path = "/org/bluez/hci0/dev_00_07_A4_F2_B3_CB"
| |
− | bluez.class = "0x240404"
| |
− | bluez.alias = "Motorola HT820"
| |
− | device.icon_name = "audio-headset-bluetooth"
| |
− | device.intended_roles = "phone"
| |
− | Ports:
| |
− | headset-output: Headset (priority: 0)
| |
− | Active Port: headset-output
| |
− | Formats:
| |
− | pcm
| |
− | </pre>
| |
− | :* Play sound using {{filename|paplay}}. Example:
| |
− | <pre>
| |
− | root@cl-rootfs:~# paplay -d bluez_sink.00_07_A4_F2_B3_CB /path/to/<audio-file.wav>
| |
| </pre> | | </pre> |