There are four types of AT command operations:
Test operation. A test operation is used to check whether a certain AT command is supported by the GSM/GPRS modem or mobile phone.
Set operation. A set operation is used to change the settings used by the GSM/GPRS modem or mobile phone for certain tasks.
Read operation. A read operation is used to retrieve the current settings used by the GSM/GPRS modem or mobile phone for certain tasks.
Execution operation. An execution operation is used to perform an action or retrieve information/status about the GSM/GPRS modem or mobile phone.
The command syntax for performing an operation will be described in detail in the following sections.
Test Command -- Checks Whether a Certain AT Command is Supported
A test operation is used to check whether a certain AT command is supported by the GSM/GPRS modem or mobile phone. All extended AT commands support the test operation. The syntax is:
command=?
where command is an AT command. When an AT command is used in the above syntax to perform a test operation, it is called a test command.
Here is an example. The AT command +CGMI (command name in text: Request Manufacturer Identification) is used to get the manufacturer name of the GSM/GPRS modem or mobile phone. To test whether +CGMI is supported, you can make use of the test command "+CGMI=?". The complete command line that should be entered is:
AT+CGMI=?
If the GSM/GPRS modem or mobile phone supports the AT command +CGMI, the result code "OK" will be returned, like this:
AT+CGMI=?
OK
If the GSM/GPRS modem or mobile phone does not support the AT command +CGMI, the result code "ERROR" will be returned, like this:
AT+CGMI=?
ERROR
In the above example, the AT command +CGMI does not have any parameters. If the AT command to be tested has parameter(s), the parameter value(s) supported by the GSM/GPRS modem or mobile phone may be printed additionally. Below is an example that illustrates the format of the response. +COMMAND1 is a fictitious AT command that has four parameters.
AT+COMMAND1=?
+COMMAND1: (0,1),(0-10),(0,1,5-10),("GSM","UCS2")
OK
The supported values of each of the four parameters are enclosed in parentheses. Commas are used to delimit the parentheses and the values inside parentheses. A hyphen is used to indicate a range of values. The values inside parentheses can be of the string type.
In the above example, the response of the test command "+COMMAND1=?" provides us the following information:
(0,1). The first parameter accepts either 0 or 1.
(0-10). The second parameter accepts any integer between 0 and 10.
(0,1,5-10). The third parameter accepts 0, 1 or any integer between 5 and 10.
("GSM","UCS2"). The fourth parameter accepts either the string "GSM" or "UCS2".
To a few AT commands, the test operation does not return the parameter values supported. Instead, it returns the values that are allowed to appear in the information response of the AT command. An example is the +CBC AT command (command name in text: Battery Charge). The +CBC command is used to retrieve the connection status and charge level of the battery of the mobile device. Two values are returned in the information response of the +CBC AT command. The format is:
+CBC: connection_status,charge_level
For example, if the battery is placed in the mobile device with no charger connected and the charge level is 80%, the result of the execution of the +CBC AT command will be:
AT+CBC
+CBC: 0,80
OK
If you run the test command "+CBC=?", all the supported values that are allowed to appear in the connection status field and charge level field will be provided. With my Nokia 6021, the result is:
AT+CBC=?
+CBC: (0,1),(0-100)
OK
"(0,1)" means the connection status field in the information response of the +CBC AT command can contain either 0 or 1, while "(0-100)" means the charge level field can contain any integer between 0 and 100.