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
Previous Page | Page 22 of 65 | Next Page |
- 1. Introduction to SMS Messaging
- 2. What Makes SMS Messaging So Successful Worldwide?
- 3. Example Applications of SMS Messaging
- 4. What is an SMS Center / SMSC?
- 5. Basic Concepts of SMS Technology
- 6. Intra-operator SMS Messages
- 7. Inter-operator SMS Messages
- 8. International SMS Messages
- 9. What is an SMS Gateway?
- 10. How to Send SMS Messages from a Computer / PC?
- 11. How to Receive SMS Messages Using a Computer / PC?
- 12. Introduction to GSM / GPRS Wireless Modems
- 13. How to Use Microsoft HyperTerminal to Send AT Commands to a Mobile Phone or GSM/GPRS Modem?
- 14. Introduction to AT Commands
- 15. General Syntax of Extended AT Commands
- 16. Result Codes of AT Commands
- 17. AT Command Operations: Test, Set, Read and Execution
- 18. Testing the Communication between the PC and GSM/GPRS Modem or Mobile Phone
- 19. Checking if the GSM/GPRS Modem or Mobile Phone Supports the Use of AT Commands to Send, Receive and Read SMS Messages
- 20. Operating Mode: SMS Text Mode and SMS PDU Mode
- 21. Setting or Reading the Service Center Address / SMSC Address (AT+CSCA)
- 22. Preferred Message Storage (AT+CPMS)
- 23. Writing SMS Messages to Memory / Message Storage (AT+CMGW)
- 24. Deleting SMS Messages from Message Storage (AT+CMGD)
- 25. Sending SMS Messages from a Computer / PC Using AT Commands (AT+CMGS, AT+CMSS)
- 26. Reading SMS Messages from a Message Storage Area Using AT Commands (AT+CMGR, AT+CMGL)
- 27. Appendix A: How to Choose an SMS Service Provider (SMS Gateway Provider, SMS Reseller, SMS Broker)?
- 28. Appendix B: Comparison Table of SMS Service Providers (SMS Gateway Providers, SMS Resellers, SMS Brokers)
- 29. Appendix C: Free Software/Tools and Libraries for Sending and Receiving SMS Messages with a Computer / PC
- 30. Appendix D: GSM 7-bit Default Alphabet Table (with Character Codes of ISO 8859 Latin 1)