本帖最後由 ckleea 於 2011-4-1 03:41 編輯
Create datacard.conf in /etc/asterisk- [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
- ; Datacard 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 Datacard channel can't accept jitter,
- ; thus an enabled jitterbuffer on the receive Datacard 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 Datacard
- ; 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 Datacard
- ; 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".
- ;-----------------------------------------------------------------------------------
- [defaults]
- ; now you can set here any not required device settings as template
- ; sure you can overwrite in any [device] section this default values
- context=datacard-incoming ; context for incoming calls, SMS and USSD
- group=0 ; calling group
- rxgain=3 ; increase the incoming volume; may be negative
- txgain=-3 ; increase the outgoint volume; may be negative
- autodeletesms=yes ; auto delete incoming sms
- resetdatacard=yes ; reset datacard during initialization with ATZ command
- u2diag=-1 ; set ^U2DIAG parameter on device (0 = disable everything except modem function)
- ; -1 not use ^U2DIAG command
- usecallingpres=yes ; use the caller ID presentation or not
- callingpres=allowed_passed_screen ; set caller ID presentation. By default use default network settings
- ; see http://www.the-asterisk-book.com/unstable/applikationen-setcallerpres.html
- disablesms=no ; disable of SMS reading from device when received. Enable this option to disable
- ; sms reception. Use smsaspdu=yes to avoid problem when SMS is too long in TEXT mode.
- smsaspdu=1 ; if 'yes' send SMS in PDU mode.
- language=UTF-8 ; set channel default language
- mindtmfgap=45 ; minimal interval from end of previews DTMF from begining of next in ms
- mindtmfduration=80 ; minimal DTMF tone duration in ms
- mindtmfinterval=200 ; minimal interval between ends of DTMF of same digits in ms
- callwaiting=yes ; if 'yes' allow incoming calls waiting; by default use network settings
- ; if 'no' waiting calls just ignored
- disable=no ; if 'yes' no load this device and just ignore this section
- ;exten=+85267896789 ; exten for start incoming calls, only in case of Subscriber Number not available!,
- ; also set to CALLERID(dnid)
- dtmf=inband ; control of incoming DTMF detection, possible values:
- ; off - off DTMF tone detection, voice data passed to asterisk unaltered
- ; use this value for gateways or if you do not use IVR in diaplan
- ; inband - do DTMF tones detection
- ; relax - like inband but with relaxdtmf option
- ; default is 'relax' for backward compatibility
- ; datacard required settings
- [datacard0]
- ;audio=/dev/hw-audio-0
- ;data=/dev/hw-data-0
- audio=/dev/ttyUSB1 ; tty port for audio connection;
- data=/dev/ttyUSB2 ; tty port for AT commands;
- exten=+85267896789
- ; or you can omit both audio and data parameters and use imei=123456789012345 and/or imsi=612849384756451
- ; imei and imsi must contain exactly 15 digits !
- ; imei/imsi discovery is available on Linux only
- ; K3715
- imei=123456789012345
- imsi=612849384756451
- ; if you set audio and data parameter together with imei and/or imsi, audio and data is used.
- ; you can use both imei and imsi together. In this case exact match by imei and imsi is required.
- ;
- ;[datacard1]
- ;audio=/dev/ttyUSB4 ; tty port for audio connection;
- ;data=/dev/ttyUSB5 ; tty port for AT commands;
-
- ; K3715
- ;imei=
- ;imsi=
- ;[datacard2]
- ;audio=/dev/ttyUSB7 ; tty port for audio connection;
- ;data=/dev/ttyUSB8 ; tty port for AT commands;
- ; E169G
- ;imei=
- ;imsi=
複製代碼 create the datacard_extensions.conf- [datacard-incoming]
- include => datacard-incoming-sms
- include => datacard-incoming-ussd
- exten => +85267896789,1,Answer()
- exten => +85267896789,n,GotoIf($[${CALLERID(num)} = 91234567]?Kwong-call)
- exten => +85267896789,n,Playback(number-not-answering)
- exten => +85267896789,n,Playback(vm-goodbye)
- exten => +85267896789,n,Hangup()
- exten => +85267896789,n(Kwong-call),GoTO(default,1001,1)
- exten => +85267896789,n,Hangup()
- [datacard-incoming-sms]
- exten => sms,1,Noop(Incoming SMS from ${CALLERID(num)} ${BASE64_DECODE(${SMS_BASE64})})
- exten => sms,n,Set(GLOBAL(isms)=/var/log/asterisk/sms/incoming/sms-${STRFTIME(${EPOCH},Hongkong,%G%m%d-%H%M%S)}.txt)
- exten => sms,n,System(echo '${STRFTIME(${EPOCH},Hongkong,%Y-%m-%d %H:%M:%S)} - ${DATACARD} - ${CALLERID(num)}: ${BASE64_DECODE(${SMS_BASE64})}' > ${isms})
- exten => sms,n,System(smtp-cli --from recipientemail --to senderemail --subject "You got a new SMS " --attach ${isms} --host=smtphost --user=username --pass=password)
- exten => sms,n,Hangup()
- [datacard-incoming-ussd]
- exten => ussd,1,Noop(Incoming USSD: ${BASE64_DECODE(${USSD_BASE64})})
- exten => ussd,n,Set(GLOBAL(iussd)=/var/log/asterisk/sms/incoming/ussd-${STRFTIME(${EPOCH},Hongkong,%C%y%m%d%H%M)}.txt)
- exten => ussd,n,System(echo '${STRFTIME(${EPOCH},Hongkong,%Y-%m-%d %H:%M:%S)} - ${DATACARD} - ${CALLERID(num)}: ${BASE64_DECODE(${SMS_BASE64})}' > ${iussd})
- exten => ussd,n,System(smtp-cli --from recipientemail --to senderemail --subject "You got a new SMS " --attach ${iussd} --host=smtphost --user=username --pass=password)
- exten => ussd,n,Hangup()
複製代碼 add this
#include "datacard_extensions.conf"
to [globals] of extensions.conf
add a dialplan for outgoing call in extensions.conf e.g.- ;dial-out via 3G Modem
- [CallingRule_3GModem]
- exten => _82.,1,Dial(Datacard/datacard0/${EXTEN:2})
- exten => _82.,n,Hangup()
- ;exten => _82.,1,Macro(superdial,Datacard/g0/852${EXTEN:2})
- ;exten => _82.,2,Macro(superdial,SIP/pstn-spa3k-d1/${EXTEN:2})
複製代碼 |