SMS sending/receiving module

Source: Internet
Author: User

The next task is to encapsulate the SMS sending/receiving module. I thought it was very simple, that is, serial communication and AT commands. There are still many gaps with expectation in a few days, in addition to portability considerations, it seems that the timetable will be extended...

Below is the GSM at command related to SMS, which is posted here for your convenience.
1. Related GSM at commands
The GSM at commands (from gsm07.05) related to SMS are shown in table 1:
Table 1 related GSM at commands

At command
Merit

At + cmgc
Send an SMS command (send a short message command)

At + cmgd
Delete SMS message (Short Message for deleting SIM card memory)

At + cmgf
Select SMS message formate (select the Short Message format: 0-pdu; 1-text)

At + cmgl
List SMS message from preferred store (list the short message PDU/Text: 0/"rec unread"-unread, 1/"rec read"-read, 2/"Sto unsent"-to be sent, 3/"Sto sent"-sent, 4/"all"-All)

At + cmgr
Read SMS message)

At + cmgs
Send SMS message)

At + cmgw
Write SMS message to memory (write a short message to the sim memory)

At + CMSS
Send SMS message from storage (send short messages from sin | M memory)

At + cnmi
New SMS message indications (displays new short messages)

At + CPMS
Preferred SMS message storage (select Short Message Memory)

At + csca
SMS service center address (Short Message Center address)

At + CSCB
Select Cell Broadcast messages (select cellular broadcast message)

At + CSMP
Set SMS text mode parameters (Set Short Message text mode parameters)

At + CSMs
Select Message Service (select short message service)

There are three modes to control short messages:
Block Mode

PDU Mode Based on at command

Text mode based on AT command

To use the block mode, the mobile phone manufacturer must provide driver support. Currently, the PDU mode has replaced the block mode, and the text mode is relatively simple. This article focuses on the Mode PDU mode, taking the Siemens product tc35t as an example.
2. Communication between the computer and tc35t
(1) RS232 serial port connection
Since tc35t comes with RS232 serial cable, you only need to connect it to the computer serial port. Open the Super Terminal, select the corresponding serial port, set the port parameters to: Speed-4800, parity bit-None, data bit-8, stop bit-1, traffic control-hardware.
(2) connection test
Enter "at" and press Enter. "OK" is returned on the screen, indicating that the computer and tc35t have been connected successfully, and tc35t can work properly. Then you can test various AT commands.
When the test command "at + cmgs = ?" If "OK" is returned, it indicates tc35t supports this command. The complete Syntax of this command is as follows:
If tc35t is in PDU mode (that is, "At + cmgf ?" Return "0 ")

At + cmgs = PDU is given <^ Z/esc>
If the short message is sent successfully, "OK" is returned and the message number is displayed:
+ Cmgs: [,]
If the short message fails to be sent, the following message number is returned:
+ CMS error:
If tc35t is in text mode (that is, "At + cmgf ?" Return "1 ")

At + cmgs = [, toda] text is entered <^ Z/esc>
If the short message is sent successfully, "OK" is returned and the message number is displayed:
+ Cmgs: [,]
If the short message fails to be sent, the following message number is returned:
+ CMS error:
In addition, because tc35t is used, when a new short message arrives, tc35t is required to generate a prompt and use the command "at + cnmi ". The complete Syntax of this command is as follows:
At + cnmi = [] [,] [,] [,] [,]
If a new short message arrives, the tc35t will automatically return the following prompt:
+ Cmti: "SM ",
At this time, read the short message content using the "at + cmgr" command.
3. Analysis of PDU data format:
For example, we want to send the character "hi" to the destination "13677328099"
PDU string:
08 91 683104701305f0 11 00 0d 91 3176378290f9 00 00 00 02 c834
(1) 08-length of the SMS center address. The length of (91) + (683104701305f0.
(2) 91-message center number type. 91 indicates that ton/NPI complies with the international/e.164 standard and requires the plus sign (+) before the number. In addition, there are other values, but 91 is the most commonly used.
91-10010001
Bit No.
7
6
5
4
3
2
1
0

Name
1
Value Type
Number Identification

Type of number: 000-unknown, 001-International, 010-domestic, 111-reserved for extension;
Numbering Plan identification: 0000-unknown, 0001-isdn/telephone number (e.164/e.163), 1111-reserved for extension;
(3) 683104701305f0-SMS center number. The actual number should be 8613800731500 (the letter F indicates the length minus 1) because the location is slightly processed ). This needs to be modified based on different regions.
(1), (2), and (3) are collectively referred to as the address of the SMSC ).
(4) 11-File Header bytes.
11 & H = 00010001 & B
Bit No.
7
6
5
4
3
2
1
0

Name
TP-RP
TP-UDHI
TP-SPR
TP-VFP
TP-RD
TP-MTI

Value
0
0
0
1
0
0
0
1

Response path-TP-RP (TP-reply-path): 0-not set; 1-Set
User Data header ID-TP-UDHL (TP-user-data-header-indicator): 0-No header information; 1-header information
Status report requirements-TP-SPR (TP-status-report-Request): 0-report required; 1-report not required
Validity Period format-TP-VPF (TP-validity-period-format): 00-not supplied (not present); 10-INTEGER (standard); 01-reserved; 11-provide half of the 8-bit bytes (semi-octet represented)
Reject replication-TP-RD (TP-reject-duplicates): 0-accept replication; 1-reject Replication
Message Type tip-TP-MTI (TP-message-type-indicator): 00-read (deliver); 01-submit (submit)
1000000-Message Type (TP-message-Reference)
Limit 0b-the length of the called number.
91-callednumber type (same as (2 ).
20173176378290f9-called number. After displacement processing, the actual number is "13677328099 ".
The destination address (TP-destination-address ).
Protocol 00-Protocol identifier TP-PID (TP-Protocol-identifier)
Bit No.
7
6
5
4
3
2
1
0

Bit No. 7 and bit No. 6: 00-for example, the allocation of bit no.0-bit No. 5 as defined below; 01-refer to the full definition of the gsm03.40 protocol logo; 10-reserved; 11-as the service center (SC) for special purposes, bit no.0-bit No. 5 is allocated.
Generally, these two locations are 00.
Bit No. 5: 0-No remote network, but the protocol between Short Message devices. 1-use remote network.
Bit no.0-bits No. 4: 00000-implied; 00001-telex; 00010-group 3 Telefax; 00100-voice; 00101-European wireless Information System (ERMES); 00110-domestic systems; 10001-any x.400-based public information processing system; 10010-email.
000000-data encoding scheme TP-DCS (TP-data-coding-Scheme)
Bit No.
7
6
5
4
3
2
1
0

Bit No. 7 and bit No. 6: generally set to 00; bit No. 5: 0-the text is not compressed; 1-the text is compressed using the GSM standard compression algorithm; bit No. 4: 0-indicates that bit No.1 and bit no.0 are reserved bits without information type information. 1-indicates that bit No.1 and bit no.0 contain information type information. Bit No. 3 and bit No. 2: 00-default alphabet, 01-8bit, 10-usc2 (16bit), 11-reserved; bit No.1 and bit no.0: 00-class-Class 2 (SIM card-specific information ), 11-Class 3.
Expires 00-validity period TP-VP (TP-valid-period)
VP value (& H)
Effective Period

00 to 8f
(VP + 1) * 5 minutes

90 to A7
12 hours + (VP-143) * 30 minutes

A8 to C4
(VP-166) * 1 day

C5 to FF
(VP-192) * 1 week

201702-User Data Length TP-UDL (TP-user-data-length)
2017c834-user data TP-UD (TP-user-data) "Hi"
4. Short Message Encoding
Set the content of the short message to be sent to "hi", and use the GSM character set to be 7-bit encoded. First, convert the character to a 7-bit binary, and then call the subsequent character to the front to complete the difference. For example, if H is translated into 1001000 and I is translated into 1101001, it is obvious that H's binary code is less than eight bits, then the last bits of I will be added to the front of H. Then it becomes 11001000 (C8), I has the remaining six digits of 110100, and then fill in two zeros in the front to change to 00110100 (34), so "hi" is changed to two eight-digit numbers of C8 34.
5. Sending and receiving of Short Messages
Since TC35 (t) supports the text format, we mainly test this format in the experiment.
(1) set up the short message center
At + csca = "+ 8613800731500" (short message center );
(2) set the short message sending format
At + cmgf = 1 (1-text; 0-pdu );
(3) send Short Messages (the short message content is "test ")
At + cmgs = "13508485560" (destination address)
> Test ^ Z;
(4) set the automatic prompt for Short Message arrival: Set the prompt for Short Message arrival. When the short message is received, the command + cmti: "SM", index (information storage location) will be obtained)
At + cnmi = 1, 1, 0, 0, 1 ();
(5) Get the short message content (once more), assuming Index = 8.
At + cmgr = 8
The returned information is as follows:
+ Cmgr: "rec unread", "+ 8613508485560", "01/07/16, 15: 37: 28 + 32", once more
6. Notes
(1) The short message center will not be changed. If the number of the short message center is changed, remember to restart TC35 when you use the "at + csca" statement, otherwise, TC35 will not work properly (tc35t does not exist ).
(2) Some SIM cards have a password. You need to enter a password when starting.


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.