23.5. Syntax of the +CMGW AT Command in SMS PDU Mode

In SMS PDU mode, the syntax of the +CMGW AT command is: (Optional parameters are enclosed in square brackets.)


+CMGW=TPDU_length[,message_status]<CR>SMSC_number_and_TPDU<Ctrl+z>


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=42,2<CR>07915892000000F001000B915892214365F7000021493A283D0795C3F33C88FE06CDCB6E32885EC6D341EDF27C1E3E97E72E<Ctrl+z>


The TPDU_length Parameter

The first parameter of the +CMGW AT command, TPDU_length, specifies the length (in octets. 1 octet = 8 bits) of the TPDU (Transfer Protocol Data Unit) assigned to the SMSC_number_and_TPDU parameter. In the earlier example command line, the value assigned to the SMSC_number_and_TPDU parameter is:


07915892000000F001000B915892214365F7000021493A283D0795C3F33C88FE06CDCB6E32885EC6D341EDF27C1E3E97E72E


It can be divided into two parts. The following part is the TPDU:


01000B915892214365F7000021493A283D0795C3F33C88FE06CDCB6E32885EC6D341EDF27C1E3E97E72E


The TPDU is coded in hexadecimal format. Each character represents 4 bits, i.e. 1/2 octet. The TPDU has 84 characters and so there are totally 42 octets. That's why the value assigned to the TPDU_length parameter is 42.


The message_status Parameter

The second parameter of the +CMGW AT command, message_status, specifies the status of the SMS message to be written. The SMS specification has defined four status values:

As message_status is an optional parameter, it can be omitted. If you do so, the GSM/GPRS modem or mobile phone will use the default value of the message_status parameter, which is 2.

Note: To some mobile devices (for example, Sony Ericsson T68i and Philips 598), an error will occur if the TPDU type is SMS-SUBMIT and the message_status parameter value is 0 or 1, or if the TPDU type is SMS-DELIVER and the message_status parameter value is 2 or 3.


The <CR> Character

<CR>, 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. If you don't understand what this means, don't worry. This should be clear to you when you see the example in the section "Example Demonstrating How to Use the +CMGW AT Command to Write SMS Text Messages to Message Storage in SMS PDU Mode".


The SMSC_number_and_TPDU Parameter

The third parameter of the +CMGW AT command, SMSC_number_and_TPDU, specifies the SMSC number and the TPDU in hexadecimal format. Entering the <Esc> character will cancel the +CMGS AT command. If you don't understand what this means, see the example in the section "Example Demonstrating How to Use the +CMGW AT Command to Write SMS Text Messages to Message Storage in SMS PDU Mode".

In the earlier example command line, the value assigned to the SMSC_number_and_TPDU parameter is:


07915892000000F001000B915892214365F7000021493A283D0795C3F33C88FE06CDCB6E32885EC6D341EDF27C1E3E97E72E


Here is some of the information encoded in the above hexadecimal sequence:

If you want to learn how the hexadecimal sequence is coded, please go 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.

Besides the TPDU type SMS-SUBMIT, the +CMGW AT command accepts other TPDU types such as SMS-DELIVER.


The <Ctrl+z> Character

When you finish entering the value for the SMSC_number_and_TPDU parameter, you have to enter the <Ctrl+z> character to mark the end of the value. The GSM/GPRS modem or mobile phone will then attempt to write the SMS message to the message storage area.


23.6. SMSC Number Stored with the SMS Message (SMS PDU Mode)

In SMS PDU mode, you can specify an SMSC number to the +CMGW AT command through the SMSC_number_and_TPDU parameter. If no SMSC number is specified, the GSM/GPRS modem or mobile phone retrieves the SMSC number specified by the +CSCA AT command (command name in text: Service Centre Address) and stores it with the SMS message. Later if you send the SMS message, it will be transmitted through this SMSC. Once an SMS message has been written to message storage, it is not possible to change the SMSC number stored with the SMS message by using AT commands.

Note that it is possible that the command behavior on your mobile device is slightly different from what was described above.

More information about this issue is available in the "SMSC Number to be Used by the +CMSS AT Command to Send SMS Messages" section of this SMS tutorial.


23.7. Format of the Information Response of the +CMGW AT Command in SMS PDU Mode

If the GSM/GPRS modem or mobile phone writes the SMS message to the message storage area successfully, it will return an information response to the computer / PC. In SMS PDU mode, the information response of the +CMGW AT command has the following format:


+CMGW: index


Here is an example that gives you some idea of how an actual information response should look like:


+CMGW: 5


The index Field

The information response of the +CMGW AT command has only one field called index. The field contains an integer that tells us the memory location to which the SMS message was written in the message storage area.


Previous Page Page 41 of 65 Next Page

Contents at a Glance (Click Here for Full Table of Contents)

Feedback Form (ExpandCollapse)

What do you think about this web page?






(Optional) Please provide us more details. For example, suppose you select option 2 above, can you tell us specifically what information is missing? You can also suggest anything that can help us improve this web page.

(Optional) Your name:

(Optional) Your email address:

Please enter again to confirm:

Due to the amount of messages we received, we may not be able to reply to all messages.

A button for going back to the top of this page