Java uses smslib to send text messages

Source: Internet
Author: User

Java uses smslib to send text messages.

Write a small program, I in java1.6.0 _ 10; smslib-v3.4.5 run successfully. can download my resources.

Http://hi.csdn.net/link.php? Url = http://yangzl0123.download.csdn.net

 

, Mainly including the following classes.
Level_final_serial.java: underlying serial port operations
Serial_for_smslib.java: Further encapsulation of level_final_serial, which can directly send and accept serial port information.
If you want to send the AT command, you must first convert it to the corresponding ASCII Code. For example, if you want to send the AT command a (acⅱ: 65) T (ASCII: 84), press enter (ASCII: 13)
Char [] atorder = {65, 84, 13}; smslib_test.writebyte (atorder );

 

Sms-testmodify.rar. After modification:

String atcommand = "at/R"; // send the AT command (with a line break/R)
Char [] atorder = atcommand. tochararray ();

Smslib_test.writebyte (atorder );

 

// Read data
Char [] rsbyte = final_level.readpackdata ();
If (rsbyte! = NULL ){
For (char C: rsbyte ){
Rsstr + = C;
}
If (rsstr. indexof ("OK")> 0 ){
System. Out. println ("find" + portstr + ": SMS module serial port ");
Rsbool = true;
}

}
Smsservice. Java: smslib Encapsulation
Smssendjob. Java: The Running instance of the Program (send 11 to 10086, query the balance, and send and receive)

If the program is not complete, sometimes exceptions occur, and the problem cannot be solved after checking the materials:
Sometimes exceptions occur in the program:
 

Warning: gtw: smslink: Ignoring interruptedexception in queue. Peek ().
Java. Lang. interruptedexception
At java. Lang. Object. Wait (native method)
At org. smslib. Modem. amodemdriver $ charqueue. Peek (amodemdriver. Java: 556)
At org. smslib. Modem. amodemdriver. getresponse (amodemdriver. Java: 323)
At org. smslib. Modem. amodemdriver. getresponse (amodemdriver. Java: 352)
At org. smslib. Modem. athandler. athandler. isalive (athandler. Java: 123)
At org. smslib. Modem. amodemdriver $ keepalive. Process (amodemdriver. Java: 678)
At org. smslib. Threading. aservicethread. Run (aservicethread. Java: 117)

 

If you know how to do this, or have a better idea to send text messages, please kindly advise.

 

Reference: http://osum.sun.com/profiles/blogs/java-shi-yong-smslibtong-guo

 

 

**************************************** ******************************
Smslib version updated: http://smslib.org/
Smslib v3.4.6 released
After downloading, extract smslib-v3.4.6/Dist/lib/smslib-3.4.6.jar,
Replace the replacement smslib-3.4.5.jar in the project, and then make the appropriate changes...
Time:
**************************************** ******************************

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.