8/2/10

TESTING THE COMMUNICATION BETWEEN THE PC AND GSM/GPRS MODEM OR MOBILE PHONE

Suppose you have connected your GSM/GPRS modem or mobile phone to your PC / computer and started a terminal program (such as HyperTerminal on Microsoft Windows). Now you are ready to enter your first command. The first thing that is usually done is to test the communication between the PC and GSM/GPRS modem/mobile phone to confirm that everything is working properly so far. Simply enter "AT" in the terminal program to perform the test. When the GSM/GPRS modem or mobile phone receives "AT", it will send back the final result code "OK" to indicate that it has received your command successfully, like this:
AT OK
WRITING SMS MESSAGES TO MEMORY / MESSAGE STORAGE (AT+CMGW)
The AT command +CMGW (command name in text: Write Message to Memory) is used to write an SMS message to memory (i.e. message storage). The memory/message storage area to which SMS messages are written is specified by the +CPMS AT command (command line in text: Preferred Message Storage).
Syntax of the +CMGW AT Command in SMS Text Mode
In SMS text mode, the syntax of the +CMGW AT command is: (Optional parameters are enclosed in square brackets.)
+CMGW[=address[,address_type[,message_status]]]sms_message_body

Before we discuss each of the parameters, let's see an example that gives you some idea of how an actual command line should look like:
AT+CMGW="+85291234567",145,"STO UNSENT"
This is an example for illustrating the syntax of the +CMGW AT command in SMS text mode.
The Character
, which represents the carriage return character, follows the message_status parameter. When the GSM/GPRS modem or mobile phone receives the carriage return character, it will send back a prompt formed by these four characters: the carriage return character, the linefeed character, the ">" character and the space character.
The Character
When you finish entering the SMS message body, you have to enter the character to mark the end of the SMS message body. The GSM/GPRS modem or mobile phone will then attempt to write the SMS message to the memory/message storage area.
READING SMS MESSAGES FROM A MESSAGE STORAGE AREA USING AT COMMANDS (AT+CMGR, AT+CMGL)
To enable a computer / PC to read SMS messages from a message storage area, the GSM/GPRS modem or mobile phone has to support either of the AT commands +CMGR (command name in text: Read Messages) and +CMGL (command name in text: List Messages). The +CMGR AT command is used to read an SMS message at a certain location of the message storage area, while the +CMGL AT command is used to read SMS messages that have a certain status from the message storage area. The status can be "received unread", "received read", "stored unsent", "stored sent", etc. The +CMGL AT command also allows you to retrieve all SMS messages stored in the message storage area.
EXAMPLE:
Following is an example for illustrating the difference between +CMGR and +CMGL. Suppose we want to use your computer / PC to read a text message from the message storage area and we know the index at which the SMS text message is located. In this case, we

should use the +CMGR AT command. Here is the command line to be typed (assume the SMS text message is stored at index 3):
AT+CMGR=3
The GSM/GPRS modem or mobile phone should return something like this:
+CMGR: "REC READ","+85291234567",,"07/02/18,00:12:05+32" Hello, welcome to our SMS tutorial. OK

No comments:

Post a Comment