Asterisk chan_dongle
# Качаем
cd /usr/src
wget https://github.com/oleg-krv/asterisk-chan-dongle/archive/asterisk13.zip
# В пакете вложена инструкция по установке!
$ cd asterisk-chan-dongle-asterisk13
#
$ aclocal
$ autoconf
$ automake -a
#
$ ./configure
#
$ make
$ make install
....
cpvt.o dc_config.o pdu.o mixbuffer.o pdiscovery.o
strip chan_dongle.so
/usr/bin/install -c -m 755 chan_dongle.so /usr/lib/asterisk/modules
команды CLI
dongle show devices
dongle restart now
dongle sms MTS1 38050XXXXX test sms
# Очистить память СМС
# 1 память SIM
# 2 память модема
dongle cmd AT+CPMS=\"SM\",\"SM\",\"SM\"
dongle cmd AT+CMGD=1,4
/etc/asterisk/dongle.conf
[general]
interval=15 ; Частота проверки подключенных устройств
[defaults]
context=dongle-income ; Контекст для входящих звонков
usecallingpres=yes ; Определять номер звонящего
callwaiting=no ; Принимать второй звонок при активном разговоре
autodeletesms=yes ; Удаление SMS с сим-карты при перезапуске
rxgain=0 ; Изменение громкости динамика
txgain=0 ; Изменение громкости микрофона
[LIFE1]
context=dongle1-income
;audio=/dev/ttyUSB1
;data=/dev/ttyUSB1
imei=35939XXXXXXXXXX ; Привязка имени модема к IMEI номеру
imsi=25506XXXXXXXXXX ; Привязка по СИМ - можно не указывать
[MTS1]
context=mts1-income
imei=35480XXXXXXXXX
imsi=25500XXXXXXXXX
/etc/asterisk/extensions.conf
#
[dongle1-income]
exten => sms,1,Noop(Incoming SMS from ${CALLERID(num)} )
same => n,System(/etc/asterisk/scripts/sendsmsemail.sh "${CALLERID(num)}" "${DONGLENUMBER}" "${BASE64_DECODE(${SMS_BASE64})}")
same => n,Hangup()
exten => _+38X.,1,Noop(INCOMMING CALL BY DONGLE-1 FROM ${CALLERID(num)})
; Обрезаем ведущие +38 на номере звонящего
same => n,Set(CNUM=${CALLERID(num)})
same => n,ExecIf($["${CNUM:0:3}"="+38"]?Set(CALLERID(num)=${CNUM:3}))
;
; Обрезаем ведущие +38 на вызываемом номере
same => n,Set(ENUM=${EXTEN})
same => n,ExecIf($["${ENUM:0:3}"="+38"]?Set(ENUM=${ENUM:3}))
;
same => n,Set(CALLTYPE=in)
same => n,GotoIfTime(08:50-18:10|mon-fri|*|*?worktime:noworktime)
same => n(worktime),Noop()
same => n,Answer()
same => n,Playback(support_worktime)
same => n,Gosub(sub-mixmonitor,${ENUM},1)
same => n,Dial(SIP/operator1&SIP/operato2&SIP/operator3,300,t)
same => n,Goto(exit)
same => n(noworktime),Noop()
same => n,Goto(support-noworktime,${ENUM},1)
same => n(exit),HangUp()
/etc/udev/rules.d/92-dongle.rules
$ cat /etc/udev/rules.d/92-dongle.rules
KERNEL=="ttyUSB*", MODE="0666", OWNER="asterisk", GROUP="dialout"
До:
ls -la /dev/ttyUSB*
crw-rw---- 1 root dialout 188, 0 Nov 29 06:17 /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 1 Nov 29 06:17 /dev/ttyUSB1
crw-rw---- 1 root dialout 188, 2 Nov 29 06:17 /dev/ttyUSB2
После:
ls -la /dev/ttyUSB*
crw-rw-rw- 1 asterisk dialout 188, 0 Nov 29 15:30 /dev/ttyUSB0
crw-rw-rw- 1 asterisk dialout 188, 1 Nov 29 15:30 /dev/ttyUSB1
crw-rw-rw- 1 asterisk dialout 188, 2 Nov 29 15:30 /dev/ttyUSB2
Посмотрим какие устройства видны
#
$ lsusb
Bus 001 Device 005: ID 12d1:1001 Huawei Technologies Co., Ltd. E169/E620/E800 HSDPA Modem
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
$ lsusb -s 1:5 -v
# Работающий модем выглядит так:
Bus 001 Device 005: ID 12d1:1001 Huawei Technologies Co., Ltd. E169/E620/E800 HSDPA Modem
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x12d1 Huawei Technologies Co., Ltd.
idProduct 0x1001 E169/E620/E800 HSDPA Modem
bcdDevice 0.00
iManufacturer 3 HUAWEI Technology
iProduct 2 HUAWEI Mobile
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 85
bNumInterfaces 3
bConfigurationValue 1
iConfiguration 1 Qualcomm Configuration
bmAttributes 0xe0
Self Powered
Remote Wakeup
MaxPower 500mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 3
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 5
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 32
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 32
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 32
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 32
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 2
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 255 Vendor Specific Subclass
bInterfaceProtocol 255 Vendor Specific Protocol
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x84 EP 4 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 32
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x03 EP 3 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 32
Device Qualifier (for other device speed):
bLength 10
bDescriptorType 6
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
bNumConfigurations 1
Device Status: 0x0001
Self Powered
# Модем который не подключается, виден как Mass Storage SCSI
Bus 001 Device 004: ID 12d1:1446 Huawei Technologies Co., Ltd. E1552/E1800/E173 (HSPA modem)
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x12d1 Huawei Technologies Co., Ltd.
idProduct 0x1446 E1552/E1800/E173 (HSPA modem)
bcdDevice 0.00
iManufacturer 2 HUAWEI Technology
iProduct 1 HUAWEI Mobile
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 55
bNumInterfaces 2
bConfigurationValue 1
iConfiguration 3 Qualcomm Configuration
bmAttributes 0xe0
Self Powered
Remote Wakeup
MaxPower 500mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 8 Mass Storage
bInterfaceSubClass 6 SCSI
bInterfaceProtocol 80 Bulk-Only
etc/asterisk/scripts/sendsmsemail.sh
#!/bin/sh
# Отправка SMS на email
# $1 c какого номера
# $2 на какой номер
# $3 текст SMS
if [ $# != 3 ]
then
echo "Use: sendsmsemail.sh 0441234567 0501234567 "
exit 1
fi
CALLER=$1
CALLTONUM=$2
TEXT=$3
TOEMAIL="[email protected]"
LOGFILE="/var/log/asterisk/sendsmsemail.log"
EMAILCMD="/usr/sbin/sendmail -t"
FROMEMAIL="[email protected]"
SUBJECT="[PBX] SMS c ${CALLER} на ${CALLTONUM}"
#logging
echo [`date +"%Y-%m-%d %H:%M:%S"`] SMS TO: ${TOEMAIL} Subject: ${SUBJECT} >> ${LOGFILE}
#send email
${EMAILCMD} <
${TEXT}
--
(c) Astersik PBX
INLINE
exit 0
UPDATED 2017-04-03
Зафиксировано полное зависание 4 из 5 модемов. LSUSB показывало только 1. Так как физического доступа к устройству не было - выполнил перезапуск всего сервера. Модемы поднялись и заработали.