Text message sending and receiving Problems Based on sim300 and S3C2410-3

Source: Internet
Author: User
Tags comparison table network function sca
Text message sending and receiving Problems Based on sim300 and S3C2410-3

The most important thing about organizing at commands and applications is not in this command, but serial port operations. The serial port is really great... I think...

Next, the AT command in the previous article, which is shown in the following table:

Execute commands

Description

Feedback

ATD

Dialing command. This command is used to set a call, data, or fax call.

No dialtone;

If the line is busy, busy;

If the connection cannot be established, no carrier;

If the connection is successful, OK + dial the phone number.

ATH

Host Command.

If the initial status is on, OK is returned after the host is successfully suspended.

ATA

Answer the phone.

If the connection is successful, OK;

If there is no connection, no carrier.

At + CSMs =

Select message service. = 0 GSM; = 128 indicates that the sms pdu mode is selected.

Return + CSMs: 0 (OR 1) OK

At + cmgf =

Set the information format. = 0 indicates the PDU mode; = 1 indicates the text mode.

Return + cmgf: 0 (OR 1) OK

At + cmgs

Send information. (Used together with cmgf)

If + cmgf = 1 and sent successfully, + cmgs is returned: <Mr> OK;

If + cmgf = 0 and sent successfully, + cmgs: <Mr> OK; (the two return different Mr values );

If an error occurs, + CMS error is returned: <err>

At + cmee = 1

Mobile device Error Reporting

Return + cmee :( list of supported <n> S) OK

At + cmgl = <stat>

Lists information from a specified bucket. The <stat> parameters executed vary according to the mode.

+ Cmgl: list of supported <stat> Sok returned

 

At + cnmi = [<mode>

[, <Mt> [, <BM>

[, <DS> [, <BFR>]

]

New information indication. This command selects how to receive short messages from the network. The preceding parameters can be checked in the comparison table, which is not listed here.

If the setting is correct, OK is returned;

If an error occurs, + CMS error: <err> is returned.

At + cmgr

Read text messages. Information is read from the memory set by the + CPMS command.

Return OK.

At + IPR = <rate>

Set the baud rate. Optional values:, and.

Return OK.

At + cmgs

Send information. (Used together with cmgf)

If + cmgf = 1 and sent successfully, + cmgs is returned: <Mr> OK;

If + cmgf = 0 and sent successfully, + cmgs: <Mr> OK; (the two return different Mr values );

If an error occurs, + CMS error is returned: <err>

At + cmgd = <I

Ndex>

Delete short messages.

If the text message is successfully deleted from the specified location, Return OK;

If an error occurs, + CMS error <err> is returned.

At + csca =

<SCA> [, <Tosca>]

Set the SMS service center address. Generally, you need to set this parameter when sending text messages. <SCA> it can be considered as the mobile phone number of the other party that needs to be connected.

The return value is also simple. If the return value is successful, OK is returned.

There are several points to note:

1. ATD commands can be written in multiple ways. Depending on the nature of the number you choose to connect to, the AT command set documentation provided by simcom is divided into the following (I have not translated it, I want to compare it ):

ATD [<n>] [<mgsm] [;] mobile originated call to dialable number

ATD> <mem> <n> [<I>] [<G>] [;] originate call to phone number in memory <mem>

ATD> <n> [<I>] [<G>] [;] originate call to phone number in current Memory

ATD> <STR> [I] [g] [;] originate call to phone number in memory which corresponding alphanum.

 

2. <err> the same set of numbers represent different meanings. For example, 13 indicates SIM failure; 14 indicates SIM busy.

 

3. here I only list some AT commands about text messages, and I think they are more important. Of course, the AT Instruction Set has far more functions than that, you need to know that the reason why it appears is to satisfy the network function. In simcom's "AT Instruction Set", we will explain in detail the TCP/IP and CAT settings, if you have any conditions, try again...

 

Well, that's all you can think of now...

Next, we will describe how to use the AT command for sending and receiving text messages... No hurry!

 

Because I learned simple AT commands, I want to use at commands only by calling and sending and receiving text messages:

Premise 1: This is when all interfaces are connected, including serial port initialization and GPRS module drivers.

Premise 2: In the project, arm sends commands to the GPRS module for execution. The instructions here are transmitted through the serial port. Therefore, the input command execution is to write the serial port, the written content is the "at command ".

Premise 3. Based on the former, a function tty_writecmd (char * Buf, int nbytes) for writing commands to the serial port has been written. We can directly perform this operation.

Premise 4: I will only describe the process of combining these commands.

 

1. Set (modify) the baud rate

Purpose: indirectly control the GPRS module through arm control so that it can directly modify the baud rate. Of course, you can also modify the baud rate at minicom.

Tty_writecmd ("at", strlen (""));

Tty_writecmd ("at + IPR =", strlen ("at + IPR = "));

Tty_writecmd (Baud, strlen (baud); // The Band macro is defined as b115200.

 

2. Call

Purpose: indirectly control the GPRS module through arm control to enable external calls, only for mobile phones.

Tty_writecmd ("at", strlen (""));

Tty_write ("ATD", strlen ("ATD "));

Tty_write (number, num); // number indicates the telephone number.

Tty_write ("; \ r", strlen ("; \ r"); // The reason for adding such a sentence, this is because each input and output of serial data ends with "10" or "13.

 

3. Answer the phone

Role: when a new call comes in from the GPRS module, the GPRS module is indirectly controlled by arm to enable the call.

Tty_writecmd ("at", strlen (""));

Tty_writecmd ("ata", strlen ("ata "));

 

4. hanging up the phone

Purpose: When the GPRS module receives a call or a new call comes in, it indirectly controls the GPRS module through arm control to enable the call to end.

Tty_writecmd ("at", strlen (""));

Tty_writecmd ("ath", strlen ("ath "));

 

5. send text messages

Function: indirectly controls the GPRS module by controlling arm to send text messages to remote mobile phones.

Tty_writecmd ("at", strlen (""));

Tty_writecmd ("at + cmgf = 1", strlen ("at + cmgf = 1 "));

Tty_write ("at + cmgs =", strlen ("at + cmgs = "));

Tty_writecmd ("\" ", strlen ("\""));

Tty_writecmd (number, strlen (number ));

Tty_writecmd ("\" ", strlen ("\""));

Tty_writecmd ("; \ r", strlen ("; \ r "));

 

6. receive text messages

Purpose: send a text message to the GPRS module. The GPRS module can receive the text message and read the text message.

Tty_writecmd ("at + cnmi =, 0", strlen ("at + cnmi =, 0 "));

Tty_writecmd ("at + cmee = 1", strlen ("at + cmee = 1 "));

Tty_writecmd ("at + CSMs = 0", strlen ("at + CSMs = 0 "));

Tty_writecmd ("at + cmgf = 1", strlen ("at + cmgf = 1 "));

Tty_writecmd ("at + cmgl = 0", strlen ("at + cmgl = 1 "));

Ty_writecmd ("at + cmgr = 1", strlen ("at + cmgr = 1 "));

For the last sentence at + cmgr = 1, it indicates reading text messages from the pre-defined storage area, but only using this command, instead of reading through the serial port, you still cannot display the information you just sent on the PC.

The above is a small understanding of AT command organization and application. The most important thing is not the command, but the serial port operation. The serial port is really great... I think...

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.