Common at instruction sets for mobile text messages

Source: Internet
Author: User
Practical AT commands
The single-chip microcomputer and the GSM Engine Use at commands to communicate with each other. Therefore, it is necessary to understand the AT command format and several common commands. For more information, see the gsm07.05 and gsm07.07 specifications.
The at Command issued by the microcontroller is used to establish a communication link. The AT Instruction Set Command Format frames start with at. Below are several common at commands.
1. Set up the short message center
At + csca = "+ 8613800270500" Enter (the specific number is determined by the local carrier .)
2. receive short messages
+ Cmti: "SM", X (X indicates the SIM card storage number for receiving short messages)
At + cmgr = x press enter (read short messages from the X storage area)
At + cmgd = x press enter (delete Short Message from X storage area)
3. Send Short Messages
At + cmgf = 1 Press enter (sent in text format, for example, in PDU format, at + cmgf = 0)
At + cmgs = "+ 8613xxxxxxxxx" Press ENTER
> Enter a short message. Crtl + z ends and sends the message.
4. Important commands
Atz; e press ENTER echo off
Atz; E1 press ENTER echo on
At + CREG? Press enter to answer x (x = 2, x = 1 Registration, x = 0 status unknown)
At + cops? Enter indicates whether the SIM card is accepted by the Network
At + cops =? Press enter to display all available networks.
5. Create a voice call
At + CREG? Enter (whether to register online)
Atd13xxxxxxxxx; press enter (the difference between a voice call and a data call lies in the semicolon after the number)
6. Change and save the parameters.
At + IPR = 2400 press enter (changes the RS232 port speed to 2400bps)
At & W press enter (Save the modified parameter)
7. Enter the pin code.
At + cpin = "XXXX"
After the communication link is established, the microcontroller can send an information unit frame. The format of the information frame is as follows:
The frame header starting with the flag frame is hex 10 h and 02 h, and the information ending with the mark is 10 h and 03 H, the last two digits are the result of the modulo operation after the data is summed by 16 bits. For data bits, to avoid an error ending mark, it is required that after each 10 H code word appears, an empty character 00 H is inserted next to it. After receiving the information, the acceptor removes the null character. If the sum of the data and BCS received by the receiving end is not equal to 0 after 16 bits, it indicates that the transmission has an error and the received information will be discarded.
This article uses an example to describe the entire process of sending a PDU text message using the AT command. If I want to send the following text message:
Receiving number: + 8613602433649
Text message content: Happy work!
SMS center number: + 8613800200500

1. Handling of SMS center numbers: represented by the string ADDR
1. Remove the number + from the SMS center to check whether the length is an even number. If not, add F
That is, ADDR = "+ 8613800200500"
=> ADDR = "8613800200500f"
2. Exchange odd and even digits.
=> ADDR = "683108020005f0"
3. Adding 91,91 to the front of the SMS center number indicates internationalization.
=> ADDR = "91683108020005f0"
4. Calculate the length of the ADDR, and divide the result into 2 hexadecimal strings, 16/2 = 8 => "08"
=> ADDR = "0891683108020005f0"

2. Mobile phone number processing: Use the string phone
1. Remove the phone number + to check whether the length is an even number. If not, add F
That is, phone = "+ 8613602433649"
=> Phone = "8613602433649f"
2. Exchange odd and even numbers of mobile phone numbers.
=> Phone = "683106423366f9"

3. Partial Short Message Processing: represented by the string msg
1. Convert the conversion string to Unicode Code, for example, "Work well !" The Unicode code of is 5de54f5c61095febff01,
(For the conversion functions, see the appendix at the end)
2. Divide Msg Length by 2 and retain two hexadecimal numbers, namely 5de54f5c61095febff01 = 20/2 => "0a", and add msg
=> MSG = "0a5de54f5c61095febff01"

Iv. Combination
1. Add the character string 11000d91 (1100: fixed, 0d: the length of the mobile phone number. If it is not a plus sign, it is expressed in hexadecimal format. If it is 91, it is sent to the mobile phone, sent to PHS 81 ),
That is, phone = "11000d91" + phone
=> 11000d91683106423366f9
2. After the mobile phone number is added with 000800 and the short message content just now, 000800 can also be written to death.
That is, phone = phone + "000800" + msg
11000d91683106423108f9 + 000800 + 0a5de54f5c61095febff01
=> Phone = 11000d91683106423108f90008000a5de54f5c61095febff01
3. Divide the phone length by 2 and format it into two decimal digits.
That is, 11000d91683106423108f90008000a5de54f5c61095febff01 => 50 bits/2 => 25

5. the content to be sent is
At + cmgf = 0 <press enter>
OK
At + cmgs = 25 <press enter>
> ADDR + phone <Ctrl + Z send>

6. If the returned result is not an error, congratulations, the message has been sent successfully. ^_^

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.