25.11. Example Demonstrating How to Use the +CMSS AT Command to Send Text Messages from a Message Storage Area (SMS Text Mode and SMS PDU Mode)

Now let's see a more detailed example that demonstrates how to use the +CMSS AT command to send text messages from a message storage area and how the +CMSS AT command should be used together with other AT commands. Since the syntax of the +CMSS AT command is the same in both SMS text mode and SMS PDU mode, the information provided below applies to both modes.


Selecting the Message Storage Area to Write Text Messages to and Send Text Messages from

First, use the +CPMS AT command (command name in text: Preferred Message Storage) to select the message storage area to write text messages to (+CMGW AT command) and send text messages from (+CMSS AT command). For example, to use the message storage area in the SIM card for writing and sending SMS text messages, assign the string value "SM" to the second parameter of the +CPMS AT command, like this:


AT+CPMS="ME","SM"


The first parameter of the +CPMS AT command is used to select the message storage area for reading and deleting SMS messages. It has no use to us here. So, it does not matter what value is assigned to the first parameter.

Now press the Enter key on the keyboard and you should see something similar to this:


AT+CPMS="ME","SM"
+CPMS: 2,150,2,10,4,160

OK


Detailed information about the +CPMS AT command is available in the "Preferred Message Storage (AT+CPMS)" section of this SMS tutorial.


Setting the SMSC Number to be Used to Send SMS Text Messages

Second, use the AT command +CSCA (command name in text: Service Centre Address) to set the SMSC number to be used to send SMS text messages. Usually the default setting is correct and you do not need to make any changes. Below demonstrates how to use the +CSCA AT command to set "+85290000000" as the SMSC number:


AT+CSCA="+85290000000"
OK


Detailed information about the +CSCA AT command can be found in the "Setting or Reading the Service Center Address / SMSC Address (AT+CSCA)" section of this SMS tutorial.


Writing Text Messages

Third, use the +CMGW AT command (command line in text: Write Message to Memory) to write the text message to message storage. Suppose the recipient mobile phone number is +85291234567. If the GSM/GPRS modem or mobile phone is operating in SMS text mode, you should enter something like this in the terminal program and press the Enter key of the keyboard:


AT+CMGW="+85291234567"


The GSM/GPRS modem or mobile phone will return a prompt, as shown below:


AT+CMGW="+85291234567"


Now enter the body of the SMS text message "It is easy to send text messages." and press Ctrl+z on the keyboard to finish. You should see something like this in the terminal program:


AT+CMGW="+85291234567"
> It is easy to send text messages.
+CMGW: 3

OK


The value 3 in the +CMGW information response is the index that specifies the location where the text message is stored in the message storage area. Later, we have to use this index to tell the +CMSS AT command which text message should be sent.

If the GSM/GPRS modem or mobile phone is operating in SMS PDU mode, here's what you should type and see in the terminal program:

AT+CMGW=42
> 0001000B915892214365F7000021493A283D0795C3F33C88FE06CDCB6E32885EC6D341EDF27C1E3E97E72E
+CMGW: 3

OK


For further details the +CMGW AT command, please refer to the earlier section "Writing SMS Messages to Memory / Message Storage (AT+CMGW)" of this SMS tutorial.


Sending Text Messages from Message Storage

Fourth, specify the index "3" to the +CMSS AT command to send the text message out:


AT+CMSS=3
+CMSS: 20

OK


"20" is the message reference number allocated by the GSM/GPRS modem or mobile phone to the text message. The final result code OK indicates the text message was sent to the SMSC successfully. If the execution of the AT command +CMSS fails, the GSM/GPRS modem or mobile phone will return either the final result code ERROR or +CMS ERROR.

In the above example, the address parameter of the AT command +CMSS is omitted. Thus, the mobile phone number stored with the SMS text message (i.e. +85291234567) will be used as the destination address. Suppose you want to send the text message to another mobile phone number, say +85298765432, you should assign "+85298765432" to the address parameter of +CMSS, as shown below:


AT+CMSS=3,"+85298765432"
+CMSS: 21

OK


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