如何用OpenVox G400P(GSM) 收发短信

发布于 2022-08-21 07:30:55 字数 7337 浏览 10 评论 2

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 编辑 ]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

薄荷梦 2022-08-31 19:05:26

不好

潜移默化 2022-08-30 11:29:24

太深奥了。。

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文