General Syntax of Extended AT Commands (Tutorial 15)

The general syntax of extended AT commands is straightforward. The syntax rules are provided below. The syntax of basic AT commands is slightly different. We will not cover the syntax of basic AT commands in this SMS tutorial since all SMS messaging commands are extended AT commands.


Syntax rule 1. All command lines must start with "AT" and end with a carriage return character. (We will use to represent a carriage return character in this SMS tutorial.) In a terminal program like HyperTerminal of Microsoft Windows, you can press the Enter key on the keyboard to output a carriage return character.

Example: To list all unread inbound SMS messages stored in the message storage area, type "AT", then the extended AT command "+CMGL", and finally a carriage return character, like this:


AT+CMGL


Syntax rule 2. A command line can contain more than one AT command. Only the first AT command should be prefixed with "AT". AT commands in the same command-line string should be separated with semicolons.

Example: To list all unread inbound SMS messages stored in the message storage area and obtain the manufacturer name of the mobile device, type "AT", then the extended AT command "+CMGL", followed by a semicolon and the next extended AT command "+CGMI":


AT+CMGL;+CGMI


An error will occur if both AT commands are prefixed with "AT", like this:


AT+CMGL;AT+CGMI


Syntax rule 3. A string is enclosed between double quotes.

Example: To read all SMS messages from message storage in SMS text mode (at this time you do not need to know what SMS text mode is. More information will be provided later in this SMS tutorial), you need to assign the string "ALL" to the extended AT command +CMGL, like this:


AT+CMGL="ALL"


Syntax rule 4. Information responses and result codes (including both final result codes and unsolicited result codes) always start and end with a carriage return character and a linefeed character.

Example: After sending the command line "AT+CGMI" to the mobile device, the mobile device should return a response similar to this:


Nokia
OK


The first line is the information response of the AT command +CGMI and the second line is the final result code. and represent a carriage return character and a linefeed character respectively. The final result code "OK" marks the end of the response. It indicates no more data will be sent from the mobile device to the computer / PC.

When a terminal program such as HyperTerminal of Microsoft Windows sees a carriage return character, it moves the cursor to the beginning of the current line. When it sees a linefeed character, it moves the cursor to the same position on the next line. Hence, the command line "AT+CGMI" that you entered and the corresponding response will be displayed like this in a terminal program such as HyperTerminal of Microsoft Windows:


AT+CGMI
Nokia

OK


Information Response and Final Result Code

Don't forget the meanings of information response and final result code stated above, since you will see these two terms frequently as you go through this SMS tutorial.


AT+CGMI <-- Command line entered
Nokia <-- Information response

OK <-- Final result code


Case Sensitivity of AT Commands

In the SMS specification, all AT commands are in uppercase letters. However, many GSM/GPRS modems and mobile phones allow you to type AT commands in either uppercase or lowercase letters. For example, on Nokia 6021, AT commands are case-insensitive and the following two command lines are equivalent:


AT+CMGL


at+cmgl


from developershome .com