25.7. Example Demonstrating How to Use the +CMGS AT Command to Send SMS Text Messages in SMS PDU Mode
Now let's see a more detailed example that demonstrates how to use the +CMGS AT command to send SMS text messages in SMS PDU mode and how the +CMGS AT command should be used together with other AT commands.
Instructing the GSM/GPRS Modem or Mobile Phone to Operate in SMS PDU Mode
First, instruct the GSM/GPRS modem or mobile phone to operate in SMS PDU mode by entering the command line "AT+CMGF=0" in a terminal program (for example, HyperTerminal in Microsoft Windows). Below shows the response returned from Nokia 6021 to HyperTerminal after the execution of the command line "AT+CMGF=0":
The final result code OK indicates the +CMGF AT command was executed successfully. If the final result code ERROR is returned, it is likely that the GSM/GPRS modem or mobile phone does not support SMS PDU mode. To check whether the GSM/GPRS modem or mobile phone supports SMS PDU mode, enter the command line "AT+CMGF=?" in the terminal program. Here is the response returned from Nokia 6021 to HyperTerminal:
The values in the parentheses indicate the modes that the GSM/GPRS modem or mobile phone can operate in. The value 0 represents SMS PDU mode and the value 1 represents SMS text mode. From the above response, we know that Nokia 6021 can operate in either SMS PDU mode or SMS text mode. See the section titled "Selecting the Operating Mode (AT+CMGF)" of this SMS tutorial if you want to learn further details about the +CMGF AT command.
(Optional in SMS PDU Mode) Setting the SMSC Number to be Used to Send SMS Text Messages
Second, set the SMSC number to be used to send SMS text messages by the AT command +CSCA (command name in text: Service Centre Address). Usually the default setting is correct and you do not need to make any changes. In SMS PDU mode, you can skip this step since you can pass the SMSC number to the +CMGS AT command as a parameter. This is different from SMS text mode, in which the only way to set the SMSC number for sending SMS text messages is by using the +CSCA AT command.
Below demonstrates how to use the +CSCA AT command to set "+85290000000" as the SMSC number:
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.
Sending Text Messages
Third, use the +CMGS AT command to send a text message to the SMSC. Suppose you want to send the text message "It is easy to send text messages." to the mobile phone number +85291234567 through the SMS center at +85290000000, the hexadecimal sequence to be passed to the +CMGS AT command should be:
and the length of the SMS-SUBMIT TPDU embedded in the hexadecimal sequence is 42 octets. We have discussed how to obtain these values in previous sections and so we will not talk about them again here.
Now pass the length of the SMS-SUBMIT TPDU to the +CMGS AT command by entering the following command line in a terminal program:
Then, press the Enter key of the keyboard to send a carriage return character to the GSM/GPRS modem or mobile phone. The GSM/GPRS modem or mobile phone will send back a prompt formed by four characters. They are the carriage return character, the linefeed character, the ">" character and the space character. If all characters are to be displayed, the characters you have sent to and received from the GSM/GPRS modem or mobile phone so far are:
However, the carriage return character and linefeed character have special meanings to a terminal program. When a terminal program sees a carriage return character, it moves the cursor to the beginning of the current line. When it sees a linefeed character, it moves the cursor to the same position on the next line. So, here is what you will actually see in a terminal program such as HyperTerminal:
If you want to cancel the send command at this point, press the Esc key on the keyboard. The GSM/GPRS modem or mobile phone will then return the OK final result code. Here shows the response returned from Nokia 6021 (or Sony Ericsson T68i):
Some mobile devices return a slightly different response. One example is Philips 598:
If you do not want to cancel the send command, enter the hexadecimal sequence containing the SMS text message that you want to send from your computer / PC. When finished, press Ctrl+z on the keyboard. The GSM/GPRS modem or mobile phone then attempts to send the SMS text message to the SMSC and returns a response to the computer / PC. Below shows what you should see in a terminal program:
The value in the information response, 12, is the message reference number allocated to the SMS text message by the GSM/GPRS modem or mobile phone. The final result code OK indicates the sending of the SMS text message was successful. If the execution of the +CMGS AT command fails, the GSM/GPRS modem or mobile phone will return either the final result code ERROR or +CMS ERROR.
|Previous Page||Page 50 of 65||Next Page|
- 1. Introduction to SMS Messaging
- 2. What Makes SMS Messaging So Successful Worldwide?
- 3. Example Applications of SMS Messaging
- 4. What is an SMS Center / SMSC?
- 5. Basic Concepts of SMS Technology
- 6. Intra-operator SMS Messages
- 7. Inter-operator SMS Messages
- 8. International SMS Messages
- 9. What is an SMS Gateway?
- 10. How to Send SMS Messages from a Computer / PC?
- 11. How to Receive SMS Messages Using a Computer / PC?
- 12. Introduction to GSM / GPRS Wireless Modems
- 13. How to Use Microsoft HyperTerminal to Send AT Commands to a Mobile Phone or GSM/GPRS Modem?
- 14. Introduction to AT Commands
- 15. General Syntax of Extended AT Commands
- 16. Result Codes of AT Commands
- 17. AT Command Operations: Test, Set, Read and Execution
- 18. Testing the Communication between the PC and GSM/GPRS Modem or Mobile Phone
- 19. Checking if the GSM/GPRS Modem or Mobile Phone Supports the Use of AT Commands to Send, Receive and Read SMS Messages
- 20. Operating Mode: SMS Text Mode and SMS PDU Mode
- 21. Setting or Reading the Service Center Address / SMSC Address (AT+CSCA)
- 22. Preferred Message Storage (AT+CPMS)
- 23. Writing SMS Messages to Memory / Message Storage (AT+CMGW)
- 24. Deleting SMS Messages from Message Storage (AT+CMGD)
- 25. Sending SMS Messages from a Computer / PC Using AT Commands (AT+CMGS, AT+CMSS)
- 26. Reading SMS Messages from a Message Storage Area Using AT Commands (AT+CMGR, AT+CMGL)
- 27. Appendix A: How to Choose an SMS Service Provider (SMS Gateway Provider, SMS Reseller, SMS Broker)?
- 28. Appendix B: Comparison Table of SMS Service Providers (SMS Gateway Providers, SMS Resellers, SMS Brokers)
- 29. Appendix C: Free Software/Tools and Libraries for Sending and Receiving SMS Messages with a Computer / PC
- 30. Appendix D: GSM 7-bit Default Alphabet Table (with Character Codes of ISO 8859 Latin 1)