opkg update
opkg install kmod-usb-serial kmod-usb-serial-wwan kmod-usb-serial-option usb-modeswitch smstools3 curl iconv
vi /usr/local/bin/pushsms
#!/bin/sh
chat_id=xxxxxxxx
token=xxxxxxxx
if [ "$1" == "RECEIVED" ]; then
from=`grep "From:" $2 | awk -F ': ' '{printf $2}'`
#sent=`grep "Sent:" $2 | awk -F ': ' '{printf $2}'`
#received=`grep "Received:" $2 | awk -F ': ' '{printf $2}'`
alphabet=`grep "Alphabet:" $2 | awk -F ': ' '{printf $2}'`
if [ "$alphabet" = "UCS2" ]; then
content=$(sed -e '1,/^$/ d' < "$2" | iconv -f UNICODEBIG -t UTF-8)
else
content=$(sed -e '1,/^$/ d' < "$2")
fi
text=$(cat <<EOF
$content
From $from
EOF
)
curl -d "chat_id=$chat_id&text=$text" -X POST https://api.telegram.org/bot"$token"/sendMessage
fi
vi /etc/smsd.conf
#
# Description: Main configuration file for the smsd
#
devices = GSM1
incoming = /var/spool/sms/incoming
outgoing = /var/spool/sms/outgoing
checked = /var/spool/sms/checked
failed = /var/spool/sms/failed
sent = /var/spool/sms/sent
receive_before_send = no
autosplit = 3
loglevel = notice
#delaytime = 0
eventhandler = /usr/local/bin/pushsms
[GSM1]
init = AT+CPMS="ME","ME","ME"
device = /dev/ttyUSB1
incoming = yes
#pin = 0000
baudrate = 9600
signal_quality_ber_ignore = yes
detect_unexpected_input = no
memory_start = 0
/etc/init.d/smstools3 restart
哥门 https://zijung.me/archives/lede-receive-sms-and-forward-to-telegram.html这里的
發件人: ${from}
發件時間: ${sent}
收件時間: ${received}
如果这几行存在 收不到消息 ,,有啥办法保留这几个 发出消息的不