自己寫一個小程序我在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:)
如果知道怎麼做或者有更好的思路發送短信還請多多指教
From:http://tw.wingwit.com/Article/program/Java/hx/201311/26133.html