Author: dever (please indicate the source if you need to quote.) )
Foreword: This article only discusses constructs the message platform the thought, does not focus on the discussion certain technology, in the article mentions the technical detail if has the question, please read the related material to look for.
In the communication developed today, SMS has become an important means of communication, and e-mail, telephone and other traditional ways of communication, compared to the advantages of the text message has incomparable. More and more enterprises began to choose to use SMS Platform for corporate advocacy, industry applications, system integration and so on.
When you decide to build an enterprise's SMS platform, you are faced with the following options: First, through the Internet or a dedicated line to the mobile operator SMS Center or SMS gateway; second, through the Internet or private line access to the intermediary service operators of the message center (such as Sina, NetEase, such as SP service providers) Third, through the computer connection mobile phone to send a short message, four is through the multi-channel SMS Special equipment (GSM modem pool) Send short message. In general, the first method has the advantages of fast transmission, successful rate and high reliability. is preferred, followed by the fourth way. But obviously these two methods are not our ordinary people can contact, let alone DIY, so, today I want to introduce the method is the third, the use of mobile phone built-in Gsm-modem build SMS platform.
Let me start by introducing my development environment:
Hardware: Siemens M55 mobile phone, mobile data cable (USB interface, virtual COM port), BENQ Joybook5000 notebook.
software system: Windows XP operating system,. NET Framwork 1.1
Development tools: vs.net2003
If you are the first contact serial programming, then it is best to cram some basic knowledge: serial programming, commonly used at instructions.
The best choice of mobile phones Siemens, Nokia, Ericsson and other well-known brands of mobile phones. Data cable as far as possible to choose the original, to ensure its stability. Connect the data cable, installed mobile phone driver, remember to check your mobile phone connected to which port, a set to use.
(Figure 1: My mobile port is COM3)
OK, so far all the preparations have been completed, before the beginning of the formal, we also need to test, see if you can communicate with the computer, or the time to compile the program but found that can not communicate, afraid to cry is not out. The test tool I use is the "HyperTerminal" that Windows brings. Create a new connection, set port number and port parameters, and port parameters depending on your phone's parameters. Basically, you can choose the default parameters. After the connection succeeds, a window similar to the following figure appears:
(Figure 2: Super Terminal debugging window)
Try the AT command and return to OK to indicate that your phone and PC are ready to communicate. This tool is still useful, and most of the time you need to test the AT command here.
Everything is available, and the East Wind has it. We are now starting to build the path of the SMS platform, the first step is to do a short message to the small program out.
First tidy up the idea, want to send a short message, you need to send a message to the serial port, to send a message to be able and serial communication, the problem seems to be very clear, first find a can and serial communication of the class bag it. (Unfortunately, C # does not provide such a class directly, yesterday read a blog written to vb.net2005 in a special serial communication class, do not know if C # 2005 will also join such a class. There are a lot of such components on the Internet, but most of them do not have the source code and charge, which obviously violates the DIY spirit, no need to.
Finally found in the GotDotNet two serial operation class, the domestic source code and information is too little:(. By the way, thanks to these original authors, if not their hard work, we will have to toil. The two serial operation types found are Justinio and Serialstreamreader. Justinio is a simple and easy-to-use class that is pretty good. Serialstreamreader itself is a serial debugging tool, so it can basically replace Windows "HyperTerminal". As its inner core-serialstream classes directly inherit from the Stream class, which gives us the operation also brought considerable convenience, but I found in the test process, using remoting to invoke this class will cause the service process deadlock, how many regret. (These two packages are provided below)
With these two-class packages, means that we can write in the program with the serial port, but can communicate does not mean that you can send text messages, because all communications will have an agreement, and here's the communication protocol is below I want to introduce to you the three modes of sending and receiving short message. These three modes are block mode, text mode, and PDU mode respectively. Block mode: the need for mobile phone manufacturers to provide driver support, has been eliminated. Text mode: Simple and easy, do not need to encode, but only the ASCII code, and support this mode less mobile phones, more commonly seen in Nokia mobile phones. PDU: Supports this mode handset most, the compatibility is good, but needs to carry on the coding conversion.
Read the above introduction, there is no doubt that our choice is only PDU, online on the PDU code a lot of examples, I refer to the Silkworm Chrysalis wrote an article "C # Development of terminal text message principle and method", the article behind there is a writer to write the demo, I believe that will give the first contact serial programming friends to bring a lot of help (including me, thank pupa). The serial communication class used in his demo is Justinio.
Now it seems that there is no big problem, do our program, open vs.net, new projects, the need to use the class are guided in, you can start ~ ~
This is a demo I do, the appearance is a little bit, but as a test, the function is enough, about this demo source code in the next available.
So quickly made a can send a short message of the program to, is not a sense of accomplishment ~ ~ Hehe, first intoxicated for a while. We'll continue next time.
Code Download:
Serial Communication components: Justinio.rar Serialstream.rar