从终端设备向蜂窝电话发送短消息文本是十分简单的。以下的代码片段就演示了这个过程。所使用的电话是nokia 7100系列,并且me (mobile equipment)是连接在计算的#1号通信端口上。
注意到ctrl-z是用来表示终结发送到移动设备的文本输入。
使用visual basic来发送sms文本到nokia电话:
' set up the communications port mscomm1.commport = 1 ' com port 1 ' set for 9600 baud, no parity, 8 data, and 1 stop bit. mscomm1.settings = "9600,n,8,1" ' tell the control to read entire buffer when input is used mscomm1.inputlen = 0 ' open the port mscomm1.portopen = true ' send an 'at' command to the phone mscomm1.output = "at" & chr$(13) & chr(10) ' the phone will respond with an 'ok' ' set up the phone for a text message mscomm1.output = "at+cmgf=1" & chr$(13) & chr(10) ' the phone will respond with an 'ok' ' prep for sms, give destination type and destination address. ' enter the destination type and destination address to prep for sms ' e.g. at+cmgs="+2145551212",129 mscomm1.output = "at+cmgs= " & chr(34) & "+2145551212" & chr(34) & ",129" & chr$(13) & chr(10) ' the phone will return a'>' prompt, and await entry of the sms message text. ' now send the text to the phone and terminate with (ctrl-z) mscomm1.output = "this is a test. wow! " ' the phone will respond with a conformation containing the 'message reference number' eg. +cmgs:' close the port mscomm1.portopen = false
在终端,看起来就象下面:
at ok at+cmgf=1 ok at+cmgs="+15127752607",129 >this is a test. wow! +cmgs: 49 ok
想了解更多的有关发送sms文本信息的内容,请参考gsm 07.05白皮书在etsi web site。想了解更多nokia关于sms的信息,请去http://www.forum.nokia.com,并登陆到smart messaging forum。
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器