Use of AT commands related to SMS in the GSM Module

Source: Internet
Author: User
Any secondary development using the GSM module, whether used for public speaking or GPRS communication, in which short messages are basically used. This topic describes how to use at commands related to short messages.
For detailed at instruction instructions, refer to 07.05 or the at manual of Siemens mc35i. The Siemens manual is quite good.

1. Short Message format

The short messages that I have seen are basically in two formats: Text and PDU. The text mode is relatively simple. It is especially suitable for transmitting those characters. for foreigners, It is very convenient to Issue 26 subtitles. The PDU mode requires encoding. Currently, many Chinese characters are transmitted in the PDU mode. I am not familiar with PDU and how to send Chinese characters.

Generally, the module uses the PDU mode by default. You can use the following command to switch to the text mode:
At + cmgf = 1
If you want to switch to PDU mode again, use:
At + cmgf = 0
The following short message sending and reading modes all adopt the text mode, because I don't know much about PDU.

2. How to send me a short message?
Now you have a gnetwork module, but first make sure that the following operations have been completed:
1) The module is powered on and the AT command communicates smoothly with the serial port of your PC.
2) the SIM card is not in arrears and has logged on to the GSM network (Can I use at + CREG? Query. If 1 or 5 is returned, the query is normal ).
3) at + cmgf = 1 is set.

With the above process, you can send me a message. The at command you want to use is at + cmgs.
Assume that my mobile phone number is 13636371111 (the last four digits are false ).

1) input at + cmgs = "13636371111" from the serial port and press Enter.
2) at this time, you can see a message larger than '>' popped up, prompting you to enter the message content.

If you want to send "Hello World", simply enter it after '>'. After the input is complete, press 'ctrl ^ Z '. Wait a moment and your information will be sent out, if the programming seems to be 0x1b (you can check the ASCII table if you cannot remember it ).
The entire process is as follows:
At + cmgs = "13636371111"
> Hello World
+ Cmgs: 199

OK
You must wait until OK returns to confirm that the message is sent successfully. The middle part can be ignored first. If you enter "Hello World" and do not want to send it again, Press ESC to cancel sending, so you will not describe it again.

3. How to enable transfer return?
We can find a menu on the mobile phone, and you can choose to send the return function. That is to say, after someone receives your message, the short message center will send you a confirmation message, if it is sent to the sweetheart, this function is particularly important.
We have no menu options for the module, but we have an AT command such as at + CSMP. In text mode, the option on the mobile phone can be implemented using this command, I am not very clear about the specific meaning of this command, and I am too reluctant to study it. Someone once told me to follow the settings below and send a return:
At + CSMP = 33
However, even if you set it like this, you may still not be able to see the transfer return after someone else receives it. You also need to set another at command: "At + cnmi =, 1 ", the following describes the usage of this command.
For the PDU mode, there is a big difference in controlling the transfer return.
4. At + cnmi usage.
So far, you have at least the following questions:
1) How do I know the new text message?
2) I am worried that the SIM card will be written badly after a long time, flash may also be written badly, or I don't need to store SMS messages with strong single-chip microcomputer, so the module will directly send it to me. What should I do?
3) I want to see the transfer return!
All the above questions can be answered from at + cnmi.
I have a manual for Siemens mc35 on hand. Several Parameters of cnmi are as follows:
At + cnmi = [<mode>] [, <Mt>] [, <BM>] [, <DS>] [, <BFR>]
Square brackets indicate that the parameters are optional:
<Mode> it is used to select a new text message, prompting whether the message needs to be played directly from the serial port. Generally, 2 is used.
<Mt> this option is used to select the prompt mode for the new text message. If the value is 1, it is relatively simple. For example, "+ cmti:" SM ", 3" tells you that the new text message is saved in the SIM card, the serial number is 3. I will tell you how to read it later. If the parameter value is 2, the new text message is not stored and displayed directly from the serial port.
<DS> this option is used to select the transfer return value. If you want to see the return value, 1 is generally used in combination with at + CSMP ).
Other parameters are not described.
Three sets of parameters are provided here for your use:
1) At + cnmi = 2, 1, 1
This set of parameters can provide new information prompts and send return functions
2) at + cnmi = 2, 1
This set of parameters displays new information directly to the serial port. If this parameter is not stored, the transfer return is still enabled.
3) at + cnmi = 2, 1
This set of parameters, the general module will have a new message, will not enable the return function (open may interfere with the microcontroller processing) The above is for reference only, different manufacturers module implementation form and support parameters may be different, actual test is required.

5. How do I read SIM card or mobile phone information?
For example, we receive the following message: "+ cmti:" SM ", 3". We know the new information and store it in the SIM card, 3rd locations. How can we read it?

Easy to read with at + cmgr, as shown below:
At + cmgr = 3. After you press enter, you can see the text message content, which is relatively simple and will not be used here.

There is also a command for reading text messages, at + cmgl, which can list all at commands in the mobile phone,
For example:
At + cmgl = "all". After you press enter, you can return all the text messages in the current storage area.
+ There are three other parameters in cmgl. You can refer to the manual and the PDU is somewhat different. The parameters use numbers.

6. How to Select a storage area?
The current modules generally provide 2-3 storage areas, SIM card, mobile phone (flash), SIM card + flash.
Can we use at + CPMS? For more information about the three CPMS parameters, it is easy to mix up. It does not mean that the SIM card or mobile phone has three storage zones.
Set the command as follows: At + CPMS = <mem1> [, <MEM2>] [, <mem3>]
<Mem1> memory to be used when listing, reading and deleting messages:
<MEM2> memory to be used when writing and sending messages:
<Mem3> received messages will be placed to this storage if routing to te is not
Set.
The above is a copy from the Siemens manual to save trouble, and I need to understand it carefully. Try it several times in combination.

7. How to delete a text message?
Use at + cmgd, for example:
At + cmgd = 1 will delete the first message in <mem1> (note that the module returns OK after deletion, and some modules return error, which indicates that there is no short message at this position ).
At + cmgd also has a full delete function, such:
At + cmgd = all messages in the <mem1> storage area will be deleted. (Note that there are three other parameters in the second parameter. You can refer to the Manual and not all factory modules support full deletion)

Now, I have been working for two hours. I have to go to bed and start working early tomorrow.

I used short message programming once two years ago. It was the first time I came into contact with the AT command. I couldn't find anything on the Internet, but I couldn't do it well. I have learned from the hard work of beginners, but now I am not doing anything. I will share what I know and share it with beginners.

In order to handle the code well, we still need to carefully study the 07.05 protocol and the manual provided by the manufacturer, and then compare the actual verification, do not guess, even if it is correct in one place, you may not be able to use things in another city.

If you want code, wait. Now you are testing the PPP code.

Originally written in word, the iron format is gone, unfortunately!

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.