Asterisk GSM-шлюз
Материал из Xgu.ru
GSM-шлюз на базе Asterisk — устройство на базе программной АТС Asterisk и аппаратных модулей, осуществляющих передачу звонка в GSM-сеть. Примером такого модуля может служить специализированная карта расширения от Digium или 3G-модем Huawei.
Ниже рассматривается как настроить Астериск для использования USB-модема Huawei E1550 (или модемов Huawei E169, K3520, K3715).
Содержание |
[править] Введение
(несколько слов об идее)
[править] Инсталляция и настройка
Поддержка модема осуществляется через канал datacard. Пока что код этого канала не включен в состав Asterisk и должен инсталлироваться отдельно. Инсталляция выполняется непосредственно из репозитория проекта.
[править] Инсталляция драйвера устройства
$ lsmod option 20658 0 usb_wwan 12950 1 option usbserial 27298 2 option,usb_wwan
Apr 24 11:43:54 linux0 usb_modeswitch: switching 12d1:1446 (HUAWEI Technology: HUAWEI Mobile) Apr 24 11:43:54 linux0 kernel: [86823.322530] usb 1-3: USB disconnect, device number 2 Apr 24 11:44:01 linux0 kernel: [86829.968038] usb 1-3: new high speed USB device number 3 using ehci_hcd Apr 24 11:44:01 linux0 kernel: [86830.111258] usb 1-3: New USB device found, idVendor=12d1, idProduct=1001 Apr 24 11:44:01 linux0 kernel: [86830.111262] usb 1-3: New USB device strings: Mfr=2, Product=1, SerialNumber=0 Apr 24 11:44:01 linux0 kernel: [86830.111264] usb 1-3: Product: HUAWEI Mobile Apr 24 11:44:01 linux0 kernel: [86830.111267] usb 1-3: Manufacturer: HUAWEI Technology Apr 24 11:44:01 linux0 kernel: [86830.117037] scsi11 : usb-storage 1-3:1.3 Apr 24 11:44:01 linux0 kernel: [86830.118033] scsi12 : usb-storage 1-3:1.4 Apr 24 11:44:01 linux0 kernel: [86830.159312] usbcore: registered new interface driver usbserial Apr 24 11:44:01 linux0 kernel: [86830.159326] USB Serial support registered for generic Apr 24 11:44:01 linux0 kernel: [86830.159552] usbcore: registered new interface driver usbserial_generic Apr 24 11:44:01 linux0 kernel: [86830.159554] usbserial: USB Serial Driver core Apr 24 11:44:01 linux0 kernel: [86830.168853] USB Serial support registered for GSM modem (1-port) Apr 24 11:44:01 linux0 kernel: [86830.169179] option 1-3:1.0: GSM modem (1-port) converter detected Apr 24 11:44:01 linux0 kernel: [86830.169323] usb 1-3: GSM modem (1-port) converter now attached to ttyUSB0 Apr 24 11:44:01 linux0 kernel: [86830.169334] option 1-3:1.1: GSM modem (1-port) converter detected Apr 24 11:44:01 linux0 kernel: [86830.169435] usb 1-3: GSM modem (1-port) converter now attached to ttyUSB1 Apr 24 11:44:01 linux0 kernel: [86830.169444] option 1-3:1.2: GSM modem (1-port) converter detected Apr 24 11:44:01 linux0 kernel: [86830.169538] usb 1-3: GSM modem (1-port) converter now attached to ttyUSB2 Apr 24 11:44:01 linux0 kernel: [86830.169784] usbcore: registered new interface driver option Apr 24 11:44:01 linux0 kernel: [86830.169786] option: v0.7.2:USB Driver for GSM modems
[править] Инсталляция модуля канала datacard
Для того чтобы собрать бинарный модуль канала, потребуются заголовочные файлы Asterisk. Если Asterisk установлен из бинарного пакета, необходимо добавить соответствующий пакет dev:
$ sudo apt-get install asterisk-dev
После этого можно приступить к установке модуля:
$ svn checkout http://chan-datacard.googlecode.com/svn/trunk/ chan-datacard-read-only $ cd chan-datacard-read-only $ ./configure $ sudo make install
Модуль канала установлен.
[править] Настройка канала datacard
После того как модуль канала установлен, его необходимо настроить.
Пример конфигурационного файла канала входит в дистрибутив исходного кода канала. Этот файл можно использовать как основу конфигурационного файла:
$ cp etc/datacard.conf /etc/asterisk/datacard.conf
Конфигурационный файл:
[general]
interval=15 ; Number of seconds between trying to connect to devices
;language=en ; Default language setting for all devices
; This may also be set for individual device
;------------------------------ 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".
;-----------------------------------------------------------------------------------
[E1550_t](!)
context=incoming-datacard ; context for incoming calls
rxgain=3 ; increase the incoming volume
txgain=-3 ; increase the outgoint volume
autodeletesms=yes ; auto delete incoming sms
resetdatacard=yes ; reset datacard during initialization
u2diag=0 ; set U2DIAG parameter (0 = disable everything except modem function)
[datacard0](E1550_t)
audio=/dev/ttyUSB1 ; tty for audio connection
data=/dev/ttyUSB2 ; tty for AT commands
group=1 ; calling group
[datacard1]
context=incoming-datacard ; context for incoming calls
;language=de ; Use German as default language
audio=/dev/ttyUSB4 ; tty port for audio connection
data=/dev/ttyUSB5 ; tty port for AT commands
group=2 ; calling group
rxgain=10 ; increase the incoming volume
txgain=10 ; increase the outgoint volume
autodeletesms=yes ; auto delete incoming sms
resetdatacard=yes ; reset datacard during initialization
u2diag=0 ; set U2DIAG parameter (0 = disable everything except modem function)
usecallingpres=yes ; use the caller ID presentation or not
callingpres=allowed_passed_screen ; set caller ID presentation
disablesms=yes ; chan_datacard has currently a bug with SMS reception. When a SMS gets in during a
; call chan_datacard might crash. Enable this option to disable sms reception.
; Default = no
[править] Настройка диалплана для использования канала datacard
[datacard-incoming]
exten => sms,1,Verbose(Incoming SMS from ${CALLERID(num)} ${SMS})
exten => sms,n,System(echo ‘${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)} – ${DATACARD} – ${CALLERID(num)}: ${SMS}’ >> /var/log/asterisk/sms.txt)
exten => sms,n,Hangup()
exten => ussd,1,Verbose(Incoming USSD: ${USSD})
exten => ussd,n,System(echo ‘${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)} – ${DATACARD}: ${USSD}’ >> /var/log/asterisk/ussd.txt)
exten => ussd,n,Hangup()
exten => s,1,Dial(SIP/2001@othersipserver)
exten => s,n,Hangup()
[othersipserver-incoming]
exten => _X.,1,Dial(Datacard/r1/${EXTEN})
exten => _X.,n,Hangup
Другие идентификаторы каналов, которые можно использовать в datacard:
exten => _X.,1,Dial(Datacard/g1/${EXTEN})
Звонок через конкретную карточку datacard0:
exten => _X.,1,Dial(Datacard/datacard0/${EXTEN})
Звонок через карточку указанного провайдера:
exten => _X.,1,Dial(Datacard/p:PROVIDER NAME/${EXTEN})
Звонок через карточку с данным IMEI:
exten => _X.,1,Dial(Datacard/i:123456789012345/${EXTEN})
Звонок через карточку с данным IMSI-префиксом:
exten => _X.,1,Dial(Datacard/s:250976764489/${EXTEN})
[править] Переменные Datacard
Переменные, которые можно использовать в диалплане.
- ${DATACARD}
- Текущая карта, через которую идёт звонок.
- ${IMSI}
- IMSI текущей карты.
- ${IMEI}
- IMEI текущей карты.
- ${PROVIDER}
- PROVIDER текущей карты.
- ${SMS}
- Входящее сообщение SMS.
- ${USSD}
- Исходящее сообщение USSD.