Tom, other interested people,
I finally got it working on a raspberry pi-4 with buster lite,
mostly thanks to the following articles:
https://sigmdel.ca/michel/ha/rpi/bluetooth_01_en.html
https://sigmdel.ca/michel/ha/rpi/bluetooth_02_en.html
https://sigmdel.ca/michel/ha/rpi/bluetooth_n_buster_01_en.html
The exact reproducible steps have been:
- Started on the basis of

+ my FreeSwitch installation based on instructions under https://freeswitch.org/confluence/display/FREESWITCH/Raspberry+Pi
- sudo apt-get update &&
sudo apt-get install -y bluealsa
- sudo vi
/lib/systemd/system/bluealsa.service
--> substituted ExecStart=/usr/bin/bluealsa
with
--> Environment=LIBASOUND_THREAD_SAFE=0
ExecStart=/usr/bin/bluealsa -p hfp-hf -p hsp-hs -p hfp-ag
-p hsp-ag -p a2dp-source -p a2dp-sink
- sudo vi
/lib/systemd/system/bluetooth.service
--> Added --noplugin=sap to the
end of the following line
ExecStart=/usr/lib/bluetooth/bluetoothd
- sudo vi
/lib/systemd/system/bthelper@.service
--> Added ExecStartPre=/bin/sleep
2 in
a new line after
Type=simple
- Created a new file by sudo
vi /etc/asound.conf
and added the following as its sole content
(if you know the MAC address of your Bluetooth
device, substitute it already now; otherwise
you can change it also later in step 9):
pcm.btAudioIO {
type asym
playback.pcm {
type plug
slave.pcm {
type bluealsa
service "org.bluealsa"
device
"00:11:09:94:14:3D"
profile "a2dp"
delay 10000
}
}
capture.pcm {
type plug
slave.pcm {
type bluealsa
service "org.bluealsa"
device
"00:11:09:94:14:3D"
profile "sco"
delay 10000
}
}
hint {
show on
description "Bluetooth Audio
Input/Output Dvice"
}
}
- sudo adduser freeswitch audio
sudo adduser freeswitch bluetooth
sudo reboot
- After reboot, run sudo
bluetoothctl and then find, pair, connect
and trust your Bluetooth device with the
following control commands of this program:
agent on
scan on
<-- find the MAC
address of your device in the scan
outputs
pair
50:11:2D:06:ED:2F
scan off
connect
50:11:2D:06:ED:2F
trust 50:11:2D:06:ED:2F
exit
--> from now on, your device
should
automatically
reconnect to
the pi each
time after the
pi is
rebooted; if,
however, this
is not the
case, you will
have to redo
this step
after each
reboot.
- In this example, the device
that I have paired and trusted has a different
MAC address as the one in /etc/asound.conf;
therefore we must edit the file and set the
right MAC address. If you already had the
right MAC address, you may go to the next step
without reboot; but, if you had to change the
file /etc/asound.conf, then you will have to
reboot before going to the next step.
- Test your device with the
following two commands (five seconds
recording):
arecord -D btAudioIO -d 5 test.wav
aplay -D btAudioIO
test.wav
- Assuming that the above test is
successful, you now
- edit <FreeSwitch-Config-Home>/autoload_configs/modules.conf.xml
and un-comment the loading of mod_portaudio
- edit <FreeSwitch-Config-Home>/autoload_configs/portaudio.conf.xml
and substitute the whole
content with the following
new content:
<configuration
name="portaudio.conf"
description="Soundcard
Endpoint">
<settings>
<param name="indev"
value="btAudioIO"/>
<param name="outdev"
value="btAudioIO"/>
<param name="ringdev"
value="btAudioIO"/>
<param name="hold-file"
value="$${hold_music}"/>
<param name="dialplan"
value="XML"/>
<param name="cid-name"
value="$${outbound_caller_name}"/>
<param name="cid-num"
value="$${outbound_caller_id}"/>
<param
name="sample-rate"
value="48000"/>
<param name="codec-ms"
value="20"/>
</settings>
</configuration>c
- In my case, I
didn't need to do anything
for dial plans because in my
system both the in- and
outbound calls are first
handled by my python
scripts; in particular, the
BT handsfree device is never
supposed to make calls but
is called for making
announcements or invited to
a running call as the
third leg. So far, I was
using an IP telephone
with auto-answering
capability as extension
000 of my FreeSwitch for
this purpose. To
substitute that phone
with the BT handsfree
device, I just needed to
update my related python
script with the
following command:
sudo sed -i
's#user/000@[0-9.]+#portaudio/auto_answer#g'
dial.py
After a reboot, after which also FreeSwitch and my application
start, everything was working for me just fine :-)
Cheers,
-- Saied
I'm in the same boat with portaudio when it's started
with systemd. When I disable it as a service and start it from
the command line, pa devlist does return a list of devices. Still
workingon getting a call from portaudio to a station and vice
versa. Calling a station from portaudio device goes to voicemail
and in reverse direction I never get a ring indication, just music
on hold.
Lesley Pervis wrote
> Sorry for the spam, but I thought I'd mention that I can aplay
no problem
> from the command line as the 'freeswitch' user, and yet when FS
is running
> as that user, no luck.
Exactly seven years after your last post here, I'm there to ask if
you
finally succeeded to resolve the issue?
My case:
1. Pi-4 with Raspbian buster und latest related FreeSwitch
distribution,
apt-upgraded and updated just yesterday
2. aplay is working both with the audio jack and with bluetooth
(although
not simultaneously: as soon as I have a bluetooth audio connection,
the
audio jack stops to work, and I cannot switch back to it with
"amixer cset
numid=3 1", but aplay can continue to use the bluetooth connection
again
after I issue "amixer cset numid=3 65536")
3. it seems that I do not have any permission issue as both pi and
freeswitch are in the audio group and related devices under /dev/snd
are in
that group
4. I have already installed alsaoss, libasound2 and libasound2-dev
5. The output of "pa rescan" in fs_cli is the following:
2020-06-19 06:55:18.803478 [INFO] mod_portaudio.c:3186 Looking for
new
devices.
2020-06-19 06:55:18.803478 [INFO] mod_portaudio.c:2102 PortAudio
version
number = 1246720
PortAudio version text = 'PortAudio V19.6.0-devel, revision
396fe4b6699ae929d3a685b3ef8a7e97396139a4'
2020-06-19 06:55:18.943433 [DEBUG] mod_portaudio.c:1773 global indev
[-1]
2020-06-19 06:55:18.943433 [ERR] mod_portaudio.c:1777 Cannot find an
input
device
2020-06-19 06:55:18.943433 [DEBUG] mod_portaudio.c:1786 global
outdev [-1]
2020-06-19 06:55:18.943433 [ERR] mod_portaudio.c:1790 Cannot find an
output
device
2020-06-19 06:55:18.943433 [INFO] mod_portaudio.c:2125 Number of
devices = 0
Any clue, what could be wrong on my side?
Thanks!