GSM Cards FAQ
Q1, How to Send/Receive Sms by OpenVox G400P
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 through:
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. <pre> [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 <[email protected]> # 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.
Attention: I only test the sms content in English, i do not know if it also works using other languages.
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/asterisk-perl-0.09/lib/Asterisk/AGI.pm
http://www.osnow.org/images/4/41/How_to_Write_a_Perl_AGI_Application.pdf