免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 7863 | 回复: 2

如何用OpenVox G400P(GSM) 收发短信 [复制链接]

论坛徽章:
0
发表于 2009-12-09 19:12 |显示全部楼层
hello:
OpenVox G400P can be implemented to send or receive sms.  I will introduce few possible ways to get the features work.
1) To receive the sms, there is a patch to get sms and store that in text format under asterisk logs,
customers can use script to parse that and save to somewhere. please refer this link:
http://bbs.openvox.cn/viewthread.php?tid=981&extra=page%3D1
2) To send sms, there are few things users have to consider:
2.1) the generation of content of sms, users have to store sms in a file.
2.2) the ways to send sms, from GUI or by dialplan.
here, i use dialplan to send sms. before starting the configurations,  users have to go though:
1) perl and asterisk::AGI are installed.  users have to download the asteriskAGI module.
asterisk-perl-1.01.tar.gz , unzip that and follow the readme.text to install that.
2) Make sure G400P is working, edit the dialplan in this way:
=============extensions.conf===============
;
[globals]
CONSOLE=Console/dsp                             ; Console interface for demo
;CONSOLE=Zap/1
;CONSOLE=Phone/phone0
IAXINFO=guest                                   ; IAXtel username/password
;IAXINFO=myuser:mypass
TRUNK=Zap/G2                                    ; Trunk interface
sms_test="Test OpenVox G400P by james.zhu" ; default sms, users also can read the file using asterisk cmd and pass the value to the variable.
;
[from-gsm]
exten =>s,1,Answer()
exten =>s,n,Dial(sip/500)
[from-internal]
exten =>1000,1,Dial(zap/1/10000)
exten =>1000,2,Hangup()
exten =>200,1,Dial(zap/3/10000)
exten =>200,2,Hangup()
exten =>300,1,Dial(zap/5/10000)
exten =>300,2,Hangup()
exten =>400,1,Dial(zap/7/10000)
exten =>400,2,Hangup()
exten => _135.,1,AGI(gsm_sms.agi|${EXTEN}|${sms_test})
exten => _135.,n,hangup
========================
in this dialplan,  if users dial 13570XXXXXX, the agi will be executed and pass to values(${EXTEN}|${sms_test} to gsm_sms.agi. the gsm_sms.agi file must be stored into
/var/lib/asterisk/agi-bin, and make sure it is executable with asterisk permission.
this is the sample file called: gsm_sms.agi:
========gsm_sms.agi=================
#!/usr/bin/perl
#
# Simple AGI Application to show how to send sms by using OpenVox G400P
#
# Written by: James.zhu <james.zhu@openvox.cn>
# Date:12/10/2009
# include Asteisk AGI, install it first
use Asterisk::AGI;
$AGI = new Asterisk::AGI;
# default channel, use it send sms
my $channel = 3;
# the handphone number user dialed
$number = $ARGV[0];
# the sms user wants to send
$context = $ARGV[1];
# the command line to send sms by asterisk
# asterisk -rx 'gsm  send sms 3 1357080XXXX  "hello, this is openvox gsm card"'
#print "asterisk -rx 'gsm  send sms' $channel $number  $context";
# Perl system call
system("asterisk -rx 'gsm send sms $channel $number $context'");
==============================
please take a note there, i am testing with span 3, please modify that for your needs.
========asterisk log======================================
- Executing [13570807877@from-internal:1] AGI("SIP/500-0a2af738", "gsm_sms.agi|13570807XXX|"Test OpenVox G400P by james.zhu"") in new stack
    -- Launched AGI Script /var/lib/asterisk/agi-bin/gsm_sms.agi
AGI Tx >> agi_request: gsm_sms.agi
AGI Tx >> agi_channel: SIP/500-0a2af738
AGI Tx >> agi_language: en
AGI Tx >> agi_type: SIP
AGI Tx >> agi_uniqueid: asterisk-1260351409.30
AGI Tx >> agi_callerid: 500
AGI Tx >> agi_calleridname: 500
AGI Tx >> agi_callingpres: 0
AGI Tx >> agi_callingani2: 0
AGI Tx >> agi_callington: 0
AGI Tx >> agi_callingtns: 0
AGI Tx >> agi_dnid: 1357080XXX
AGI Tx >> agi_rdnis: unknown
AGI Tx >> agi_context: from-internal
AGI Tx >> agi_extension: 13570807XXX
AGI Tx >> agi_priority: 1
AGI Tx >> agi_enhanced: 0.0
AGI Tx >> agi_accountcode:
AGI Tx >>
AGI Rx << gsm send sms 3 135708078XXX "Test OpenVox G400P by james.zhu"
AGI Tx >> 510 Invalid or unknown command
    -- Remote UNIX connection
    -- Remote UNIX connection disconnected
AGI Rx << gsm send sms 3 135708078XX "Test OpenVox G400P by james.zhu"
AGI Tx >> 510 Invalid or unknown command
    -- AGI Script gsm_sms.agi completed, returning 0
    -- Executing [13570807XX@from-internal:2] Hangup("SIP/500-0a2af738", "") in new stack
  == Spawn extension (from-internal, 13570807XX, 2) exited non-zero on 'SIP/500-0a2af738'
GSM 3: SMS sent successfully on span 2.
==========================================
other possible solutions to send sms using G400P:
1) use asterisk cli system command: asterisk -rx 'gsm  send sms 3 1357080XXXX  "hello, this is openvox gsm card"'
2)  save the command above into the bash file, run the system command to launch the sms.
3)  send sms from GUI(PHP, i do not test that),  users can login the GUI and fill in a form, which contains message and the phone numbers users want to send to, after submitting, the php file will transfer the context to a bash file.  the system will be executed and send that through asterisk -rx command.

here, i give users an example of using dialplan to send SMS with few static variables. i believe it should be very possible to send sms from GUI, system commands or other solutions.  

References:
http://www.voip-info.org/wiki/view/Asterisk+AGI
http://search.cpan.org/~jamesgol ... lib/Asterisk/AGI.pm
http://www.osnow.org/images/4/41 ... AGI_Application.pdf

regards!
James.zhu

[ 本帖最后由 zhulizhong 于 2009-12-9 19:16 编辑 ]

backup_gsm_sms.zip

510 Bytes, 下载次数: 117

论坛徽章:
0
发表于 2010-01-26 09:03 |显示全部楼层
太深奥了。。

论坛徽章:
0
发表于 2010-12-16 09:37 |显示全部楼层
不好
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

DTCC2020中国数据库技术大会 限时9.5折

【架构革新 高效可控】2020年8月17日~19日第十一届中国数据库技术大会将在北京隆重召开。

大会设置2大主会场,20+技术专场,将邀请超百位行业专家,重点围绕数据架构、AI与大数据、传统企业数据库实践和国产开源数据库等内容展开分享和探讨,为广大数据领域从业人士提供一场年度盛会和交流平台。

http://dtcc.it168.com


大会官网>>
  

北京盛拓优讯信息技术有限公司. 版权所有 16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122
中国互联网协会会员  联系我们:huangweiwei@it168.com
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP