Ubuntu 24下安装Asterisk和chan-quectel小记

尝试把Asterisk+chan-quectel部署在了PVE的LXC里的Ubuntu24环境下,配合EC20实现了短信转发到Telegram

安装Asterisk和chan-quectel

apt install asterisk asterisk-dev adb git autoconf automake libsqlite3-dev build-essential libasound2-dev alsa-utils
git clone https://github.com/IchthysMaranatha/asterisk-chan-quectel
cd asterisk-chan-quectel
./bootstrap
./configure --with-astversion=20.6
./configure --with-astversion=20.6 DESTDIR=/usr/lib/x86_64-linux-gnu/asterisk/modules
make
make install

配置USB直通

#LXC配置文件
lxc.cgroup.devices.allow: c 188:* rwm
lxc.mount.entry: /dev/QWS.EC25.AT dev/QWS.EC25.AT none bind,optional,create=file
lxc.mount.entry: /dev/QWS.EC25.NMEA dev/QWS.EC25.NMEA none bind,optional,create=file
#/etc/udev/rules.d/99-qws-usb-serial.rules
SUBSYSTEMS=="usb", ENV{.LOCAL_ifNum}="$attr{bInterfaceNumber}"
SUBSYSTEMS=="usb", KERNEL=="ttyUSB[0-9]*", ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0125", ENV{.LOCAL_ifNum}=="01", SYMLINK+="QWS.EC25.NMEA", MODE="0777"
SUBSYSTEMS=="usb", KERNEL=="ttyUSB[0-9]*", ATTRS{idVendor}=="2c7c", ATTRS{idProduct}=="0125", ENV{.LOCAL_ifNum}=="02", SYMLINK+="QWS.EC25.AT", MODE="0777"

配置Asterisk

#/etc/asterisk/quectel.conf
[quectel0]
audio=/dev/QWS.EC25.NMEA ; tty port for Audio, set as ttyUSB4 for Simcom if no other dev present
data=/dev/QWS.EC25.AT ; tty port for AT commands; no default value
#/etc/asterisk/extensions.conf
[incoming-mobile]
exten => sms,1,Verbose(Incoming SMS from ${CALLERID(num)} ${BASE64_DECODE(${SMS_BASE64})})
;store
exten => sms,n,System(echo '${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)} - ${QUECTELNAME} - ${CALLERID(num)}: ${BASE64_DECODE(${SMS_BASE64})}' >> /var/log/asterisk/sms.txt)
exten => sms,n,System(curl -d 'chat_id={chatid}&text=${URIENCODE(${BASE64_DECODE(${SMS_BASE64})})}\nForm: ${CALLERID(num)}' 'https://api.telegram.org/bot{bottoken}/sendMessage')
exten => sms,n,Hangup()

exten => ussd,1,Verbose(Incoming USSD: ${BASE64_DECODE(${USSD_BASE64})})
exten => ussd,n,System(echo '${STRFTIME(${EPOCH},,%Y-%m-%d %H:%M:%S)} - ${QUECTELNAME}: ${BASE64_DECODE(${USSD_BASE64})}' >> /var/log/asterisk/ussd.txt)

exten => ussd,n,Hangup()

exten => _X.,1,System(curl -d 'chat_id={chatid}&text=${URIENCODE(Incoming Call:${CALLERID(num)} )}' 'https://api.telegram.org/bot{bottoken}/sendMessage')
exten => s,1,Verbose('${EXTEN} ${CHANNEL} ${CALLERID(num)} ${INVALID_EXTEN}')
exten => s,n,System(curl -d 'chat_id={chatid}&text=${URIENCODE(Incoming Call:${CALLERID(num)} )}' 'https://api.telegram.org/bot{bottoken}/sendMessage')
exten => s,n,Hangup()

Leave a Reply

Your email address will not be published. Required fields are marked *