Saturday, April 15, 2017

Home IP phone server by Raspberry Pi + asterisk

I built a PBX (IP phone server) with Raspberry Pi and made an extension call with old smartphone.
My 5 year old daughter seemes happy that she obtained her own mobile phone.
Many phone call comes from her.

Call with an outside line is also possible if configure.
But, for now, my goal is a usable toy phone by simple configuration, for now.


Asterisk vs RasPBX

I used software "Aterisk" to make Raspberry Pi a PBX.

As another way, Raspberry Pi distribution RasPBX is also available.
PasPBX provides very easy setup and web base configuration.

Today's goal is a toy, so advanced settings are not needed.
Plus, I want to use a Raspberry Pi also for other purposes.
So, I chose Asterisk, not RasPBX.

Install Asterisk

Just use apt-get.
pi@raspberrypi ~ $ sudo apt-get install asterisk

The necessary users are created automatically.

Setup Asterisk:/etc/asterisk/sip.conf



First, define phone numbers in /etc/asterisk/sip.conf.
It is a very large configuration file, but most parts are commented out.
general セクションだけ探して書き換えたら、あとは末尾に書き足せばOKです。
Modify one line at general section.
And then, add number definitions at the end of file.
[general]
localhost=192.168.11.0/255.255.255.0
[5130]
type=friend
username=5130
secret=PASSWORD
canreinvite=no
host=dynamic

[5134]
type=friend
username=5134
secret=PASSWORD
canreinvite=no
host=dynamic

The address written at general section is the network segment which the Raspberry Pi connects to.

The numbers with angle brackets are phone numbers.
Any number of digits are acceptable.
If the first digit is the same, it will be easier to set up later.

"username" and "secret" are the account for registering a phone.

Setup Asterisk:/etc/asterisk/rtp.conf

As asterisk uses 10,000 ports as a default configuration, it should be reduced.

rtpstart=10000
;rtpend=20000
rtpend=10010

Setup Asterisk:/etc/asterisk/extensions.conf

Modify [default] section as follows.

exten => _5XXX,1,Dial(SIP/${EXTEN},30)
exten => _5XXX,2,Congestion
exten => _5XXX,102,Busy

"_5XXX" means "Four digits starting with 5".
This parameter should match the number defined in sip.cnf.

Restart Asterisk

The setting of Asterisk is completed.
Restart the asterisk server.

pi@raspberrypi ~ $ sudo service asterisk restart
Stopping Asterisk PBX: asterisk.
Starting Asterisk PBX: asterisk.

Setup smartphone

Various applications are found by searching "SIP" on Google play / AppStore.
You can use whatever you like.
Although android also has SIP function on OS itself, I don't recommend it as it is not easy to use.

I chose these apps, because they are usable even for kids.

On these apps, enter the phone number, username, and password defined in sip.conf.
Of course, the smartphones have to connect the same network segment as Raspberry Pi via WiFi.

Call each other

All configuration are completed.
Let's try calling.
Check SIP apps to launch on both of calling device and receiving device have to launch the SIP apps.

If you give unnecessary smartphones to kids, they can really call to parent's smartphone so they gets excited.

No comments:

Post a Comment