自己写一个小程序我在java_;smslibv下运行成功
主要是以下几个类
Level_Final_Serialjava:串口底层操作
Serial_For_Smslibjava:对Level_Final_Serial的进一步封装可以直接发送和接受串口信息
如果要发送AT指令需要先转换成相应的Ascii码如: 发送AT指令A(acsii:)T(ascii:)回车(ascii:)
char[] atOrder = { }; smslib_testwriteByte(atOrder);
SmsTest修改版rar修改后:
String atCommand = AT\r; // 发送AT指令(加换行符号\r)
char[] atOrder = atCommandtoCharArray();
smslib_testwriteByte(atOrder);
// 读取数据
char[] rsByte = final_LevelreadPackData();
if (rsByte != null){
for (char c : rsByte) {
rsStr += c;
}
if (rsStrindexOf(OK)>){
Systemoutprintln(找到 + portStr + :短信模块串口);
rsbool = true;
}
}
SmsServicejava:smslib的封装
SmsSendJobjava:程序的运行实例(向发送查询余额能发能收)
程序不完善是有时候有异常出现查了质料后还是无法解决:
程序中有时候会出现异常:
警告: GTW: SMSLINK: Ignoring InterruptedException in Queuepeek()
javalangInterruptedException
at javalangObjectwait(Native Method)
at orgsmslibmodemAModemDriver$CharQueuepeek(AModemDriverjava:)
at orgsmslibmodemAModemDrivergetResponse(AModemDriverjava:)
at orgsmslibmodemAModemDrivergetResponse(AModemDriverjava:)
at orgsmslibmodemathandlerATHandlerisAlive(ATHandlerjava:)
at orgsmslibmodemAModemDriver$KeepAliveprocess(AModemDriverjava:)
at orgsmslibthreadingAServiceThreadrun(AServiceThreadjava:)
如果知道怎么做或者有更好的思路发送短信还请多多指教