26.3.5. Syntax of
the +CMGL AT Command in SMS PDU Mode
The
syntax of the +CMGL AT command in SMS PDU mode is: (Optional
parameter is enclosed in square brackets.)
+CMGL[=message_status]
The
message_status
parameter takes an integer that specifies the message status to be
used to find messages to return. The SMS specification has defined
five message status values, which are shown below. You can perform a
test operation to find the actual values supported by your GSM/GPRS
modem or mobile phone. See the "Finding
the Message Status Values Supported by the +CMGL AT Command in SMS
PDU Mode" section
for the details. Usually all five status values are supported.
0.
It refers to the message status "received unread". It is
the default value.
1.
It refers to the message status "received read".
2.
It refers to the message status "stored unsent".
3.
It refers to the message status "stored sent".
4.
It tells the +CMGL AT command to list all messages.
For
example, if 1 is specified to the message_status
parameter, the +CMGL AT command will list all messages that have the
"received read" status from the message storage area.
Note
that message_status is
an optional parameter. If it is omitted, the +CMGL AT command will
use the default value 0.
26.3.6. Format of
the Information Response of the +CMGL AT Command in SMS PDU Mode
If
the GSM/GPRS modem or mobile phone reads the SMS message from message
storage successfully, it will return an information response to the
computer / PC. In SMS PDU mode, the information response of the +CMGL
AT command has the following format: (Optional fields are enclosed in
square brackets.)
+CMGL:
index,message_status,[address_text],TPDU_length<CR><LF>SMSC_number_and_TPDU[<CR><LF>+CMGL:
...]
Before
we discuss each of the fields that appear in the +CMGL information
response, let's see an example that gives you some idea of how an
actual +CMGL information response should look like:
+CMGL:
1,0,,62 07915892000000F0040B915892214365F700007040213252242331493A283D0795C3F33C88FE06C9CB6132885EC6D341EDF27C1E3E97E7207B3A0C0A5241E377BB1D7693E72E
The
index Field
The
first field of the information response of the +CMGL AT command,
index, is an integer
that specifies the location of the SMS message in the message storage
area.
The
message_status Field
The
second field of the information response of the +CMGL AT command,
message_status, is an
integer that indicates the status of the SMS message. It can be one
of the following four values:
0.
It refers to the message status "received unread".
1.
It refers to the message status "received read".
2.
It refers to the message status "stored unsent".
3.
It refers to the message status "stored sent".
The
address_text Field
The
third field of the information response of the +CMGL AT command,
address_text, is a
string that contains the text associated to address
in the phonebook, where address
is the phone number encoded in the TPDU of the SMSC_number_and_TPDU
field. For example, if the phone number encoded in the TPDU is
"91234567" and the text "Alice" is associated to
the phone number "91234567" in the phonebook, address_text
will be "Alice". The AT command +CSCS (command name in
text: Select TE Character Set) can be used to specify the character
set for displaying address_text.
Note
that address_text is
an optional field. Some GSM/GPRS modems and mobile phones leave this
field empty. (Examples: Philips 598 supports this field, while most
Nokia products, including my Nokia 6021, and Sony Ericsson T68i does
not.)
The
TPDU_length Field
The
fourth field of the information response of the +CMGL AT command,
TPDU_length, is an integer
that indicates the length (in octets. 1 octet = 8 bits) of the TPDU
contained in the SMSC_number_and_TPDU
field. In the earlier example command line, the value of the
SMSC_number_and_TPDU
field is:
07915892000000F0040B915892214365F700007040213252242331493A283D0795C3F33C88FE06C9CB6132885EC6D341EDF27C1E3E97E7207B3A0C0A5241E377BB1D7693E72E
It
can be divided into two parts. The following part is the TPDU:
040B915892214365F700007040213252242331493A283D0795C3F33C88FE06C9CB6132885EC6D341EDF27C1E3E97E7207B3A0C0A5241E377BB1D7693E72E
The
TPDU is coded in hexadecimal format. Each character represents 4
bits, i.e. 1/2 octet. The TPDU has 124 characters and so there are
totally 62 octets. That's why the value of the TPDU_length
field is 62.
The
SMSC_number_and_TPDU Field
The
fifth field of the information response of the +CMGL AT command,
SMSC_number_and_TPDU,
specifies the SMSC number and the TPDU (Transfer Protocol Data Unit)
in hexadecimal format.
If
the SMS message to be read is an incoming SMS message, the value of
the SMSC_number_and_TPDU field will be something like this:
07915892000000F0040B915892214365F700007040213252242331493A283D0795C3F33C88FE06C9CB6132885EC6D341EDF27C1E3E97E7207B3A0C0A5241E377BB1D7693E72E
The
TPDU embedded in the above hexadecimal sequence is of the type
SMS-DELIVER. Here is some of the information encoded in the
hexadecimal sequence:
SMSC
number from which the SMS message was received: +85290000000
Sender
phone number: +85291234567
Time
and date at which the SMSC received the SMS message: 12 April 2007,
23:25:42 GMT+8 hours
Text
message: "It is easy to read text messages via AT
commands."
For
the details about how the hexadecimal sequence of an incoming SMS
message is coded, please refer to the section titled "Some
Explanation about the Decoding of the SMSC_number_and_TPDU Field
Value of the +CMGR AT Command" of this SMS tutorial.
If
the SMS message to be read is an outgoing SMS message, the value of
the SMSC_number_and_TPDU
field will be something like this:
07915892000000F001000B915892214365F7000021493A283D0795C3F33C88FE06CDCB6E32885EC6D341EDF27C1E3E97E72E
The
TPDU embedded in the above hexadecimal sequence is of the type
SMS-SUBMIT. Its format is different from that of an SMS-DELIVER TPDU.
Below shows some of the information encoded in the hexadecimal
sequence above:
SMSC
number to be used if the SMS message is sent out: +85290000000
Destination
phone number: +85291234567
Text
message: "It is easy to send text messages."
For
the details about how the hexadecimal sequence of an outgoing SMS
message is coded, please refer to the section titled "Some
Explanation about the Coding of the SMSC_number_and_TPDU Parameter
Value of the +CMGS AT Command" of this SMS tutorial.
Multiple
SMS Messages in the Information Response
If
there are multiple SMS messages to be returned, the information
response of the +CMGL AT command will contain more than one "+CMGL:
...". Two characters, <CR><LF>, are
used to delimit two "+CMGL: ...". Here is an example for
illustration. Suppose the command line "AT+CMGL=4" (this
command line tells the GSM/GPRS modem or mobile phone to retrieve all
messages from message storage) is executed and three SMS messages are
listed. If all characters are shown, the command line and the
response returned will be displayed like this:
AT+CMGL=4<CR> <CR><LF>+CMGL:
...<CR><LF>+CMGL: ...<CR><LF>+CMGL:
...<CR><LF> <CR><LF>OK<CR><LF>
In
a terminal program such as HyperTerminal of Microsoft Windows, a
carriage return character causes the cursor to be moved to the
beginning of the current line, and a linefeed character causes the
cursor to be moved to the same position on the next line. Hence, the
above result will be displayed like this in a terminal program such
as HyperTerminal of Microsoft Windows:
AT+CMGL=4 +CMGL:
... +CMGL: ... +CMGL: ...
OK
Feedback Form (ExpandCollapse)
|
|