Raspberry Asterisk and an SPA3102 Voice Gateway

In my last blog post a little while ago, I looked at how a Raspberry Pi could be used as a VoIP to GSM gateway. I’ve actually been running a Raspberry Asterisk phone system for a little while now, and I thought I’d share what I’ve come up with.

Why?
So the main reasons for running a VoIP phone system on a miniature credit card sized computer were to get my teeth back into Linux administration and learn a little more about Voice over IP. I also wanted to make my home PSTN phone available over IP so I can call a local extension if I am working abroad or in an area with no GSM coverage, or answer my house phone at work. I also wanted to get voicemail sent to me via email rather than listening for a 1571 dial tone.

SPA3102
I had played with a Raspberry Pi running raspberry asterisk, had created a few test accounts with VoIP telecoms providers (I am now the proud owner of several phone numbers beginning with 05). But to fulfill my aim of getting my house phone via IP I needed to either get a full blown PC and get a PSTN to IP card, or invest in a hardware gateway. A quick search on ebay revealed that the Linksys SPA3102 was what I was after. It looks like a domestic broadband router but it actually has several ports:

    One FXO port – This is an RJ11 port that you would connect to your BT phone socket, thus making your BT line available to a VoIP system
    One FXS port – This is an RJ11 port that you plug your analogue phone into, thus allowing your existing phone to be used as a VOIP extension
    Two Ethernet ports – Used to connect to the same network as your phone system

I managed to pick up an SPA3102 for about £40. It has a neat web interface and has literally hundreds of options to tweak. I discovered by far the best document on how to set up an SPA3102 in a UK asterisk system over at aoakley.com, which saved several hours of heartache. One key setting was to set up a dialplan so I could still dial 999 directly, without going via the Asterisk system.

Setting up my BT line as a new inbound SIP trunk in the Raspberry Asterisk web based control panel, I was able to make my (now IP extension) home phone ring when someone calls my landline.

Looking at that last statement, it seems like a waste of effort (and £65) to replicate the phone system I already had. But from here on in, I can attach a software phone on my laptop or laptop to my home phone system. Setting up an extension ring group, my mobile phone rings at the same time as my home phone. If no-one answers, that extension goes to a voicemail module and emails me an audio file of the message, along with their number.

I can call my house phone as an extension from one of my software phones too. This is great for staying in touch with family when I’m working abroad, without touching any public telecoms network. I spend a reasonable amount of time in the Middle East where mobile roaming costs can be very high. Vodafone UK charge a whopping £1.65 per minute whilst roaming in Jordan, so the ability to have long calls home is very useful. Skype is ubiquitous, but often isn’t left running, whereas my home phone is always switched on. I can also dial out from wherever I am from my home landline, which is great for when I’m sat in a building with WiFi but no mobile coverage. And should I feel the need to filter out nuisance phone calls, I can easily implement an IVR system (Press 1 for Jamie, 2 to leave a voicemail) or different rules at different times of day.

It’s not without issues: Echo is a big problem, and I’m still tweaking with settings to achieve reasonable volume without echo being heard by both callers. I wonder whether the hardware limitations of the Pi make things a little worse, or whether things could be improved with an IP phone handset rather than using the SPA3102’s FXS port. Running Asterisk on a Raspberry Pi also means that I’m not able to choose some of the more bandwidth efficient audio codecs that require an x86 processor architecture.

It has been a great way to get my IP telephony skills up to scratch without spending a huge amount of money. Now all I need to do is install a few more gateways, perhaps in my workplace phone system which is not currently IP enabled.