SMS send and receive

xiaoxiao2021-03-06  44

Principle

SMS code

In terms of sending and receiving text messages, three modes have been generated in time: block mode, TEXT MODE, based on the AT command, PDU MODEM based on the AT instruction, is relatively simple, and a plurality of Nokia phones support this mode. Most of the Siemens mobile phone only supports the PDU mode. The PDU mode is a method of transmitting or receiving mobile SMS information, and the short message body is transmitted after hexadecimal encoding. Currently, the PDU has replaced Block Mode because we mainly explore the transmission of PDU mode. Take Siemens 3508 mobile phone as an example.

SMS is a specification established by ETSI (GSM 03.40 and GSM 03.38). When using 7-bits encoding, it can send up to 160 characters; but use 8-bit encoding, you can send up to 140 characters, usually not directly displayed directly; also use 16-bit encoding, up to 70 characters, Used to display Unicode (UCS2) text information, can be displayed by most mobile phones. What we discussed today is UCS2 encoding, that is, only 70 characters can be sent, regardless of English or Chinese.

For example, we must send the following information now, send "Hello, Hello!" To my mobile phone 13715342642. Before you send it, you have to be clear, the SMS center number of the mobile SIM card is not the SMS center number you are in the place, like I am in Shenzhen, Shenzhen SMS Channel No.: 8613800755000, even if I go to the field now, SMS The center number is still Shenzhen. From above we got the following information:

Received mobile number: 13715342642

SMS Center: 8613800755000

SMS content: Hello, Hello!

In actual use, the above information does not execute the mobile phone, to perform the encoding mobile phone will be executed, no matter what information after the encoding:

0891683108705500F011000D91683117352446F2000800124F60597DFF0C00480065006C006C006F0021

I don't understand, let me explain:

08 - refers to the length of the SMS center number, that is, the length of (91) (683108705500F0)

91 - Refers to the short message center number type. 91 is Ton / NPI complies with the International / E.164 standard, refers to the number of ' ' before the number; there are other values, but 91 is most common.

683108705500F0 - Short message center number. The actual number should be: 8613800731500 (letter F means length 1). This requires corresponding modifications according to different geographies. The front (08) (91) (683108705500 F0) actually constitutes a portion of the entire SMS, which is generally called the short message of the SMSC.

11 - Document Header

00 - Type of Information (TP-Message-Reference)

0D - called number length

91 - Called Number Type

In fact, in actual processing, we usually write 11000d91 in the program, because in China, these data will not change.

683117352446f2 - The called number, after displacement processing, the actual number is "8613715342642". The upper (00) (0D) (91) (683173524446f2) constitutes a second part of the entire SMS (TP-Destination-Address). 00 - Agreement identifies TP-PID, here is usually 00

08 - Data encoding scheme TP-DCS (TP-DATA-CODING-Scheme), using the previous USC2 (16bit) data encoding

00 - Validity TP-VP (TP-VALID-Period)

12- Length TP-UDL (TP-User-Data-Length), that is, the length of the 4F60597DFF0C00480065006C006C 36/2 = 18

4F60597DFF0C00480065006C006C 006F0021- Here is the content of SMS, actual content is: "Hello, Hello!" Program implementation, please refer to the pdudecoding.cs of the source program of this article.