25.5. Syntax of the +CMGS AT Command in SMS PDU Mode

In SMS PDU mode, the syntax of the +CMGS AT command is:


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


The TPDU_length Parameter

The first parameter of the +CMGS 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 <CR> Character

<CR>, which represents the carriage return character, follows the TPDU_length 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 +CMGS AT Command to Send SMS Text Messages in SMS PDU Mode".


The SMSC_number_and_TPDU Parameter

The second parameter of the +CMGS 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 +CMGS AT Command to Send SMS Text Messages in SMS PDU Mode".


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 send the SMS message to the SMS center.


25.5.1. Some Explanation about the Coding of the SMSC_number_and_TPDU Parameter Value of the +CMGS AT Command

This section provides some explanation about the coding of the SMSC_number_and_TPDU parameter value of the +CMGS AT command. Let's consider the SMSC_number_and_TPDU parameter value in the earlier example command line:


07915892000000F001000B915892214365F7000021493A283D0795C3F33C88FE06CDCB6E32885EC6D341EDF27C1E3E97E72E


The above value can be divided into two parts, as shown below. The first part contains information about the SMSC to be used for sending the SMS message. The second part is the TPDU.


07915892000000F0

01000B915892214365F7000021493A283D0795C3F33C88FE06CDCB6E32885EC6D341EDF27C1E3E97E72E


25.5.1.1. The SMSC Part

The SMSC part can be further divided into three sub-fields, like this:


07 91 5892000000F0


The First Sub-field: Length of the Second and Third Sub-fields

The first sub-field specifies the length in octets of the following two sub-fields. There are 14 hexadecimal digits in "915892000000F0" and each hexadecimal digit represents 4 bits. So, there are totally 7 octets. That's why the value of the first sub-field is 0x07.


The Second Sub-field: Type of SMSC Number

The second sub-field specifies the type of the SMSC number assigned to the third sub-field. Two values are commonly used. They are 0x81 (129 in decimal) and 0x91 (145 in decimal):


The Third Sub-field: SMSC Number

The third sub-field specifies the SMSC number for sending the SMS message. 0x5892000000F0 represents the phone number +85290000000. Here's how the value 0x5892000000F0 is obtained:

  1. Starting from the left, group the digits of the phone number 85290000000 into pairs, like this: 85 29 00 00 00 0.

  2. As the last group has only one digit, we add an "F" to make up a pair. The result is 85 29 00 00 00 0F.

  3. Swap the digits in each pair and you will get 58 92 00 00 00 F0.


Note

It is possible to tell the GSM/GPRS modem or mobile phone to use the SMSC number specified by the AT command +CSCA (command name in text: Service Centre Address) for sending SMS messages. Just assign the value 0x00 to the first sub-field and omit the second and third sub-fields, i.e. the SMSC part becomes:


00


25.5.1.2. The TPDU Part (SMS-SUBMIT TPDU)

The TPDU part can be divided into nine sub-fields, as shown below. This is a TPDU of the type SMS-SUBMIT.


01 00 0B 91 5892214365F7 00 00 21 493A283D0795C3F33C88FE06CDCB6E32885EC6D341EDF27C1E3E97E72E


The First Sub-field: First Octet of the TPDU

The first sub-field is the first octet of the TPDU. It tells the GSM/GPRS modem or mobile phone several things:

The value 0x01 means:


The Second Sub-field: Message Reference Number

The second sub-field specifies the message reference number. It is an integer in the range from 0 to 255. The value 0x00 tells the GSM/GPRS modem or mobile phone to assign a message reference number to the SMS message automatically.


The Third Sub-field: Length of the Destination Phone Number

The third sub-field specifies the length in digits of the destination phone number. The destination phone number specified in the fifth sub-field is "+85291234567", which has 11 digits. Thus, the value of the third sub-field is 0x0B (i.e. 11 in decimal).


The Fourth Sub-field: Type of the Destination Phone Number

The fourth sub-field specifies the type of the destination phone number assigned to the fifth sub-field. Two values are commonly used. They are 0x81 (129 in decimal) and 0x91 (145 in decimal):


The Fifth Sub-field: Destination Phone Number

The fifth sub-field specifies the destination phone number. The value 0x5892214365F7 represents the phone number +85291234567. Here's how the value 0x5892214365F7 is obtained:


The Sixth Sub-field: Protocol Identifier

The sixth sub-field specifies the protocol identifier. Its value should be 0x00 for normal cases.


The Seventh Sub-field: Data Coding Scheme

The seventh sub-field specifies the data coding scheme. With 0x00, we inform the GSM/GPRS modem or mobile phone that the text in the SMS message body is encoded according to the "GSM 7-bit default alphabet" text coding scheme.


The Eighth Sub-field: Length of the SMS Message Body

The eighth sub-field specifies the length of the SMS message body in septets (1 septet = 7 bits). The value 0x21 means there are 33 septets (or characters, since each character is represented by 7 bits according to the "GSM 7-bit default alphabet" text coding scheme) in the SMS message body.


The Ninth Sub-field: SMS Message Body

The ninth sub-field specifies the SMS message body. The value 0x493A283D0795C3F33C88FE06CDCB6E32885EC6D341EDF27C1E3E97E72E represents the text message "It is easy to send text messages.". Below shows how the hexadecimal value is obtained:



Bit 7

Bit 6

Bit 5

Bit 4

Bit 3

Bit 2

Bit 1

Bit 0



Octet 1

0

1

0

0

1

0

0

1

=

0x49

Octet 2

0

0

1

1

1

0

1

0

=

0x3A

Octet 3

0

0

1

0

1

0

0

0

=

0x28

Octet 4

0

0

1

1

1

1

0

1

=

0x3D

Octet 5

0

0

0

0

0

1

1

1

=

0x07

Octet 6

1

0

0

1

0

1

0

1

=

0x95

Octet 7

1

1

0

0

0

0

1

1

=

0xC3

Octet 8

1

1

1

1

0

0

1

1

=

0xF3

Octet 9

0

0

1

1

1

1

0

0

=

0x3C

Octet 10

1

0

0

0

1

0

0

0

=

0x88

Octet 11

1

1

1

1

1

1

1

0

=

0xFE

Octet 12

0

0

0

0

0

1

1

0

=

0x06

Octet 13

1

1

0

0

1

1

0

1

=

0xCD

Octet 14

1

1

0

0

1

0

1

1

=

0xCB

Octet 15

0

1

1

0

1

1

1

0

=

0x6E

Octet 16

0

0

1

1

0

0

1

0

=

0x32

Octet 17

1

0

0

0

1

0

0

0

=

0x88

Octet 18

0

1

0

1

1

1

1

0

=

0x5E

Octet 19

1

1

0

0

0

1

1

0

=

0xC6

Octet 20

1

1

0

1

0

0

1

1

=

0xD3

Octet 21

0

1

0

0

0

0

0

1

=

0x41

Octet 22

1

1

1

0

1

1

0

1

=

0xED

Octet 23

1

1

1

1

0

0

1

0

=

0xF2

Octet 24

0

1

1

1

1

1

0

0

=

0x7C

Octet 25

0

0

0

1

1

1

1

0

=

0x1E

Octet 26

0

0

1

1

1

1

1

0

=

0x3E

Octet 27

1

0

0

1

0

1

1

1

=

0x97

Octet 28

1

1

1

0

0

1

1

1

=

0xE7

Octet 29

0

0

1

0

1

1

1

0

=

0x2E



Previous Page Page 48 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