Chan Dongle

Asterisk channel driver

chan_dongle это канал Asterisk-а для USB модемов Huawei UMTS/3G USB. На данный момент поддерживаются функции:

Список поддерживаемых модемов

  • Голосовые вызовы, вызов по имени модема, группы, по кругу, по имени провайдеа, IMEI или IMSI.
  • Ожидание вызова
  • Удержание вызова
  • Конференуия
  • Отправка СМС из CLIasterisk manager и dialplan
  • Прием СМС
  • Отправка USSD
  • Прием USSD 
  • Отправка DTMF
  • Прием DTMF

Установка и настройка chan_dongle 

Для работы модемы должны быть разлочены

Prerequisites

Be careful with iptables and selinux. If needed, edit  /etc/selinux/config  and write:

                  SELINUX=disabled
SELINUXTYPE=targeted
                

Then, disable iptables

iptables -F
iptables-save > /etc/iptables.up.rules

or configure it to allow SIP (port 5060) and RTP (port 10000-20000) if you plan to use these protocols.

Now upgrade your system

apt-get update
apt-get upgrade

And install packages needed for compilation of asterisk

apt-get install linux-headers-`uname -r` gcc g++ make libnewt-dev libncurses5-dev openssl libssl-dev zlib1g-dev

Asterisk Installation

Download source files and untar. Asterisk 1.6 is explained, but 1.8 looks similar.

wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-1.6.2.13.tar.gz
tar zxvf asterisk-1.6.2.13.tar.gz

If you will use FreePBX, then install asterisk-addons

wget http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-addons-1.6.2.2.tar.gz
tar zxvf asterisk-addons-1.6.2.2.tar.gz

Now compile

cd asterisk-1.6.2.13
make clean && ./configure --disable-xmldocs && make && make install && make config

If needed

make samples

Install chan_dongle

Obtain source code

If you installed asterisk as described  here , go ahead. Anyway, check some dependencies like  automake  and  autoconf . Also must have asterisk sources and development tools like  make gcc  and so on.

SVN Method

svn checkout http://asterisk-chan-dongle.googlecode.com/svn/trunk/ dongle-read-only
cd dongle-read-only
aclocal && autoconf && automake -a

Compressed package

Go to  http://code.google.com/p/asterisk-chan-dongle/downloads/list  and download .tgz package, then

tar -zxvf chan_donle_%VERSION.r%REVISION.tgz
cd chan_donle_%VERSION.r%REVISION

Set Build options

./configure

configure options:

  • --enable-debug
  • --disable-debug
  • --enable-manager
  • --disable-manager
  • --enable-apps
  • --disable-apps
  • --with-asterisk=/path_to_source/asterisk.h

usefull environment variables

  • DESTDIR
  • CFLAGS
  • LDFLAGS

Examples

  • DESTDIR=“/usr/lib/asterisk/modules” ./configure
  • ./configure –with-asterisk=/usr/src/asterisk-1.6.2.13/include
  • CFLAGS=“-I /usr/src/asterisk-1.6.2.13/include” ./configure
  • ./configure --enable-debug
  • ./configure --disable-apps --disable-manager
  • CFLAGS=“-O0 -g” ./configure
  • CFLAGS=“-Os” ./configure

default is

  • ./configure --disable-debug --enable-apps --enable-manager
  • DESTDIR searching in /usr/lib/asterisk/modules /usr/local/lib/asterisk/modules /opt/local/lib/asterisk/modules

and

  • asterisk.h searching in ../include /usr/include /usr/local/include /opt/local/include

Building

For compile and build source to module

make

Installation

For install property configured and build module:

sudo make install

Module Configuration

Once installed, copy example file  dongle-read-only/etc/dongle.conf  to  /path_to_asterisk_config/  (i.e.  /etc/asterisk/ ). Configure it as desired and start asterisk. To load, stop or restart chan_dongle:

CLI>module load chan_dongle.so
CLI>module unload chan_dongle.so
CLI>module reload chan_dongle.so

chan_dongle configuration

All the information needed by chan_dongle is stored in /path_to_asterisk_config/dongle.conf.

dongle.conf

[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".
;-----------------------------------------------------------------------------------

[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=default                 ; context for incoming calls, SMS and USSD
group=0                         ; calling group
rxgain=0                        ; increase the incoming volume; may be negative
txgain=0                        ; increase the outgoint volume; may be negative
autodeletesms=yes               ; auto delete incoming sms
resetdongle=yes                 ; reset dongle 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=yes                    ; if 'yes' send SMS in PDU mode.
language=en                     ; 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=auto                ; 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=+1234567890               ; exten for start incoming calls, only in case of Subscriber Number not available!,
				; also set to CALLERID(dnid)

dtmf=relax			; 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




; dongle required settings
[dongle0]
audio=/dev/ttyUSB1              ; tty port for audio connection;        
data=/dev/ttyUSB2               ; tty port for AT commands; 

	; 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

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.            

Dialplan examples

extensions.conf

; this is chunks of Asterisk extensions.conf file for show some chan_dongle features
[general]

[dongle-incoming]
; example of ussd receive
exten => ussd,1,Set(type=${USSD_TYPE})
        ; values from 0 till 5
        ;  0 - USSD Notify
        ;  1 - USSD Request
        ;  2 - USSD Terminated by network
        ;  3 - Other local client has responded
        ;  4 - Operation not supported
        ;  5 - Network time out

exten => ussd,n,Set(typestr=${USSD_TYPE_STR})
        ; type in string, see above

exten => ussd,n,Set(ussd=${USSD})
        ; USSD text, but may be truncated by first \n

exten => ussd,n,Set(ussd_multiline=${BASE64_DECODE(${USSD_BASE64})})
        ; USSD text, may be multiline
; Note:  this exten run in Local channel not attached to anything, also all CALLERID() is empty


; example of sms receive
exten => sms,1,Set(sms=${SMS})
        ; SMS text, but may be truncated by first \n

exten => sms,1,Set(sms_multiline=${BASE64_DECODE(${SMS_BASE64})})
        ; SMS text, may be multiline

; Note:  this exten run in Local channel not attached to anything, also CALLERID(num) is address of SMS originator


; example of begining context execution from not default exten
exten => +12345678901,1,Verbose(This exten executed if Subscriber Number is available and equal +12345678901 or exten setting value is +12345678901)


; example of channel variables setting by chan_dongle
exten => s,1,Set(NAME_OF_DEVICE=${DONGLENAME})
    ; for example 'dongle0' or 'dongle1' see dongle.conf

exten => s,n,Set(NAME_OF_PROVIDE=${DONGLEPROVIDER})
    ; for example see output of cli 'dongle show devices' column "Provider Name"

exten => s,n,Set(IMEI_OF_DEVICE=${DONGLEIMEI})
    ; for example see output of cli 'dongle show devices' column "IMEI"

exten => s,n,Set(IMSI_OF_SIMCARD=${DONGLEIMSI})
    ; for example see output of cli 'dongle show devices' column "IMSI"

exten => s,n,Set(CNUM_NUMBER=${DONGLENUMBER})
    ; Subscriber Number example see output of cli 'dongle show devices' column "Number"
    ;   may be empty, use for save in SIM commands AT+CPBS="ON" and  AT+CPBW=1,"+123456789",145

exten => s,n,Set(CNUM_NUMBER=${CALLERID(dnid)})
    ; Set to Subscriber Number if available


; applications of chan_DONGLE

exten => s,n,DongleStatus(dongle0,DONGLE0_STATUS)
    ; get status of device and store result in variable
    ; possible values of ${DONGLE0_STATUS}
    ;   -1 invalid argument
    ;    1 device not found
    ;    2 device connected
    ;    3 device connected and in use

exten => s,n,DongleSendSMS(dongle0, "+18004005422", Hello how are you, Danila?, 1440, yes)
    ; send SMS on selected device and to specified number
    ;   device                  name of Dongle device
    ;   destination number      in International format with leading '+' or w/o leading '+'
    ;   message                 maximum 70 UCS-2 symbols
    ;   validity period         in minutes, will be round up to nearest possible value, optional default is 3 days
    ;   report request          if true report for this SMS is required, optional default is not


; functions of chan_dongle

exten => s,n,GotoIf($["${CHANNEL(callstate)}" == "waiting"]?waiting-call)
    ; now we provide channel function argument callstate
    ;   possible values
    ;           active          ; enjoy and speek
    ;           held            ; this call is held
    ;           dialing         ; for outgoing calls
    ;           alerting        ; for outgoing calls, number dialed and called party ringing
    ;           incoming        ; for incoming calls
    ;           waiting         ; for incoming waiting calls;
    ;                              if callwaiting=no channels for waiting calls never created

    ;           initialize      ; never appear
    ;           released        ; never appear

    ; Answer on waiting call activate this call and place any other active calls
    ;   on hold, but execution of dialplan for these calls not break stopped or frozen
    ;   When active call terminated one of held becomes active.

exten => s,n,Set(CHANNEL(callstate)=active)
    ; if callstate is 'held' you can assign new value 'active'
    ;   its mean activate this call and place on hold all other active calls but
    ;   execution of dialplan for these calls not break stopped or frozen


exten => s,n,Dial(Dongle/g1/holdother:+79139131234)
exten => s,n,Dial(Dongle/r1/holdother:+79139131234)
exten => s,n,Dial(Dongle/p:PROVIDER NAME/holdother:+79139131234)
exten => s,n,Dial(Dongle/i:123456789012345/holdother:+79139131234)
exten => s,n,Dial(Dongle/s:25099/holdother:+79139131234)
    ; now we add option 'holdother' for dialing
    ;    this option do
    ;           1) When looking for available devices by group, provider IMEI,
    ;                   IMSI prefix not ignore devices with whose state does not
    ;                   prohibit a new outgoing call when other call place on hold
    ;
    ;           2) Before actual dialing place active calls on hold
    ;                  but execution of dialplan for these calls not break stopped or frozen
    ;           3) This call will be active if succesfully answered
; BUG !!!
;  tested for call waiting and hold features Huawei E1550 has a next bug:
;    When local side hangup any call including held call ALL other calls LOST sound
;    When remove side hangup active call ALL other calls LOST sound
; Please double check true this for you or not
;  If true reduce usage of this useful features

exten => s,n,Dial(Dongle/g1/conference:+79139131234)
exten => s,n,Dial(Dongle/r1/conference:+79139131234)
exten => s,n,Dial(Dongle/p:PROVIDER NAME/conference:+79139131234)
exten => s,n,Dial(Dongle/i:123456789012345/conference:+79139131234)
exten => s,n,Dial(Dongle/s:25099/conference:+79139131234)
    ; and also option 'conference' added
    ;    this option do
    ;           1) When looking for available devices by group, provider IMEI,
    ;                   IMSI prefix not ignore devices with whose state does not
    ;                   prohibit a new outgoing call when other call place on hold
    ;
    ;           2) Before actual dialing place active calls on hold
    ;                  but execution of dialplan for these calls not break stopped or frozen
    ;           3) If answered attach hold calls to conrefence (in term of GSM)
    ; Also if created outgoing channel place call on same device that incoming channel
    ;  both incoming and outgoing channels become readonly to avoid the voice loop.
    ;
    ; see also BUG !!! note above

Не надо так делать :) 

Odoo text and image block

Более 1 000 000 компаний в мире используют Asterisk.

Присоединяйтесь к нам и сделайте вашу компанию лучше.