1.在淘宝花140元买了个通用的WAVECOM芯片短信网关,USB口的不要电源线,方便点。
2.淘宝店附送了USB转串口的安装程序PL-2303 Driver Installer.exe(通用的)和爱迪生短信通 5.4 版TxtSmsSetup.msi.msi(破解的)。
3.安装第2点的2个东东后,图形界面的爱迪生短信通就可以正常收发短信了,检测到用的com6端口。这个端口要记住,每次安装都可能不同,检测一下就知道了。速率就填9600。
4.我要的是java程序收发短信,不是用现成的 爱迪生短信通 去发广告短信,是所谓编程吧。AT命令去搞据说难于上青天,二次开发包 搜搜都是要钱的,好不容易看到了http://hi.baidu.com/%CB%CE%B9%E2%BB%D41/blog/item/e45d6b58d4ba4cdb9c8204a9.html
这篇文章。于是试用。
5.遇到N多问题。
(1)作者讲他的不支持USB口,让我绝望!
但是不死心,去http://smslib.org/doc/smslib/quickstart/看到了如下的话:
Serial modem gateway (class org.smslib.modem.SerialModemGateway): For modems which are connected via serial ports (or emulated serial ports, like USB etc). ,底层的二次开发包应该是支撑USB口的。实验结果是可以的。
(2)log4j包也要下载供smslib包调用。
http://logging.apache.org/log4j/1.2/download.html
(3)修改芯片名称和型号。端口号每个人的机器都可能不同,检测下。
SerialModemGateway gateway = new SerialModemGateway("modem.com6", "COM6", 9600, "wavecom", "17254");
(4)成功了。
run:
Example: Read messages from a serial gsm modem.
SMSLib: A Java API library for sending and receiving SMS via a GSM modem
or other supported gateways.
Web Site: http://smslib.org
This software is distributed under the terms of the Apache v2.0 License.
Version: 3.3.0-b2
Modem Information:
Manufacturer: WAVECOM MODEM
Model: MULTIBAND 900E 1800
Serial No: 012345678901234
SIM IMSI: ** MASKED **
Signal Level: 74%
Battery Level: 0%
Now Sleeping - Hit <enter> to terminate.
>>> New Inbound message detected from Gateway: modem.com6
===============================================================================
<< InboundMessage >>
-------------------------------------------------------------------------------
Gateway Id: modem.com6
Encoding: UCS2 (Unicode)
Date: Sun Mar 20 10:47:16 CST 2011
Text: 试用smslib成功了,非常高兴,希望我的文章能给摸索的人一点帮助!
PDU data: 0032723872385988598872314F6076848001516C516C5B895385957F5F97898153BB4E0D597D610F601D768476847684
Originator: 8613574110874
Memory Index: 1
Multi-part Memory Index:
Memory Location: SM
Source / Destination Ports: -1 / -1
===============================================================================
run:
Example: Send message from a serial gsm modem.
SMSLib: A Java API library for sending and receiving SMS via a GSM modem
or other supported gateways.
Web Site: http://smslib.org
This software is distributed under the terms of the Apache v2.0 License.
Version: 3.3.0-b2
Modem Information:
Manufacturer: WAVECOM MODEM
Model: MULTIBAND 900E 1800
Serial No: 012345678901234
SIM IMSI: ** MASKED **
Signal Level: 77%
Battery Level: 0%
===============================================================================
<< OutboundMessage >>
-------------------------------------------------------------------------------
Gateway Id: modem.com6
Encoding: UCS2 (Unicode)
Date: Sun Mar 20 11:26:34 CST 2011
SMSC Ref No: 15
Recipient: 13574110874
Dispatch Date: Sun Mar 20 11:26:39 CST 2011
Message Status: SENT
Validity Period (Hours): -1
Status Report: false
Source / Destination Ports: -1 / -1
Flash SMS: false
Text: 这个是用java发的中文短信!祝山寨事业蒸蒸日上
PDU data: 8FD94E2A662F7528006A00610076006153D176844E2D658777ED4FE10021795D5C715BE84E8B4E1A84B884B865E54E0A
===============================================================================
Now Sleeping - Hit <enter> to terminate.
(5)试用升级版的smslib-3.5.0.jar就报错,需要修改收发程序。以后再说了。
(6)最终目的是用java程序每隔1分钟扫描一次数据库的表,有新内容就发送短信,有接受的短信就写入库表。以后再说了。
6.附件说明:
1.把smslib-3.3.0b2.jar和comm.jar,放入工程lib中。
2.javax.comm.properties放到%JAVA_HOME%/jre/lib下,
3.win32com.dll放到%JAVA_HOME%/jre/bin下。
4.环境配置好了以后,把examples文件夹下的SendMessage.java和ReadMessages.java拷贝到你的开发工具下,就可以发短信了。
7.在前人的基础上改进比较省力,如果大家看后有改进的东西,希望告诉我也进步进步,谢谢!120251048@qq.com
8.端口和速率测试程序:CommTest
run:
Searching for devices...
Found port: COM6
Trying at 9600... Getting Info... Found: MULTIBAND 900E 1800
Trying at 14400... no device found (javax.comm.UnsupportedCommOperationException: Unsupported baud rate)
Trying at 19200... no device found
Trying at 28800... no device found (javax.comm.UnsupportedCommOperationException: Unsupported baud rate)
Trying at 33600... no device found (javax.comm.UnsupportedCommOperationException: Unsupported baud rate)
Trying at 38400... no device found
Trying at 56000... no device found (javax.comm.UnsupportedCommOperationException: Unsupported baud rate)
Trying at 57600... no device found
Trying at 115200... no device found
Test complete.
成功生成(总时间:44 秒)
9.log4j.properties 修改为控制台和log文件都输出:
log4j.properties需要放置在源程序的根目录下,折腾了很久啊。
log4j.logger.smslib=info, smsr, smsf
log4j.appender.smsr=org.apache.log4j.ConsoleAppender
log4j.appender.smsr.layout=org.apache.log4j.PatternLayout
log4j.appender.smsr.layout.ConversionPattern=%-6r %d [%t] %-5p %C %x - %m%n
log4j.appender.smsf=org.apache.log4j.FileAppender
log4j.appender.smsf.File=D:/jdev/DEV/DataTransfer/log4j.log
log4j.appender.smsf.Append=false
log4j.appender.smsf.layout=org.apache.log4j.PatternLayout
log4j.appender.smsf.layout.ConversionPattern=%-6r %d [%t] %-5p %C %x - %m%n
10.使用最新的smslib-3.5.0.jar,应该比smslib-3.3.0b2.jar强。
example里面有现成的,改改几个参数就行了。
分享到:
相关推荐
网络计算的大作业 根据联通的SGIP协议 写一个短信网关模拟程序,能够模拟短信的发送过程,有界面,用C#写的,类似于QQ。但功能较为简单,仅仅是实现了简单的通信,尚未实现注册,登录等功能。
使用C#开发的基于华为SMEIDll.dll库的SMGP 2.0、SMGP 3.0协议的短信上行、短信下行的网关程序。 该程序代码在中国电信CDMA... 另外,基于电信C网短信网关的短信收发使用C++、Java、C#开发的接口程序都已全部完成。
一个短小精干的网关程序,是学习网络服务器程序的好例子。
深讯信科短信网关SP端应用程序接口使用说明
利用网通的网关平台收发手机短信.rar 一个可以收发短信的程序
移动短信网关模拟器很好用,采用的CMPP2.0协议做的,自己用感觉不错推荐给大家。
系统介绍:本程序是一套极具通用性的中间件服务系统,该版本在界面上设计上简单易上手,无需注册即可免费使用,系统支持多个短信猫的并发进程,支持发送超长短信,短信收发效率高,短信设备离线可以自动重连。...
短信网关接入程序,通过socket接入消息,然后直接转发到ISMG;同时支持华为短信网关接入.zip
华为短信网关平台、中兴短信网关平台,根据两大主流平台提供的接入信息封装接口,里面包含有一下文件:SMGPLoginRespMessage.java,SMGPLoginMessage.java,SGIPConnection.java,CMPP30Connection.java,CMPP30...
简易短信网关示例 含代码 简易短信网关示例 简易短信网关示例 简易短信网关示例
CRM短信网关接口程序
短信网关范例 发送短信 窗体程序
短信网关协议(联通版本) 短信网关协议(电信版本) word+pdf+javacode
电信短信网关协议,电信短信网关协议初始化smgp类 Host:短信网关ip地址 Port:短信网关端口 LoginMode:登录模式,0:单发 1:单收 2:收发,如果有一个类已经启动为单收或者收发,另外一个类使用单收或者收发,只有...
短信网关相关资cmpp,smg
c#调用傲天api实现向联通短信网关发送短信,接收状态报告等功能,包内包括傲天api和vs2005下的c#源代码。
移动联通短信协议及短信网关协议