免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 8172 | 回复: 2
打印 上一主题 下一主题

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

论坛徽章:
0
跳转到指定楼层
1 [收藏(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
2 [报告]
发表于 2010-01-26 09:03 |只看该作者
太深奥了。。

论坛徽章:
0
3 [报告]
发表于 2010-12-16 09:37 |只看该作者
不好
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP