How to: Raspberry PI WIFI card static IP setting

Edit command:

sudo nano /etc/network/interfaces

Static IP setting:

iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet static
address 192.168.0.10
netmask 255.255.255.0
network 192.168.0.0
gateway 192.168.0.1

DHCP setting:

iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Refresh wifi card setting:

sudo ifdown wlan0
sudo ifup wlan0

How To : Raspberry PI install Asterisk 13

Raspberry Pi OS: Raspbian

Terminal / SSH

sudo apt-get install -y gcc make perl
sudo apt-get install -y libxml2 libxml2-dev
sudo apt-get install -y speex libspeexdsp-dev libspeex-dev ncurses-dev bison openssl libssl-dev sqlite3 libsqlite3-dev
sudo apt-get install -y libncurses5-dev subversion git-core libjansson-dev uuid-dev build-essential libsrtp0-dev

wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz
tar zxvf asterisk-13-current.tar.gz
cd asterisk-13.0.5 (Path 會改的)
./configure
make menuselect
make -j 4 (用4個 core, for Raspberry Pi 2 ) / make (Raspberry Pi )
sudo make install
sudo make samples
sudo make config

sample dialplan

sudo nano /etc/asterisk/extensions.conf 加在最後面 (nano goto file end short-cut key : Ctrl + w + v )

[mycontext]
exten => _2XXX,1,Answer()
exten => _2XXX,n,NoOP(exten=${EXTEN})
exten => _2XXX,n,Dial(SIP/${EXTEN})
exten => _2XXX,n,Hangup

;For Text chat
[messages]
exten => _.,1,NoOp(SMS receiving dialplan invoked)
exten => _.,n,NoOp(To ${MESSAGE(to)})
exten => _.,n,NoOp(From ${MESSAGE(from)})
exten => _.,n,NoOp(Body ${MESSAGE(body)})
exten => _.,n,Set(ACTUALTO=${CUT(MESSAGE(to),@,1)})
exten => _.,n,Set(CDR(message)=${MESSAGE(from)})
exten => _.,n,MessageSend(${ACTUALTO},${MESSAGE(from)})
exten => _.,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => _.,n,GotoIf($[“${MESSAGE_SEND_STATUS}” != «SUCCESS»]?sendfailedmsg)
exten => _.,n,Hangup()
;
; Handle failed messaging
exten => _.,n(sendfailedmsg),Set(MESSAGE(body)=”[${STRFTIME(${EPOCH},,%d%m%Y-%H:%M:%S)}] Your message to ${EXTEN} has failed. Retry later.”)
exten => _.,n,Set(ME_1=${CUT(MESSAGE(from),<,2)}) exten => _.,n,Set(ACTUALFROM=${CUT(ME_1,@,1)})
exten => _.,n,MessageSend(${ACTUALFROM},ServiceCenter)
exten => _.,n,Hangup()
exten => _.,n,Hangup()

sudo nano /etc/asterisk/sip.conf

[general]
videosupport=yes ;For video call
tcpenable=yes ;For mobile phone, Mobile phone can’t get incoming call when use UDP.
accept_outofcall_message=yes ;For text chat
outofcall_message_context=messages ;For text chat
auth_message_requests=yes ;For text chat

;加在最後面
[2001]
type = friend
context=mycontext
callerid = User One <2001>
secret =
host = dynamic
canreinvite = no
dtmfmode = rfc2833
mailbox = 2001
disallow = all
allow = speex,g722,ilbc ; Auido codec
allow = vp8 ; Video codec
transport = udp

[2002]
type = friend
context=mycontext
callerid = User Two <2002>
secret =
host = dynamic
canreinvite = no
dtmfmode = rfc2833
mailbox = 2002
disallow = all
allow = speex,g722,ilbc ; Auido codec
allow = vp8 ; Video codec
transport = udp

Re-load config:
sudo asterisk -r
reload

P.S.
Raspberry Pi 最好是用有線接 Network
因為要用 Compiler,Raspberry Pi 2 比較好.

Link:
Raspbian install Asterisk 13
Raspberry PiとAsteriskでIP電話システムの構築(その1)
Asterisk Project Home – Getting Started
Asterisk 13 SIP SIMPLE messages to CDR
Asterisk權威指南