Use smslib to send SMS messages

Source: Internet
Author: User

SMS (Short Messaging Service) is a short message service. It is a standard developed by ETSI (GSM 03.40 and gsm03.38 ). When 7-bits encoding is used, a maximum of 160 characters can be sent. When 8-bit encoding is used, a maximum of 140 characters can be sent, which is usually not displayed on the mobile phone; it can contain up to 70 characters in 16-bit encoding and is used to display Unicode (ucs2) text information, which can be displayed on most mobile phones.

CurrentlyProgramThere are roughly three ways to send text messages:
1. Apply for a gateway from the local telecommunications department and use the API calling program provided by the other party to send text messages without additional equipment. This is suitable for large communication companies.
2. Use settings such as GSM Modem (mobile phones that support at commands can also send text messages) and connect to a computer through data lines. This method is suitable for small companies and individuals. To implement this method, you must understand serial communication, at command, SMS encoding, and decoding.
3. Using the website, the website sends text message data on behalf of the website, which is highly dependent on the website and has high network requirements, and is not suitable for project development.
 
This article explains how to use the AT command.

The so-called at, that is, attention. The at command set is sent from terminal equipment or data terminal equipment to terminal adapter or data circuit terminating equipment, send AT commands by TA and te to control the interaction between mobile station functions and GSM network services. We can use the AT command to control the call SMS, phone book, data service, supplementary service, and fax. Because at commands are very simple, we can completely write components to complete relevant operations, and to address different service requirements such as China Unicom, China Mobile, and PHS, self-made components are easier to control and expand.

In Java programming, Java comm can be used for serial communication between mobile phones and computers, and mobile phone operations can be controlled through AT commands. There is a smslib project on Google code, which is a component (http://code.google.com/p/smslib/downloads/list) that implements mobile operations with AT commands ).
An example of smslib is as follows:

  Public class test {<br/> Public static void main (string [] ARGs) {<br/> service SRV = new service (); <br/> outboundmessage MSG = new outboundmessage ("Account", "content"); <br/> // com serial port name, for example, for COM1 or/dev/ttys1 <br/> // port 1234 speed, Wavecom is 9600 <br/> serialmodemgateway gateway = new serialmodemgateway ("smsatcommandsubscriptionimpl", "com ", <br/> 1234, null, null, srv. getlogger (); <br/> gateway. setinbound (true); <br/> gateway. setoutbound (true); <br/> gateway. setsimpin ("0000"); <br/> gateway. setoutboundnotification (New ioutboundmessagenotification () {<br/> Public void process (string, outboundmessage) {</P> <p >}< br/> }); <br/> srv. addgateway (GATEWAY); <br/> try {<br/> srv. sendmessage (MSG); <br/> srv. stopservice (); <br/>}catch (exception e) {<br/> E. printstacktrace (); <br/>}</P> <p >}< br/>} 

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.