Intercom - addycakes/Domotics GitHub Wiki

The intercom was hands down the most complicated part of the system. Although many alternatives exist, using a free VoIP service, Mumble in this case, proved the only method I was able to fully implement. For posterity, I tried without success to use a SIP service on the pi and PJSIP with iOS, also GOSSIP which is just a PJSIP wrapper. I then tried to use FFServer with WebRTC, but it appears support has dropped for that in most browsers, and I couldn't get audio enabled anyhow.

In the end I followed this youtube video to install the mumble-server and mumble-client onto the raspberry pi. This was very straightforward, the only issue is that the client can only be run as a GUI app, and thus needs LXSession/Startx to function.

To work around this, I configured the pi to startx on boot and added Mumble to the list of startup apps. You can set the auto-connect server and user name in the /home/pi/.config/Mumble.conf file. Once set to the correct server, the client will prepare to connect each time the client opens. The last step is to install the python library uinput which simulates keyboard strokes and mouse clicks. This can be used to finish the connection to the server and even input the password for the server if one is setup. The script I use can be found here and works to connect a mumble-client to a mumble-server without user interaction. I run this script on boot through /etc/rc.local. You don't even need a monitor plugged into the pi for this to work, but there is a performance sacrifice with running lxsession, xorg, etc.

On the iOS side, a few problems had to be overcome also. The mumblekit library for iOS does work, but is unfortunately lacking in thorough tutorials to get it working properly. I managed to get it working with my devices, but by hacking it a bit. The problem is when trying to connect with the opus audio codec, occasionally the app would crash with an range overflow in a libCelt file. I commented out the abort call, piped the error message to a separate method that reads the error log. If the overflow occurs mumble is disconnected and terminated, then a new connection is tried. This method, while not ideal, has been tested and works usually after a couple failed attempts. It is critical to set the connection attempts to 0 in the mumble-server.ini file to allow the app enough tries to successfully connect past the overflow error, otherwise an OSError with occur and you will be temporarily banned from the server.

I was only able to get this working with this code placed in its own view controller. Hopefully it will work for others as well.