?? sms.java
字號:
showText(SMSTools.getSMSText(pdu)+ "\n"); pdu = "0791947101670000040485080039004010412121854024D737DB7C0EBBCF2E69D8BD6603C865D739DD22975DE3771B747DB3CDE7B0FB0C"; showText(SMSTools.getSMSText(pdu)+ "\n"); } // if else if (cmd.equals("read SMS")) { showText("read and decode all SMS from SIM\n\n"); try { Port.open(); if (Msg.test() == false) { showText("ERROR: Can't connect to mobile phone\n"); } // if } // try catch (Exception e) {showText("Error: Exception in read SIM: " + e);} try { n = Msg.getNoOfSMS(); showText("No. of stored SMS in SIM: " + Integer.toString(n) + "\n"); index = Msg.getIndexOfSMS(); // get a index list of stored SMS n = -1; do { n++; if (index[n] != 0) { // found a guilty index for a SMS i = index[n]; s = Msg.getSMS(i); s = SMSTools.getSMSText(s); showText("SMS No. " + index[n] + ": " + s + "\n"); } // if } while (index[n] != 0); Port.close(); } // try catch (Exception e) { showText("Exception in Main: " + e); } // catch } // else if else if (cmd.equals("read ME Info")) { showText("Get some information about the connected mobile phone\n\n"); try { Port.open(); showText("Battery Status: " + Msg.getBatteryStatus() + "\n"); // get battery status from ME showText("Signal Quality: " + Msg.getSignalQuality() + "\n"); // get signal quality from ME Port.close(); } // try catch (Exception e) { showText("Error: Exception in read ME Info: " + e); } // catch } // else if else if (cmd.equals("send SMS")) { showText("send some SMS and eMails\n\n"); try { Port.open(); Msg.sendSMS(EMAILDIALNO, TOA_NATIONAL, EMAILADR + "Testmail, PC send time: " + getFormatedDateTime()); Msg.sendSMS(SMSDIALNO, TOA_INTERNATIONAL, "Test-SMS, PC send time: " + getFormatedDateTime()); Msg.sendSMS(EMAILDIALNO, TOA_NATIONAL, EMAILADR + " Testmail"); Port.close(); } // try catch (Exception e) { showText("Exception in Main: " + e); } // catch } // else if else if (cmd.equals("invest Runtime")) { showText("Investigate run time of a SMS within the GSM network\n\n"); try { Port.open(); showText("Delete all SMS from SIM\n"); Msg.deleteAllSMS(); sendtime = getLongTime(); sendtext = "Testmail for run time, PC send time: " + getFormatedDateTime(); receivetext =""; loopbreak = false; Msg.sendSMS (SMSDIALNO, TOA_NATIONAL, sendtext); // send a SMS to the sending mobile phone do { Thread.sleep(500); // wait 500 msec receivetime = getLongTime(); deltatime = (receivetime - sendtime)/1000; // deltatime is in seconds index = Msg.getIndexOfSMS(); // get a index list of stored SMS n = -1; do { n++; if (index[n] != 0) { // found a guilty index for a SMS receivetext = SMSTools.getSMSText(Msg.getSMS(index[n])); i = receivetext.indexOf(SMSTEXTSIGN); receivetext = receivetext.substring(i+1, receivetext.length()); if (sendtext.compareTo(receivetext) == 0) { loopbreak = true; // received the same SMS as sended break; } // if } // if } while (index[n] != 0); if (deltatime >= TIMEOUT) loopbreak = true; } while (loopbreak == false); if (deltatime >= TIMEOUT) showText("timeout of " + TIMEOUT + " s reached\n"); else showText("actual run time of a SMS = " + deltatime + " s\n"); Port.close(); } // try catch (Exception e) { showText("Exception in Main: " + e); } // catch } // else if else if (cmd.equals("AT Cmd.")) { showText("send some AT commands and display the received raw data\n\n"); try { Port.open(); showText("Mobile Phone Modell: " + Port.sendAT ("AT+CGMM")); // get Modellinformation from ME showText("Connection Status: " + Port.sendAT ("AT+CREG?")); // get connection status to GSM net from ME Port.close(); } // try catch (Exception e) { showText("Error: Exception in AT Cmd.: " + e); } // catch } // else if else if (cmd.equals("Parse")) { showText("parse received SMS, parsing is switched automatically off in " + TIMEOUT/1000 + " s\n\n"); loopbreak = false; starttime = getLongTime(); try { Port.open(); Msg.deleteAllSMS(); do { showText("Delete all SMS from SIM\n"); index = Msg.getIndexOfSMS(); // get a index list of stored SMS n = -1; do { n++; if (index[n] != 0) { // found a guilty index for a SMS receivetext = SMSTools.getSMSText(Msg.getSMS(index[n])); i = receivetext.indexOf(" "); originateno = receivetext.substring(0, i); i = receivetext.indexOf(SMSTEXTSIGN); receivetext = receivetext.substring(i+1, receivetext.length()); showText("received SMS from: " + originateno + ", content: " + receivetext + "\n"); if (receivetext.indexOf(".on") == 0) { showText("found command in SMS: .on\n"); } // if else if (receivetext.indexOf(".off") == 0) { showText("found command in SMS: .off\n"); } // else if else if (receivetext.indexOf("get time") == 0) { showText("found command in SMS: get time\n"); showText("send local time to the sender\n"); Msg.sendSMS(SMSDIALNO, TOA_INTERNATIONAL, "PC send time: " + getFormatedDateTime()); } // else if else if (receivetext.indexOf("exit") == 0) { showText("found command in SMS: exit\n"); loopbreak = true; } // else if else { // unknown command showText("no command found in SMS\n"); showText("send help information to the sender\n"); Msg.sendSMS(SMSDIALNO, TOA_INTERNATIONAL, "possible commands: .on, .off, get time, exit"); } // else } // if } while (index[n] != 0); Msg.deleteAllSMS(); Thread.sleep(1000); // wait 1 sec showText("time: " + getFormatedDateTime() + "\n\n"); deltatime = getLongTime() - starttime; // deltatime is in milliseconds if (deltatime >= TIMEOUT) loopbreak = true; } while (loopbreak == false); if (deltatime >= TIMEOUT) showText("timeout of " + TIMEOUT/1000 + " s reached"); Port.close(); } // try catch (Exception e) { showText("Error: Exception in parsing SMS: " + e); } // catch } // else if else if (cmd.equals("create PDUs")) { showText("creates PDUs for sending PDUs from a simple microcontroller to the mobile phone\n\n"); String dialno4SMS, dialno4Email, emailadr, message = new String(); dialno4SMS = "01751082323"; // dialing number for SMS transmission, this is the number of the phone you want to send the SMS dialno4Email = "8000"; // dialing number for eMail transmission, this is the number you have to dial if you want to convert a SMS into a e-Mail emailadr = "wolfgang.rankl@de.gi-de.de"; // eMail adress message = "et's geht's des glump"; // message to the receiver, maximal length is 160 characters SMS.showText("Dialing Number for SMS: " + dialno4SMS + "\n"); SMS.showText("Dialing Number for EMail: " + dialno4Email + "\n"); SMS.showText("Email Adress: " + emailadr + "\n"); SMS.showText("Message: " + message + "\n"); SMSTools smstools = new SMSTools(); byte[] pdu_byte = SMSTools.getPDUPart(dialno4SMS, TOA_INTERNATIONAL, message); // build PDU for SMS char[] pdu_char = SMSTools.toHexString(pdu_byte); pdu = SMSTools.convertCharArray2String(pdu_char); SMS.showText("PDU for SMS: " + pdu + "\n"); pdu_byte = SMSTools.getPDUPart(dialno4Email, TOA_NATIONAL, message); // build PDU for eMail pdu_char = SMSTools.toHexString(pdu_byte); pdu = SMSTools.convertCharArray2String(pdu_char); SMS.showText("PDU for EMail: " + pdu + "\n"); } // else if else if (cmd.equals("Exit")) { showText("\tExit Button pressed\n"); showText("Stop Program GUI\n"); System.exit(0); } // else if showText("-------------------------------------------\n"); } // actionPerformed /** main * @param args there will be no arguments for the main */ public static void main(String [] args){ //--- build the GUI SMS sms = new SMS(); sms.setLocation(0, 0); sms.pack(); sms.setTitle("SMS Transceiver"); sms.setVisible(true); showText("Start Program SMS Transceiver\n\n"); } // main} // class
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -