Recently, a department of the company has to integrate the text message sending and receiving function in the management system, and the task falls into my head. Although the text message platform is nothing new, it can also provide secondary development libraries for devices, but I have never touched on it before, so I am also very engaged in learning and research. At first it was very mysterious and exciting. I searched on the Internet and found that the function of sending and receiving text messages only was not complicated, that is, the
The command is sent to the SMS receiving and receiving device, and then the data returned from the serial port is read. After parsing the data, you can determine whether the command response or returned data is used.
The test tool is included here. If it is only used to test General at commands and there is no available serial port test tool at hand, the Super Terminal tool that comes with Windows is a good choice, however, the Super Terminal cannot decode the encoded short messages. Therefore, you can only see a bunch of garbled characters when reading the short messages. When it comes to short message encoding, various terminals now support the text and PDU modes. It is said that the text mode does not support Chinese characters, so it is ignored by me and the PDU mode is not complex to grasp, the first is to understand the message format after PDU encoding, and the second is to master the specific encoding and decoding rules.
PDU
The code is divided into 13 segments, from
A
To
M
There are 13 English letters. I have listed a table for simple descriptions of each section.
:
|
Serial number
|
PDU
Segment number
|
Description
|
|
1
|
A
|
The length of the SMS center address,
2
Hexadecimal number
(1
Bytes
)
|
|
2
|
B
|
SMS center number type,
2
Hexadecimal number. |
|
3
|
C
|
SMS center number,
B + C
The length
A
Depends on the data in. |
|
4
|
D
|
File Header bytes,
2
Hexadecimal number. |
|
5
|
E
|
Information type,
2
Hexadecimal number. |
|
6
|
F
|
Called Number length,
2
Hexadecimal number. |
|
7
|
G
|
Called Number type,
2
Hexadecimal number with the same value
B
. |
|
8
|
H
|
Called number. The length is determined
F
Depends on the data in. |
|
9
|
I
|
Protocol identifier,
2
Hexadecimal number. |
|
10
|
J
|
Data encoding scheme,
2
Hexadecimal number. |
|
11
|
K
|
Validity period,
2
Hexadecimal number. |
|
12
|
L
|
User Data Length,
2
Hexadecimal number. |
|
13
|
M
|
The length of user data is determined
L
Depends on the data in.
J
Set to use
Ucs2
Encoding, which is in Chinese and English
Unicode
Character. |
For more detailed information about PDU, you can go to non-dog blog (http://xinos.cn/downloads/sms/manual/index.shtml
) Download the sms pdu Manual
.
At commands related to text messages can also be found in non-dogs. Thank you.
Finally, the serial port operations, at command encapsulation, and PDU codec are stirred up and implemented,
The test is successful on common phone, sms modem, and mobile network card.
Now
I wanted to attach the source code of the implementation, but did not find the place to upload, if you are interested, you can send an e-mail to the dubing.lee@gmail.com to ask me...