16. Result
Codes of AT Commands
Result
codes are messages sent from the GSM/GPRS modem or mobile phone to
provide you information about the execution of an AT command and the
occurrence of an event. Two types of result codes are useful to you
when dealing with AT commands for SMS messaging:
Final
result codes
Unsolicited
result codes
16.1. Final Result
Codes of AT Commands
A
final result code marks the end of an AT command response. It is an
indication that the GSM/GPRS modem or mobile phone has finished the
execution of a command line. Two frequently used final result codes
are OK and ERROR. Only one final result code will be returned for
each command line. Thus, you will not see both OK and ERROR in the
response of a command line.
16.1.1. The OK
Final Result Code
The
OK final result code indicates that a command line has been executed
successfully by the GSM/GPRS modem or mobile phone. It always starts
and ends with a carriage return character and a linefeed character.
Here
is an example for illustration. Let's say you send the command line
"AT+CMGL;+CGMI<CR>" to your GSM/GPRS modem.
The AT command "+CMGL" is used to list SMS messages stored
in the message storage area and the AT command "+CGMI" is
used to get the manufacturer name of the GSM/GPRS modem. If
everything works properly without any errors, the command line,
together with the response returned, should be something similar to
this:
AT+CMGL;+CGMI<CR> <CR><LF>+CMGL:
1,"REC
UNREAD","+85291234567",,"06/11/11,00:30:29+32"<CR><LF> Welcome
to our SMS tutorial.<CR><LF> <CR><LF>Nokia<CR><LF> <CR><LF>OK<CR><LF>
As
mentioned earlier, 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 you entered, together with the response
returned, will be displayed like this in a terminal program such as
HyperTerminal of Microsoft Windows:
AT+CMGL;+CGMI +CMGL:
1,"REC UNREAD","+85291234567",,"06/11/11,00:30:29+32" Welcome
to our SMS tutorial.
Nokia
OK
16.1.2. The ERROR
Final Result Code
The
ERROR final result code indicates that an error occurs when the
GSM/GPRS modem or mobile phone tries to execute a command line. After
the occurrence of an error, the GSM/GPRS modem or mobile phone will
not process the remaining AT commands in the command-line string.
Below
are some common causes of error:
The
syntax of the command line is incorrect.
The
value specified to a certain parameter is invalid.
The
name of the AT command is spelt incorrectly.
The
GSM/GPRS modem or mobile phone does not support one or more of the
AT commands, command parameters or parameter values in the
command-line string.
Like
the OK final result code, the ERROR final result code always starts
and ends with a carriage return character and a linefeed character.
Here
is an example for illustration. Suppose you want to instruct your
GSM/GPRS modem to list SMS messages from the message storage area and
get the manufacturer name of the GSM/GPRS modem. You intend to type
the command line "AT+CMGL;+CGMI<CR>" but make
a careless mistake by typing "+CMFL" instead of "+CMGL".
The GSM/GPRS modem will return the ERROR final result code, as shown
below:
AT+CMFL;+CGMI<CR> <CR><LF>ERROR<CR><LF>
As
an error occurs when the GSM/GPRS modem processes "+CMFL",
the GSM/GPRS modem stops the execution of the command line and so the
second AT command "+CGMI" is not processed.
If
you type the second AT command "+CGMI" incorrectly instead
of the first AT command "+CMGL", the GSM/GPRS modem will
output the result of the execution of the AT command "+CMGL"
before outputting the ERROR final result code, like this:
AT+CMGL;+CGMU<CR> <CR><LF>+CMGL:
1,"REC
UNREAD","+85291234567",,"06/11/11,00:30:29+32"<CR><LF> Welcome
to our SMS tutorial.<CR><LF> <CR><LF>ERROR<CR><LF>
As
mentioned earlier, 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 you entered, together with the response
returned, will be displayed like this in a terminal program such as
HyperTerminal of Microsoft Windows:
AT+CMGL;+CGMU +CMGL:
1,"REC UNREAD","+85291234567",,"06/11/11,00:30:29+32" Welcome
to our SMS tutorial.
ERROR
Feedback Form (ExpandCollapse)
|
|