Turn to a post for mobile phone Development (from the developer Club)

Source: Internet
Author: User

Introduction: This is a detailed page of a post for mobile phone Development (from the developer Club). It introduces PHP, related knowledge, skills, experience, and some PHP source code.

Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 326437 'rolling = 'no'>

Code:--------------------------------------------------------------------------------
At present, mobile phone Short Messages are widely used, and there are more and more sites that provide short message sending on the Internet. However, the services of some sites are not satisfactory, and the short messages are often sent. The most reliable sending method is of course the mobile phone in your hands. If you set the status report, you can be more accurate to know whether the recipient has received this message. Although mobile phone transmission is reliable, it also causes input troubles and low efficiency. This article introduces a method, as long as the mobile phone can be connected to the computer (using an infrared port or using a mobile phone data line to connect to a serial port, while the mobile phone supports the gsm at Instruction Set ), you can use the self-developed short message sending software to send short messages.
Most mobile phones on the market now support the gsm at Instruction Set controlled by modem. This instruction set was developed by Nokia, Ericsson, Motorola, HP, and other manufacturers for the GSM system, this includes the control of SMS (short message service.
Introduction to GSM at commands
The GSM at commands related to SMS are shown in table 1:

Table 1 related GSM at commands
There are three ways to control SMS:
Block mode;
Text mode based on AT command;
PDU mode based on the AT command.
Text mode is relatively simple. Multiple Nokia phones support this mode. Most Siemens mobile phones only support the PDU mode. The PDU mode is a method for sending or receiving SMS messages from mobile phones. The text of Short Messages is transmitted after hexadecimal encoding. Currently, PDU has replaced block mode. Therefore, this article mainly discusses the transmission of PDU mode.
Communication between computers and mobile phones
This document uses Siemens s3568i as an example to describe how to send short messages.
Data line connection
First, connect the mobile phone to the computer through the S35/25 data line. Then, open the Super Terminal and select a direct serial port connection. The port parameter is set to 19200 speed, no verification, data bit 8, and stop bit 1.
Infrared connection
If you are using a computer with an infrared port, you can set a wireless connection with your mobile phone. First, confirm that the infrared port of the computer is enabled, and enable the infrared and fax/data functions of the mobile phone to connect to the infrared port, an infrared device, Siemens S35, should appear on the computer system tray (not displayed if no Infrared Monitor is installed ). Then, open the Super Terminal and select the serial port on IRDA.
Connection test
Click the call button on the toolbar of the Super Terminal, enter at and press Enter. If OK appears on the screen, the connection between the computer and the mobile phone is successful. Then you can enter various GSM at commands.
For example, if you want to query the mobile phone manufacturers, enter at + cgmi = <CR> and display Siemens on the screen.
Generally, run the test command at + cmgs =? <CR>. If OK is returned, the mobile phone supports this command. The complete syntax format of this command is as follows:
If PDU mode (+ cmgf = 0) + cmgs = <length> <CR> PDU is given <Ctrl-z/esc>
If the message format command at + cmgf returns 0, the SMS format is PDU mode, and then the at + cmgs = <data length> command is executed, the phone returns the ">" symbol and waits for the input. Enter the PDU data and end with the ^ Z or ESC key.
If the message is sent successfully, OK is returned and the information number is displayed:
+ Cmgs: <Mr>
If sending fails, the following information is returned:
+ CMS error: <err>
Analysis of PDU Data Format
The following describes the data format of the sms pdu by analyzing the messages to be sent stored on the mobile phone. First, use your mobile phone to write a short message. The mobile phone number is 13605696031 and the message content is "Hello World !". You can read this information by executing at + cmgl = 2.
The procedure is as follows (the italic characters are the response information, and the {} is the comment ):
At
OK
At + cmgl = 2 {read unsent messages}
+ Cmgl: 1, 2, 24 {1 indicates the number of information, 2 indicates the number of unsent information, and 24 indicates the total information capacity}
08 91 683104501505f0 11 00 0b 81 3106621330f1 109a7 0b e8329bfd06dddf723619
OK
This information is analyzed as follows:
08: the length of the SMS center address.
91: The number type of the SMS center. 91 is ton/NPI. Ton/NPI complies with international/e.164 standards, which means to add the '+' number before the number. In addition, there are other numerical values, but 91 is the most commonly used.
683104501505f0: Short Message number, which is the service center address used. The actual number should be 8613805515500 (the letter F indicates the length minus 1) because the location is slightly processed. This is the number of the author's GSM Short Message Center.
11: Header byte (A bitmask ). Here 11 refers to sending short messages normally.
00: Information type.
0b: the length of the called number.
81: called number type.
3106621330f1: The called number, which is also transferred. The actual number is 13605696031.
2017a7: the short message encoding type GSM default alphabet. If it is Chinese, it is 000010.
0b: Short message length.
E8329bfd06dddf723619: the short message content is "Hello World !".
Short message encoding method and programming implementation
The following describes the information encoding methods for English and pure Chinese. Through the test, we found that the front part of each sent short message is the same, but the called Number and short message content have changed.
1. English Encoding
For more information, see table 2. Set the short message content to "Hello World !". The default GSM character set is 7-bit encoding, which can be simply interpreted as ASCII code (the ASCII value is smaller than 80 hex, so bit8 is ignored ), move the last few digits of the next 7-bit encoding to the front to form a new 8-bit encoding. See table 2 arrow instructions. Note that for the first row, if the shift count has reached 7 digits, add 0 to the front of the encoding. GSM does not support all ASCII characters.
Table 2 Implementation of English Encoding

The following is part of Delphi 5 code for English encoding:
// english format encoding. S is string.
function encode1 (var s: string): string;
var
I, j, Len: integer;
cur: integer;
T: string;
begin
result: = '';
Len: = length (s);
// J used for shift count
I: = 1; J: = 0;
while I <= Len DO
begin
If I // data conversion
cur: = (ord (s [I]) shr j) or (ord (s [I + 1]) SHL (7-j) and $ ff)
else
cur: = (ord (s [I]) SHR J) and $ 7f;
F Mtstr (T, '% 2.2x', [cur]);
result: = Result + T;
Inc (I );
// special handling of 7-bit shift count
J: = (J + 1) mod 7; if J = 0 then Inc (I );
end;
2. chinese encoding
see Table 3. Set the text message content to "Chinese text message ". Short Messages in Chinese are easy to implement ?????? To the Unicode code of the code page cp936.
Table 3 Implementation of Chinese encoding

Through the widestring type conversion in Delphi, You Can skillfully implement ?????? Unicode (note that the code page is associated with the operating system ). The following is part of the Delphi 5 code that implements Chinese encoding:
// Encoded in Chinese format, and S is a unicode string
Function encode2 (var s: widestring): string;
VaR
I, Len: integer;
Cur: integer;
T: string;
Begin
Result: = '';
Len: = length (s );
I: = 1;
While I <= Len do
Begin
Cur: = ord (s [I]);
// BCD Conversion
Fmtstr (T, '% 4.4x', [cur]);
Result: = Result + T;
INC (I );
End;
End;
Knot
The short message encoding in PDU format is described above. It is recommended that the length of the English information should not exceed 140 characters, and the Chinese information should not exceed 54 Chinese characters. If you use a mobile phone that supports text, it is easier to implement. For example, send "Hello World !", Use the following at command:
At + cgmf = 1 <CR> at + CGMS = "13605696031", 129 <CR>
> Hello world! <^ Z>

Love J2EE follow Java Michael Jackson video station JSON online tools

Http://biancheng.dnbcw.info/php/326437.html pageno: 13.

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.