Asterisk with USB dongle as GSM gateway on OpenWRT

   

   

   

   

root@OpenWrt:~# cat /etc/asterisk/sip.conf
;!
;! Automatically generated configuration file
;! Filename: sip.conf (/etc/asterisk/sip.conf)
;! Generator: Manager
;! Creation Date: Sat May 28 18:56:49 2016
;!
;
; SIP Configuration example for Asterisk
;
; Note: Please read the security documentation for Asterisk in order to
;       understand the risks of installing Asterisk with the sample
;       configuration. If your Asterisk is installed on a public
;       IP address connected to the Internet, you will want to learn
;       about the various security settings BEFORE you start
;       Asterisk.
;
;       Especially note the following settings:
;               - allowguest (default enabled)
;               - permit/deny/acl - IP address filters
;               - contactpermit/contactdeny/contactacl - IP address filters for registrations
;               - context - Which set of services you offer various users
;
; SIP dial strings
;-----------------------------------------------------------
; In the dialplan (extensions.conf) you can use several
; syntaxes for dialing SIP devices.
;        SIP/devicename
;        SIP/username@domain   (SIP uri)
;        SIP/username[:password[:md5secret[:authname[:transport]]]]@host[:port]
;        SIP/devicename/extension
;        SIP/devicename/extension/IPorHost
;        SIP/username@domain//IPorHost
;
;
; Devicename
;        devicename is defined as a peer in a section below.
;
; username@domain
;        Call any SIP user on the Internet
;        (Don't forget to enable DNS SRV records if you want to use this)
;
; devicename/extension
;        If you define a SIP proxy as a peer below, you may call
;        SIP/proxyhostname/user or SIP/user@proxyhostname
;        where the proxyhostname is defined in a section below
;        This syntax also works with ATA's with FXO ports
;
; CLI Commands
; -------------------------------------------------------------
; Useful CLI commands to check peers/users:
;   sip show peers               Show all SIP peers (including friends)
;   sip show registry            Show status of hosts we register with
;
;   sip set debug on             Show all SIP messages
;
;   sip reload                   Reload configuration file
;   sip show settings            Show the current channel configuration
;

[general]
context = public  ; Default context for incoming calls. Defaults to 'default'
allowguest=no                  ; Allow or reject guest calls (default is yes)
;match_auth_username=yes        ; if available, match user entry using the
allowoverlap = no  ; Disable overlap dialing support. (Default is yes)
;allowtransfer=no               ; Disable all transfers (unless enabled in peers or users)
;realm=mydomain.tld             ; Realm for digest authentication
;domainsasrealm=no              ; Use domains list as realms
udpbindaddr = 0.0.0.0  ; IP address to bind UDP listen socket to (0.0.0.0 binds to all)
; Optionally add a port number, 192.168.1.1:5062 (default is port 5060)
tcpenable = no  ; Enable server for incoming TCP connections (default is no)
tcpbindaddr = 0.0.0.0  ; IP address for TCP server to bind to (0.0.0.0 binds to all interfaces)
;tlsenable=no                   ; Enable server for incoming TLS (secure) connections (default is no)
;tlsbindaddr=0.0.0.0            ; IP address for TLS server to bind to (0.0.0.0) binds to all interfaces)
transport = udp  ; Set the default transports.  The order determines the primary default transport.
srvlookup = yes  ; Enable DNS SRV lookups on outbound calls
subscribecontext = default
allowexternaldomains = yes
allowguest = yes
allowsubscribe = yes
allowtransfer = yes
alwaysauthreject = no
autodomain = no
callevents = no
checkmwi = 10
compactheaders = no
defaultexpiry = 120
dumphistory = no
externrefresh = 10
g726nonstandard = no
jbenable = no
jbforce = no
jblog = no
maxcallbitrate = 1024
maxexpiry = 3600
minexpiry = 60
mohinterpret = default
notifyringing = yes
pedantic = no
progressinband = never
promiscredir = no
realm = asterisk
recordhistory = no
registerattempts = 0
registertimeout = 20
relaxdtmf = no
sendrpid = no
sipdebug = no
t1min = 100
t38pt_udptl = no
tos_audio = none
tos_sip = none
tos_video = none
trustrpid = no
useragent = Asterisk PBX
usereqphone = no
videosupport = yes

bindport = 61982
disallow = all
allow = ulaw,alaw,gsm,h264,g729
;pedantic=yes                   ; Enable checking of tags in headers,
[basic-options](!); a template
dtmfmode = rfc2833
context = from-office
type = friend

[natted-phone](!,basic-options); another template inheriting basic-options
directmedia = no
host = dynamic

[public-phone](!,basic-options); another template inheriting basic-options
directmedia = yes

[my-codecs](!); a template for my preferred codecs
disallow = all
allow = ilbc
allow = g729
allow = gsm
allow = g723
allow = ulaw
; Or, more simply:
;allow=!all,ilbc,g729,gsm,g723,ulaw
[ulaw-phone](!); and another one for ulaw-only
disallow = all
allow = ulaw

root@OpenWrt:~# cat /etc/asterisk/extensions.conf
;!
;! Automatically generated configuration file
;! Filename: extensions.conf (/etc/asterisk/extensions.conf)
;! Generator: Manager
;! Creation Date: Mon May 30 20:06:33 2016
;!
[general]
static = yes
writeprotect = no
clearglobalvars = yes
[globals]
FEATURES =
DIALOPTIONS =
RINGTIME = 20
FOLLOWMEOPTIONS =
PAGING_HEADER = Intercom
CID_403 = 403
CID_402 = 402
CID_401 = 401
CID_400 = 400
[default]
[macro-stdexten]
exten = s,1,Set(__DYNAMIC_FEATURES=${FEATURES})
exten = s,2,Set(ORIG_ARG1=${ARG1})
exten = s,3,GotoIf($["${FOLLOWME_${ARG1}}" = "1"]?6:4)
exten = s,4,Dial(${ARG2},${RINGTIME},${DIALOPTIONS})
exten = s,5,Goto(s-${DIALSTATUS},1)
exten = s,6,Macro(stdexten-followme,${ARG1},${ARG2})
exten = s-NOANSWER,1,Voicemail(${ORIG_ARG1},u)
exten = s-NOANSWER,2,Goto(default,s,1)
exten = s-BUSY,1,Voicemail(${ORIG_ARG1},b)
exten = s-BUSY,2,Goto(default,s,1)
exten = _s-.,1,Goto(s-NOANSWER,1)
exten = a,1,VoicemailMain(${ORIG_ARG1})
[macro-stdexten-followme]
exten = s,1,Answer
exten = s,2,Set(ORIG_ARG1=${ARG1})
exten = s,3,Dial(${ARG2},${RINGTIME},${DIALOPTIONS})
exten = s,4,Set(__FMCIDNUM=${CALLERID(num)})
exten = s,5,Set(__FMCIDNAME=${CALLERID(name)})
exten = s,6,Followme(${ORIG_ARG1},${FOLLOWMEOPTIONS})
exten = s,7,Voicemail(${ORIG_ARG1},u)
exten = s-NOANSWER,1,Voicemail(${ORIG_ARG1},u)
exten = s-BUSY,1,Voicemail(${ORIG_ARG1},b)
exten = s-BUSY,2,Goto(default,s,1)
exten = _s-.,1,Goto(s-NOANSWER,1)
exten = a,1,VoicemailMain(${ORIG_ARG1})
[macro-pagingintercom]
exten = s,1,SIPAddHeader(Alert-Info: ${PAGING_HEADER})
exten = s,2,Page(${ARG1},${ARG2})
exten = s,3,Hangup
[conferences]
[ringgroups]
[queues]
[voicemenus]
[voicemailgroups]
[directory]
[page_an_extension]
[pagegroups]
[asterisk_guitools]
exten = executecommand,1,System(${command})
exten = executecommand,n,Hangup()
exten = record_vmenu,1,Answer
exten = record_vmenu,n,Playback(vm-intro)
exten = record_vmenu,n,Record(${var1},0,500,k)
exten = record_vmenu,n,Playback(vm-saved)
exten = record_vmenu,n,Playback(vm-goodbye)
exten = record_vmenu,n,Hangup
exten = play_file,1,Answer
exten = play_file,n,Playback(${var1})
exten = play_file,n,Hangup
[macro-local-callingrule-cid-0.1]
exten = s,1,Set(CALLERID(all)=${IF($[${LEN(${ARG4})} > 2]?${ARG4}:)})
exten = s,n,Goto(${ARG1},${ARG2},${ARG3})
[macro-trunkdial-failover-0.3]
exten = s,1,GotoIf($[${LEN(${FMCIDNUM})} > 6]?1-fmsetcid,1)
exten = s,n,GotoIf($[${LEN(${GLOBAL_OUTBOUNDCIDNAME})} > 1]?1-setgbobname,1)
exten = s,n,Set(CALLERID(num)=${IF($[${LEN(${CID_${CALLERID(num)}})} > 2]?${CID_${CALLERID(num)}}:)})
exten = s,n,Set(CALLERID(all)=${IF($[${LEN(${ARG5})} > 2]?${ARG5}:)})
exten = s,n,GotoIf($[${LEN(${CALLERID(num)})} > 6]?1-dial,1)
exten = s,n,Set(CALLERID(all)=${IF($[${LEN(${CID_${ARG3}})} > 6]?${CID_${ARG3}}:${GLOBAL_OUTBOUNDCID})})
exten = s,n,Set(CALLERID(all)=${IF($[${LEN(${ARG5})} > 2]?${ARG5}:)})
exten = s,n,Goto(1-dial,1)
exten = 1-setgbobname,1,Set(CALLERID(name)=${GLOBAL_OUTBOUNDCIDNAME})
exten = 1-setgbobname,n,Goto(s,3)
exten = 1-fmsetcid,1,Set(CALLERID(num)=${FMCIDNUM})
exten = 1-fmsetcid,n,Set(CALLERID(name)=${FMCIDNAME})
exten = 1-fmsetcid,n,Goto(s,4)
exten = 1-dial,1,Dial(${ARG1})
exten = 1-dial,n,Gotoif(${LEN(${ARG2})} > 0 ?1-${DIALSTATUS},1:1-out,1)
exten = 1-CHANUNAVAIL,1,Dial(${ARG2})
exten = 1-CHANUNAVAIL,n,Hangup()
exten = 1-CONGESTION,1,Dial(${ARG2})
exten = 1-CONGESTION,n,Hangup()
exten = 1-out,1,Hangup()
[queue-member-manager]
exten = handle_member,1,Verbose(2, Looping through queues to log in or out queue members)
exten = handle_member,n,Set(thisActiveMember=${CHANNEL(channeltype)}/${CHANNEL(peername)})
exten = handle_member,n,Set(queue_field=2)
exten = handle_member,n,Set(thisQueueXtn=${CUT(QUEUES,\,,${queue_field})})
exten = handle_member,n,While($[${EXISTS(${thisQueueXtn})}])
exten = handle_member,n,Macro(member-loginlogout)
exten = handle_member,n,Set(queue_field=$[${queue_field} + 1])
exten = handle_member,n,Set(thisQueueXtn=${CUT(QUEUES,\,,${queue_field})})
exten = handle_member,n,EndWhile()
[macro-member-loginlogout]
exten = s,1,Verbose(2, Logging queue member in or out of the request queue)
exten = s,n,Set(thisQueue=${thisQueueXtn})
exten = s,n,Set(queueMembers=${QUEUE_MEMBER_LIST(${thisQueue})})
exten = s,n,Set(field=1)
exten = s,n,Set(logged_in=0)
exten = s,n,Set(thisQueueMember=${CUT(queueMembers,\,,${field})})
exten = s,n,While($[${EXISTS(${thisQueueMember})}])
exten = s,n,GotoIf($["${thisQueueMember}" != "${thisActiveMember}"]?check_next)
exten = s,n,Set(logged_in=1)
exten = s,n,ExitWhile()
exten = s,n(check_next),Set(field=$[${field} + 1])
exten = s,n,Set(thisQueueMember=${CUT(queueMembers,\,,${field})})
exten = s,n,EndWhile()
exten = s,n,MacroIf($[${logged_in} = 0]?q_login:q_logout)
[macro-q_login]
exten = s,1,Verbose(2, Logging ${thisActiveMember} into the ${thisQueue} queue)
exten = s,n,AddQueueMember(${thisQueue},${thisActiveMember})
exten = s,n,Playback(silence/1)
exten = s,n,ExecIf($["${AQMSTATUS}" = "ADDED"]?Playback(agent-loginok):Playback(an-error-has-occurred))
[macro-q_logout]
exten = s,1,Verbose(2, Logged ${thisActiveMember} out of ${thisQueue} queue)
exten = s,n,RemoveQueueMember(${thisQueue},${thisActiveMember})
exten = s,n,Playback(silence/1)
exten = s,n,ExecIf($["${RQMSTATUS}" = "REMOVED"]?Playback(agent-loggedoff):Playback(an-error-has-occurred))

[gsm_incoming]
exten => s,1,Background(vm-enter-num-to-call)
exten => s,n,Read(NUMBER,,3,,2)
exten => s,n,GotoIf($["${SIPPEER(${NUMBER},status)}" = ""]?number_not_exists)
exten => s,n,Dial(SIP/${NUMBER},,)
exten => s,n,Hangup()
exten => s,n(number_not_exists),Playback(pbx-invalid)
exten => s,n,Hangup()

[CallingRule_gsm_outgoing]
exten = _0.,1,Dial(dongle/dongle0/${EXTEN})
exten = _+.,1,Dial(dongle/dongle0/${EXTEN})
exten = _0.,n,Hangup()
exten = _+.,n,Hangup()

[DLPN_DialPlan1]
include = CallingRule_gsm_outgoing
include = default
include = parkedcalls
include = conferences
include = ringgroups
include = voicemenus
include = queues
include = voicemailgroups
include = directory
include = pagegroups
include = page_an_extension
root@OpenWrt:~#

root@OpenWrt:~# cat /etc/asterisk/dongle.conf
;!
;! Automatically generated configuration file
;! Filename: dongle.conf (/etc/asterisk/dongle.conf)
;! Generator: Manager
;! Creation Date: Sun May 29 18:55:27 2016
;!
[general]

interval = 15  ; Number of seconds between trying to connect to devices

;------------------------------ JITTER BUFFER CONFIGURATION --------------------------
;jbenable = yes                 ; Enables the use of a jitterbuffer on the receiving side of a
; Dongle channel. Defaults to "no". An enabled jitterbuffer will
; be used only if the sending side can create and the receiving
; side can not accept jitter. The Dongle channel can't accept jitter,
; thus an enabled jitterbuffer on the receive Dongle side will always
; be used if the sending side can create jitter.

;jbforce = no                   ; Forces the use of a jitterbuffer on the receive side of a Dongle
; channel. Defaults to "no".

;jbmaxsize = 200                ; Max length of the jitterbuffer in milliseconds.

;jbresyncthreshold = 1000       ; Jump in the frame timestamps over which the jitterbuffer is
; resynchronized. Useful to improve the quality of the voice, with
; big jumps in/broken timestamps, usually sent from exotic devices
; and programs. Defaults to 1000.

;jbimpl = fixed                 ; Jitterbuffer implementation, used on the receiving side of a Dongle
; channel. Two implementations are currently available - "fixed"
; (with size always equals to jbmaxsize) and "adaptive" (with
; variable size, actually the new jb of IAX2). Defaults to fixed.

;jbtargetextra = 40             ; This option only affects the jb when 'jbimpl = adaptive' is set.
; The option represents the number of milliseconds by which the new jitter buffer
; will pad its size. the default is 40, so without modification, the new
; jitter buffer will set its size to the jitter value plus 40 milliseconds.
; increasing this value may help if your network normally has low jitter,
; but occasionally has spikes.

;jblog = no                     ; Enables jitterbuffer frame logging. Defaults to "no".
;-----------------------------------------------------------------------------------

[dongle0]
audio = /dev/ttyUSB0
data = /dev/ttyUSB1
context = gsm_incoming
group = 1
rxgain = 3
txgain = 0
autodeletesms = yes
resetdongle = no
u2diag = -1
usecallingpres = yes
callingpres = allowed_passed_screen
disablesms = no
language = en
smsaspdu = yes
mindtmfgap = 45
mindtmfduration = 80
mindtmfinterval = 200
callwaiting = auto
disable = no
initstate = start
dtmf = relax
root@OpenWrt:~#


7 comments:

  1. I use chan dongle for Huwei e1550 (firmware 11.609.20.03.356). It has oneway audio problem (from Lan and without nat). I see rtp conversation both way. Have you time, I send some log and wireshark tcp capture for my sip conversation.

    ReplyDelete
    Replies
    1. My Blog: Asterisk With Usb Dongle As Gsm Gateway On Openwrt >>>>> Download Now

      >>>>> Download Full

      My Blog: Asterisk With Usb Dongle As Gsm Gateway On Openwrt >>>>> Download LINK

      >>>>> Download Now

      My Blog: Asterisk With Usb Dongle As Gsm Gateway On Openwrt >>>>> Download Full

      >>>>> Download LINK r9

      Delete
  2. You can use your mobile as sip gsm gateway using pure-voip.com software , the software is windows based :) , avoid linux headache :(

    for more information info@pure-voip.com
    http://pure-voip.com

    ReplyDelete
    Replies
    1. pure-voip solution is very very expensive its not worth to use because gray route has no good rates to sell now a days and even use mobile phones not possible to stop blocking sim cards . instead of pure voip software use chan mobile is more cheaper

      Delete
  3. Choosing a Single Band Router it's important to consider the size of your home and the number of devices you'll be connecting to the network. If you have a small home and only a few devices, a single band router should suffice. Get the best quality Single Band Router rom UBIQCOM at affordable price.

    ReplyDelete