You are on page 1of 13

AT commands are instructions used to control a modem. AT is the abbreviation of ATtention.

Every command line starts with "AT" or "at". That's why modem commands are called AT commands. Many of the commands that are used to control wired dial-up modems, such as ATD (Dial), ATA (Answer), ATH (Hook control) and ATO (Return to online data state), are also supported by GSM/GPRS modems and mobile phones. Besides this common AT command set, GSM/GPRS modems and mobile phones support an AT command set that is specific to the GSM technology, which includes SMS-related commands like AT+CMGS (Send SMS message), AT+CMSS (Send SMS message from storage), AT+CMGL (List SMS messages) and AT+CMGR (Read SMS messages). Note that the starting "AT" is the prefix that informs the modem about the start of a command line. It is not part of the AT command name. For example, D is the actual AT command name in ATD and +CMGS is the actual AT command name in AT+CMGS. However, some books and web sites use them interchangeably as the name of an AT command. Here are some of the tasks that can be done using AT commands with a GSM/GPRS modem or mobile phone: Get basic information about the mobile phone or GSM/GPRS modem. For example, name of manufacturer (AT+CGMI), model number (AT+CGMM), IMEI number (International Mobile Equipment Identity) (AT+CGSN) and software version (AT+CGMR). Get basic information about the subscriber. For example, MSISDN (AT+CNUM) and IMSI number (International Mobile Subscriber Identity) (AT+CIMI). Get the current status of the mobile phone or GSM/GPRS modem. For example, mobile phone activity status (AT+CPAS), mobile network registration status (AT+CREG), radio signal strength (AT+CSQ), battery charge level and battery charging status (AT+CBC). Establish a data connection or voice connection to a remote modem (ATD, ATA, etc). Send and receive fax (ATD, ATA, AT+F*). Send (AT+CMGS, AT+CMSS), read (AT+CMGR, AT+CMGL), write (AT+CMGW) or delete (AT+CMGD) SMS messages and obtain notifications of newly received SMS messages (AT+CNMI). Read (AT+CPBR), write (AT+CPBW) or search (AT+CPBF) phonebook entries. Perform security-related tasks, such as opening or closing facility locks (AT+CLCK), checking whether a facility is locked (AT+CLCK) and changing passwords (AT+CPWD). (Facility lock examples: SIM lock [a password must be given to the SIM card every time the mobile phone is switched on] and PH-SIM lock [a certain SIM card is associated with the mobile phone. To use other SIM cards with the mobile phone, a password must be entered.]) Control the presentation of result codes / error messages of AT commands. For example, you can control whether to enable certain error messages (AT+CMEE) and whether error messages should be displayed in numeric format or verbose format (AT+CMEE=1 or AT+CMEE=2). Get or change the configurations of the mobile phone or GSM/GPRS modem. For example, change the GSM network (AT+COPS), bearer service type (AT+CBST), radio link protocol parameters (AT+CRLP), SMS center address (AT+CSCA) and storage of SMS messages (AT+CPMS). Save and restore configurations of the mobile phone or GSM/GPRS modem. For example, save (AT+CSAS) and restore (AT+CRES) settings related to SMS messaging such as the SMS center address.

Note that mobile phone manufacturers usually do not implement all AT commands, command parameters and parameter values in their mobile phones. Also, the behavior of the implemented AT commands may be different from that defined in the standard. In general, GSM/GPRS modems designed for wireless applications have better support of AT commands than ordinary mobile phones. In addition, some AT commands require the support of mobile network operators. For example, SMS over GPRS can be enabled on some GPRS mobile phones and GPRS modems with the +CGSMS command

(command name in text: Select Service for MO SMS Messages). But if the mobile network operator does not support the transmission of SMS over GPRS, you cannot use this feature.

14.1. Basic Commands and Extended Commands


There are two types of AT commands: basic commands and extended commands. Basic commands are AT commands that do not start with "+". For example, D (Dial), A (Answer), H (Hook control) and O (Return to online data state) are basic commands. Extended commands are AT commands that start with "+". All GSM AT commands are extended commands. For example, +CMGS (Send SMS message), +CMSS (Send SMS message from storage), +CMGL (List SMS messages) and +CMGR (Read SMS messages) are extended commands.

2. What Makes SMS Messaging So Successful Worldwide?


2.1. SMS Messages can be Sent and Read at Any Time
Nowadays, almost every person has a mobile phone and carries it most of the time. With a mobile phone, you can send and read SMS messages at any time, no matter you are in your office, on a bus or at home.

2.2. SMS Messages can be Sent to an Offline Mobile Phone


Unlike a phone call, you can send an SMS message to your friend even when he/she has not switched on the mobile phone or when he/she is in a place where the wireless signal is temporarily unavailable. The SMS system of the mobile network operator will store the SMS message and later send it to your friend when his/her mobile phone is online.

2.3. SMS Messaging is Less Disturbing While You can Still Stay in Touch

Unlike a phone call, you do not need to read or reply an SMS message immediately. Besides, writing and reading SMS messages do not make any noise. While you have to run out of a theater or library to answer a phone call, you do not need to do so if SMS messaging is used.

2.4. SMS Messages are Supported by 100% GSM Mobile Phones and They can be Exchanged between Different Wireless Carriers
SMS messaging is a very mature technology. All GSM mobile phones support it. Not only that you can exchange SMS messages with mobile users of the same wireless carrier, but you can also exchange SMS messages with mobile users of many other wireless carriers worldwide.

2.5. SMS is a Suitable Technology for Wireless Applications to Build on


Here are some of the reasons that make SMS a suitable technology for wireless applications to build on: Firstly, SMS messaging is supported by 100% GSM mobile phones. Building wireless applications on top of the SMS technology can maximize the potential user base. Secondly, SMS messages are capable of carrying binary data besides text. They can be used to transfer ringtones, pictures, operator logos, wallpapers, animations, VCards, VCals (calendar entries), etc. Thirdly, SMS supports reverse billing, which enables payment to be made conveniently. For example, suppose you want to develop a commercial ringtone download application that charges a fee from the user for each ringtone downloaded. One way to accept payment is to use a reverse billing phone number obtained from a wireless carrier. To buy a ringtone, the user will write an ordinary SMS text message that contains the ID of the ringtone he/she wants to buy and send it to your SMS application's reverse billing phone number. Your SMS application will then send back one or more reverse billing SMS messages that carry the ringtone. The user will be charged a fee for the reverse billing SMS messages he/she received. The fee will be included in the user's monthly mobile phone bill or be deducted from his/her prepaid card credits. Depending on the agreement between you and the wireless carrier, all or part of the money received will be given to you.

SMS stands for Short Message Service. It is a technology that enables the sending and receiving of messages between mobile phones. SMS first appeared in Europe in 1992. It was included in the GSM (Global System for Mobile Communications) standards right at the beginning. Later it was ported to wireless technologies like CDMA and TDMA. The GSM and SMS standards were originally developed byETSI. ETSI is the abbreviation for European Telecommunications Standards Institute. Now the 3GPP(Third Generation Partnership Project) is responsible for the development and maintenance of the GSM and SMS standards. As suggested by the name "Short Message Service", the data that can be held by an SMS message is very limited. One SMS message can contain at most 140 bytes (1120 bits) of data, so one SMS message can contain up to: 160 characters if 7-bit character encoding is used. (7-bit character encoding is suitable for encoding Latin characters like English alphabets.) 70 characters if 16-bit Unicode UCS2 character encoding is used. (SMS text messages containing non-Latin characters like Chinese characters should use 16-bit character encoding.)

SMS text messaging supports languages internationally. It works fine with all languages supported by Unicode, including Arabic, Chinese, Japanese and Korean. Besides text, SMS messages can also carry binary data. It is possible to send ringtones, pictures, operator logos, wallpapers, animations, business cards (e.g. VCards) and WAP configurations to a mobile phone with SMS messages. One major advantage of SMS is that it is supported by 100% GSM mobile phones. Almost all subscription plans provided by wireless carriers include inexpensive SMS messaging service. Unlike SMS, mobile technologies such as WAP and mobile Java are not supported on many old mobile phone models.

1.2. Concatenated SMS Messages / Long SMS Messages


One drawback of the SMS technology is that one SMS message can only carry a very limited amount of data. To overcome this drawback, an extension called concatenated SMS (also known as long SMS) was developed. A concatenated SMS text message can contain more than 160 English characters. Concatenated SMS works like this: The sender's mobile phone breaks down a long message into smaller parts and sends each of them as a single SMS message. When these SMS messages reach the destination, the recipient mobile phone will combine them back to one long message. The drawback of concatenated SMS is that it is less widely supported than SMS on wireless devices.

1.3. EMS (Enhanced Messaging Service)


Besides the data size limitation, SMS has another major drawback -- an SMS message cannot include rich-media content such as pictures, animations and melodies. EMS (Enhanced Messaging Service) was developed in response to this. It is an application-level extension of SMS. An EMS message can include pictures, animations and melodies. Also, the formatting of the text inside an EMS message is changeable. For example, the message sender can specify whether the text in an EMS message should be displayed in bold or italic, with a large font or a small font.

The drawback of EMS is that it is less widely supported than SMS on wireless devices. Also, many EMSenabled wireless devices only support a subset of the features defined in the EMS specification. A certain EMS feature may be supported on one wireless device but not on the other.

3. Example Applications of SMS Messaging


Preferences - Do not show ads There are many different kinds of SMS applications on the market today and many others are being developed. Applications in which SMS messaging can be utilized are virtually unlimited. We will describe some common examples of SMS applications below to give you some ideas of what can be done with SMS messaging.

3.1. Person-to-Person Text Messaging


Person-to-person text messaging is the most commonly used SMS application and it is what the SMS technology was originally designed for. In these kinds of text messaging applications, a mobile user types an SMS text message using the keypad of his/her mobile phone, then he/she inputs the mobile phone number of the recipient and clicks a certain option on the screen, such as "Send" or "OK", to send the text message out. When the recipient mobile phone receives the SMS text message, it will notify the user by giving out a sound or vibrating. The user can read the SMS text message some time later or immediately and can send a text message back if he/she wants. A chat application is another kind of person-to-person text messaging application that allows a group of people to exchange SMS text messages interactively. In a chat application, all SMS text messages sent and received are displayed on the mobile phone's screen in order of date and time. SMS text messages written by different mobile users may be displayed in different colors for better readability, like this:

Me: Let's have a meeting at 10 am tomorrow to discuss the details of our next SMS text messaging application. Tom: OK. Alan: I have another meeting at 10 am. I suggest having the meeting at 11:30 am tomorrow. What do you think?

3.2. Provision of Information


A popular application of the SMS technology other than person-to-person text messaging is the provision of information to mobile users. Many content providers make use of SMS text messages to send information such as news, weather report and financial data to their subscribers. Many of these information services are not free. Reverse billing SMS is a common way used by content providers to bill their users. The user is charged a certain fee for each reverse billing SMS message received. The fee will either be included in the monthly mobile phone bill or be deducted from prepaid card credits.

3.3. Downloading
SMS messages can carry binary data and so SMS can be used as the transport medium of wireless downloads. Objects such as ringtones, wallpapers, pictures and operator logos can be encoded in one or more SMS messages depending on the object's size. Like information services, wireless download services are usually not free and reverse billing SMS is a common way used by content providers to bill their customers. The object to be downloaded is encoded in one or more reverse billing SMS messages. The mobile user who requests the object will be charged a certain fee for each reverse billing SMS message received. If the mobile user is using a monthly mobile phone service plan, the download fee will be included in his/her next monthly bill; if the mobile user is using a prepaid SIM card, the download fee will be deducted from the prepaid credits.

3.4. Alerts and Notifications


SMS is a very suitable technology for delivering alerts and notifications of important events. This is because of two reasons: 1. A mobile phone is a device that is carried by its owner most of the time. Whenever an SMS text message is received, the mobile phone will notify you by giving out a sound or by vibrating. You can check what the SMS text message contains immediately. 2. SMS technology allows the "push" of information. This is different from the "pull" model where a device has to poll the server regularly in order to check whether there is any new information. The "pull" model is less suitable for alert and notification applications, since it wastes bandwidth and increases server load. Some common examples of SMS alert and notification applications are described below.

3.4.1. Email, Fax and Voice Message Notifications


In an email notification system, a server sends a text message to the user's mobile phone whenever an email arrives at the inbox. The SMS text message can include the sender's email address, the subject and the first few lines of the email body. An email notification system may allow the user to customize various filters so that an SMS alert is sent only if the email message contains certain keywords or if the email sender is an important person. The use cases for fax or voice message are similar.

3.4.2. E-commerce and Credit Card Transaction Alerts


Whenever an e-commerce or credit card transaction is made, the server sends a text message to the user's mobile phone. The user can know immediately whether any unauthorized transactions have been made.

3.4.3. Stock Market Alerts


In a stock market alert application, a program is constantly monitoring and analyzing the stock market. If a certain condition is satisfied, the program will send a text message to the user's mobile phone to notify him/her of the situation. For example, you can configure the alert system such that if the stock price of a company is lower than a certain value or drops by a certain percentage, it will send an SMS alert to you.

3.4.4. Remote System Monitoring


In a remote system monitoring application, a program (sometimes with the help of a group of sensors) is constantly monitoring the status of a remote system. If a certain condition is satisfied, the program will send a text message to the system administrator to notify him/her of the situation. For example, a program may be written to "ping" a server regularly. If no response is received from the server, the program can send an SMS alert to the system administrator to notify him/her that the server may be hanged.

3.5. Two-way Interactive Text Messaging Applications


SMS messaging technology can be used as the underlying communication medium between wireless devices and servers in a two-way interactive text messaging application. For example, search engines are two-way interactive text messaging applications. Let's say there is a dictionary search engine that supports queries in SMS text messages. It may operate like this: To find out the meaning of the term "SMS text messaging", you can type "find: SMS text messaging" in an SMS text message and send it to the search engine's phone number. After receiving your SMS text message, the search engine parses it and finds that it begins with the command "find" and follows by the words "SMS text messaging". The search engine then knows you want to find out the meaning of the term "SMS text messaging". So, it sends a text message, which contains the meaning of the term "SMS text messaging", back to your mobile phone. If the search result is very long and it cannot contain within a single SMS text message, the search engine adds "Page 1 of 2", "Page 1 of 3", etc, at the end of the reply SMS text message. The search engine also creates a session using your mobile phone number as the session ID and stores the term that you searched for (i.e. "SMS text messaging") in the session object. To request the second page, you can send a text message with the content "page: 2" to the search engine's phone number. After receiving your SMS text message, the search engine parses it and finds that it begins with the command "page" and follows by "2". The search engine then knows you want the second page of the search result. It retrieves the term that you searched for last time from the session object and finds that it is "SMS text messaging". The search engine

then sends a text message that contains the second page of the search result for the term "SMS text messaging" back to your mobile phone. Many other two-way interactive text messaging applications can be built using a similar way. For example, a company may want to build an SMS messaging application to enable its employees to query the corporate database while they are working outdoors.

3.6. SMS Marketing


SMS messaging can be used as a marketing tool. An example is an SMS newsletter system. After signing up, the user will receive SMS text messages about the latest discounts and products of the company. If the user has any questions or comments, he/she can send a text message back with the questions or comments in it. The company may include its phone number in the SMS newsletter so that the user can talk to the customer service staff directly if he/she wants to do so.

An SMS center (SMSC) is responsible for handling the SMS operations of a wireless network. When an SMS message is sent from a mobile phone, it will reach an SMS center first. The SMS center then forwards the SMS message towards the destination. An SMS message may need to pass through more than one network entity (e.g. SMSC and SMS gateway) before reaching the destination. The main duty of an SMSC is to route SMS messages and regulate the process. If the recipient is unavailable (for example, when the mobile phone is switched off), the SMSC will store the SMS message. It will forward the SMS message when the recipient is available. Very often an SMSC is dedicated to handle the SMS traffic of one wireless network. A network operator usually manages its own SMSC(s) and locates them inside its wireless network system. However, it is possible for a network operator to use a third-party SMSC that is located outside the wireless network system. You must know the address of the wireless network operator's SMSC in order to use SMS messaging with your mobile phone. Typically an SMSC address is an ordinary phone number in the international format. A mobile phone should have a menu option that can be used to configure the SMSC address. Normally, the SMSC address is pre-set in the SIM card by the wireless network operator, which means you do not need to make any changes to it.

One problem of SMS messaging is that SMSCs developed by different companies use their own communication protocol and most of these protocols are proprietary. For example, Nokia has an SMSC protocol called CIMD whereas another SMSC vendor, CMG, has an SMSC protocol called EMI. We cannot connect two SMSCs if they do not support a common SMSC protocol. To deal with this problem, an SMS gateway is placed between two SMSCs. This is illustrated in the following figure. The SMS gateway acts as a relay between the two SMSCs. It translates one SMSC protocol to another one. This way can be used by two different wireless carriers to interconnect their SMSCs for purposes such as enabling the exchange of inter-operator SMS messages.

Figure 1. An SMS gateway acts as a relay between two SMS centers.

Besides wireless carriers, content providers and SMS application developers may also find an SMS gateway useful. Let's consider the following situation. Suppose you are the developer of an SMS text messaging application. To send and receive SMS text messages on your server, one way is to connect to the SMSCs of the wireless carriers. Different wireless carriers may use SMSCs from different vendors, which means your SMS text messaging application may need to support multiple SMSC-specific protocols. (This is illustrated in the following figure). As a result, the SMS text messaging application's complexity and development time increases.

Figure 2. An SMS text messaging application connects to SMSCs without an SMS gateway.

To deal with the above problem, an SMS gateway can be set up to handle the connections to the SMSCs. Now the SMS text messaging application only needs to know how to connect to the SMS gateway. To support more SMSCs, you just need to modify the settings of the SMS gateway. No change to the source code of the SMS text messaging application is required. The use of an SMS gateway can greatly shorten the SMS text messaging application's development time. To connect to an SMS gateway, you can use an SMSC protocol such as SMPP and CIMD. Some SMS gateways support an HTTP / HTTPS interface. HTTP / HTTPS is easier to use than SMSC protocols. The drawback is that there may be fewer SMS features to use. For example, an SMS gateway may not support the sending of picture messages through the HTTP / HTTPS interface.

Figure 3. An SMS text messaging application connects to SMSCs through an SMS gateway.

Besides using a direct connection to the SMSC of a wireless carrier, another way to send and receive SMS text messages on a computer is to use a mobile phone or GSM/GPRS modem. To do this, your SMS text messaging application has to know how to communicate with the mobile phone or GSM/GPRS modem using AT commands. Some SMS gateways are capable of handling the connections to mobile phones and GSM/GPRS modems. To send and receive SMS text messages with a mobile phone or GSM/GPRS modem, the SMS text messaging application only needs to know how to talk to the SMS gateway and does not need to know anything about AT commands. More details about GSM/GPRS modems and AT commands will be provided in later sections of this SMS tutorial.

Figure 4. An SMS text messaging application connects to a pool of mobile phones or GSM/GPRS modems through an SMS gateway.

9.1. Open Source and Free SMS Gateway Software


As you can see in the above sections, an SMS gateway has a lot of responsibilities in an SMS messaging system. So, SMS gateway software can be very complex and complex software is usually expensive. Fortunately, there are open source SMS gateway software packages that can be downloaded free of charge over the web. One high-quality free SMS gateway software package is Kannel, which is written in the C programming language. Kannel can handle connections to SMSCs, mobile phones and GSM/GPRS modems. It has an HTTP / HTTPS interface for the sending and receiving of SMS messages. More information about Kannel can be found on its web site http://www.kannel.org/.

5.1. Validity Period of an SMS Message


An SMS message is stored temporarily in the SMS center if the recipient mobile phone is offline. It is possible to specify the period after which the SMS message will be deleted from the SMS center so that the SMS message will not be forwarded to the recipient mobile phone when it becomes online. This period is called the validity period. Here is an example that illustrates how validity period can be used. Suppose you find a very interesting program that is showing on TV now. You think your friend may want to watch it. So, you send a text message to tell your friend about the TV program. Let's say the TV program lasts for an hour. Your SMS text message will not be useful to your friend if his mobile phone is not available before the program finishes. In this situation, you may want to send a text message with a validity period of one hour to your friend. The wireless carrier will not deliver the SMS text message to your friend if his mobile phone is not available before the validity period ends. A mobile phone should have a menu option that can be used to set the validity period. After setting it, the mobile phone will include the validity period in the outbound SMS messages automatically.

5.2. Message Status Reports


Sometimes you may want to know whether an SMS message has reached the recipient mobile phone successfully. To get this information, you need to set a flag in the SMS message to notify the SMS center that you want a status report about the delivery of this SMS message. The status report is sent to you in the form of an SMS message. A mobile phone should have a menu option that can be used to set whether the status report feature is on or off. After setting it, the mobile phone will set the corresponding flag in the outbound SMS messages for you automatically. The status report feature is turned off by default on most mobile phones and GSM / GPRS modems.

5.3. Message Submission Reports


After leaving the mobile phone, an SMS message goes to the SMS center. When it reaches the SMS center, the SMS center will send back a message submission report to the mobile phone to inform whether there are any errors or failures (e.g. incorrect SMS message format, busy SMS center, etc). If there is no error or failure, the SMS center sends back a positive submission report to the mobile phone. Otherwise it sends back a negative submission report to the mobile phone. The mobile phone may then notify the user that the message submission was failed and what caused the failure. If the mobile phone does not receive the message submission report after a period of time, it concludes that the message submission report has been lost. The mobile phone may then re-send the SMS message to the SMS center. A flag will be set in the new SMS message to inform the SMS center that this SMS message has been sent before. If the previous message submission was successful, the SMS center will ignore the new SMS message but send back a message submission report to the mobile phone. This mechanism prevents the sending of the same SMS message to the recipient multiple times.

Sometimes the message submission report mechanism is not used and the acknowledgement of message submission is done in a lower layer.

5.4. Message Delivery Reports


After receiving an SMS message, the recipient mobile phone will send back a message delivery report to the SMS center to inform whether there are any errors or failures (example causes: unsupported SMS message format, not enough storage space, etc). This process is transparent to the mobile user. If there is no error or failure, the recipient mobile phone sends back a positive delivery report to the SMS center. Otherwise it sends back a negative delivery report to the SMS center. If the sender requested a status report earlier, the SMS center sends a status report to the sender when it receives the message delivery report from the recipient. If the SMS center does not receive the message delivery report after a period of time, it concludes that the message delivery report has been lost. The SMS center then re-sends the SMS message to the recipient. Sometimes the message delivery report mechanism is not used and the acknowledgement of message delivery is done in a lower layer.

You might also like