- [from-pstn-custom]
- include => dongle-incoming-sms
- include => dongle-incoming-ussd
- [dongle-incoming-sms]
- exten => sms,1,Noop(Incoming SMS from ${CALLERID(num)} ${BASE64_DECODE(${SMS_BASE64})})
- exten => sms,2,System(echo '${BASE64_DECODE(${SMS_BASE64})}' >> /var/log/asterisk/smscontent${DONGLENAME})
- exten => sms,3,System(echo '${STRFTIME(${EPOCH},Hongkong,%Y-%m-%d %H:%M:%S)} - ${DONGLENAME} - ${CALLERID(num)} - ${CALLERID(dnid)}: ${BASE64_DECODE(${SMS_BASE64})} ///// ${CMGR}' >> /var/log/asterisk/sms${DONGLENAME}.txt)
- exten => sms,4,System(echo "INSERT INTO sms (DONGLENAME,CALLERID,EPOCH,SMS_BASE64,DONGLENUMBER,CMGR) values ('${DONGLENAME}','${CALLERID(num)}','${STRFTIME(${EPOCH},Hongkong,%Y-%m-%d %H:%M:%S)}','${BASE64_DECODE(${SMS_BASE64})}','${DONGLENUMBER}','${CMGR}')\;" > /var/log/asterisk/smssql${DONGLENAME}.txt)
- exten => sms,5,System(mysql -uuser -ppassword -h192.168.0.1 -P3307 smslog < /var/log/asterisk/smssql${DONGLENAME}.txt)
- exten => sms,6,Set(channelID=${CHANNEL:-10:8})
- exten => sms,7,System(echo '${CMGR}' > /var/log/asterisk/smsCMGRraw${DONGLENAME}_${channelID})
- exten => sms,8,System(awk '{if ( NR == "2" ) print}' /var/log/asterisk/smsCMGRraw${DONGLENAME}_${channelID} | tee -a /var/log/asterisk/smsPDUraw${DONGLENAME}_${channelID})
- exten => sms,9,NoOp(cmdstr = /usr/bin/python /etc/asterisk/pdudecode.py $(cat /var/log/asterisk/smsPDUraw${DONGLENAME}_${channelID})))
- exten => sms,10,Set(completeSMS=${SHELL(/usr/bin/python /etc/asterisk/pdudecode.py $(cat /var/log/asterisk/smsPDUraw${DONGLENAME}_${channelID}))})
- exten => sms,n,NoOp(result is ${completeSMS})
- exten => sms,n,Set(completeSMS=${completeSMS:0:1})
- ;exten => sms,9,Set(completeSMS=${SYSTEMSTATUS})
- ;exten => sms,n,System(echo ${completeSMS})
- exten => sms,n,System(rm -f /var/log/asterisk/smsPDUraw${DONGLENAME}_${channelID})
- exten => sms,n,System(rm -f /var/log/asterisk/smsCMGRraw${DONGLENAME}_${channelID})
- exten => sms,n,ExecIf($[ ${completeSMS}!=1 ]?wait(10))
- exten => sms,n,ExecIf($[ ${completeSMS}!=1 ]?System(echo 'Subject: SMS received from ${CALLERID(num)}' > /var/log/asterisk/smsmail${DONGLENAME})
- exten => sms,n,ExecIf($[ ${completeSMS}!=1 ]?System(echo ' ' >> /var/log/asterisk/smsmail${DONGLENAME})
- exten => sms,n,ExecIf($[ ${completeSMS}!=1 ]?System(echo '${STRFTIME(${EPOCH},Hongkong,%Y-%m-%d %H:%M:%S)} - ${DONGLENAME}' >> /var/log/asterisk/smsmail${DONGLENAME})
- exten => sms,n,ExecIf($[ ${completeSMS}!=1 ]?System(echo ' ' >> /var/log/asterisk/smsmail${DONGLENAME})
- exten => sms,n,ExecIf($[ ${completeSMS}!=1 ]?System(cat '/var/log/asterisk/smscontent${DONGLENAME}' >> /var/log/asterisk/smsmail${DONGLENAME})
- exten => sms,n,ExecIf($[ ${completeSMS}!=1 ]?System(cat '/var/log/asterisk/smsmail${DONGLENAME}' | tr -d '\r' | mailx -s 'SMS Recevied from ${CALLERID(num)} by ${DONGLENUMBER} ' -r 'xxxxx@myemail.com' -S smtp='192.168.0.1' xxxxx@gmail.com)
- exten => sms,n,ExecIf($[ ${completeSMS}!=1 ]?System(rm -f /var/log/asterisk/smscontent${DONGLENAME})
- exten => sms,n,ExecIf($[ ${completeSMS}!=1 ]?System(echo 'I am DONE' >> /var/log/asterisk/test${DONGLENAME})
- exten => sms,n,ExecIf($[ ${completeSMS}!=1 ]?System(echo '${STRFTIME(${EPOCH},Hongkong,%Y-%m-%d %H:%M:%S)} - ${DONGLENAME} - ${completeSMS}' >> /var/log/asterisk/test${DONGLENAME})
- exten => sms,n,System(asterisk -rx 'dongle cmd ${DONGLENAME} AT+CMGD=1,4')
- exten => sms,n,Hangup()
複製代碼 |