0% found this document useful (0 votes)
65 views17 pages

GSM Tutorial

This document provides instructions for sending and receiving SMS text messages using AT commands with a GSM modem. It describes how to check if a modem supports SMS text mode, set the necessary parameters like validity period and message type, and send messages by typing the text or a hex-encoded string. Instructions are also given for receiving messages, selecting the preferred storage location, and listing available messages.

Uploaded by

robert rob
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views17 pages

GSM Tutorial

This document provides instructions for sending and receiving SMS text messages using AT commands with a GSM modem. It describes how to check if a modem supports SMS text mode, set the necessary parameters like validity period and message type, and send messages by typing the text or a hex-encoded string. Instructions are also given for receiving messages, selecting the preferred storage location, and listing available messages.

Uploaded by

robert rob
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

GSM TUTORIAL

Send SMS using AT commands


Some advanced GSM modems like WaveCom and Multitech, support the SMS text mode. This
mode allows you to send SMS messages using AT commands, without the need to encode the
binairy PDU field of the SMS first. This is done by the GSM modem

Check if your GSM phone or modem supports SMS text mode

To check if your modem supports this text mode, you can try the following command:

AT+CMGF=1 <ENTER>

If the modem reponds with "OK" this mode is supported. Please note that using this mode it is
onluy possible to send simple text messages. It is not possible to send multipart, Unicode, data
and other types of messages.

Setting up the modem

If the modem contains a SIM card with is secured with a PIN code, we have to enter this pin
code first:

AT+CPIN="0000" <ENTER> (replace 0000 with your PIN code).

Please not that in most cases you have only 3 attemps to set the correct PIN code. After setting
the PIN code, wait some seconds before issueing the next command to give the modem some
time to register with the GSM network.

In order to send a SMS, the modem has to be put in SMS text mode first using the following
command:

AT+CMGF=1 <ENTER>

In text mode there are some additional parameters that can be set. Using the following
command we can read the current values:

AT+CSMP? <ENTER>

The modem will reponse with a string like this:

+CSMP: 1,169,0,0O K

The first value is a combination of some option bits:

1
bit 7 RP Reply path, not used in text mode
bit 6 UDHI User Data Header Information
bit 5 SRR Set this bit to request a delivery report
bit 3,4 VPF Validity Period, set b4=1 if a VP value is present
Reject Duplicates, do not return a message ID when a message
bit 2 RD
with the same destination and ID is still pending
bit 0,1 MTI Message Type Indicatorb1=0 & b0=0 -> SMS-DELIVERb1=0 &
b0=1 -> SMS-SUBMIT

Bit 0 of the message is always set when sending messages (SMS-SUBMIT). So the first value
should be 1 or higher. The second parameter sets the Validity Period of the message. This
value is encoded as follows:

0 - 143 (VP + 1) x 5 minutes


144 - 167 12 Hours + ((VP-143) x 30 minutes)
168 - 196 (VP-166) x 1 day
197 - 255 (VP-192) x 1 week

The third parameter contains the PID (Protocol Identifier). This parameter is only used for
advanced messaging. The fourth parameter contains the DCS (Data Coding Scheme). This
parameter is used to select the characterset/messagetype. When setting the DCS parameter to
'0' standard 7 bit text is send. When setting this parameter to '16' the message is sent as a
flash message.

To send a message with a validity period of 1 day, the parameters have to be set like this:

Bit 0 and 4 of the first field has to be set, so the first value will become 1 + 16 = 17.

Send the following command to the modem to set this parameters:

AT+CSMP=17,167,0,16 <ENTER>

If the modem responds with "OK" ,the modem is ready to send (flash) text messages with a
validity period of 1 day.

Sending the message

To send the SMS message, type the following command:

AT+CMGS="+31638740161" <ENTER>

Replace the above phone number with your own cell phone number. The modem will respond
with:

>

2
You can now type the message text and send the message using the <CTRL>-<Z> key
combination:

Hello World ! <CTRL-Z>

After some seconds the modem will respond with the message ID of the message, indicating
that the message was sent correctly:

+CMGS: 62

The message will arrive on the mobile phone shortly.

Sending an Unicode SMS message

Some modems also have the capability to send Unicode or UCS2 messages without encoding a
PDU. You can send Unicode messages by only converting the Unicode data to a HEX string and
send this string to the modem.

To check whether your modem supports this mode, just type the following command:

AT+CSCS=?

This commands displays the codepages supported by the modem. The modem will respond like
this:

+CSCS: ("GSM","PCCP437","CUSTOM","HEX")

If this string contains "HEX" or "UCS2", Unicode seems to be supported. To specify that you will
use an HEX string to send the message, set the codepage to "HEX" or "UCS2" depending on the
modem response. In our example we will set the modem to "HEX" :

AT+CSCS="HEX" <ENTER>

Next, we have to specify the correct DCS (Data Coding Scheme) for Unicode messages, which is
0x08. We can set this value by changing the fourth parameter of the AT+CSMP command to '8':

AT+CSMP=1,167,0,8 <ENTER>

The modem is now ready to send messages as Unicode. Now is the time to send the actual
message:

AT+CMGS="+31638740161" <ENTER>

Replace the above phone number with your own cell phone number. The modem will respond
with:

>

3
The only thing you have to program by yourself, is a simple routine which converts the Unicode
string to an hexidecimal string like this:

‫مرحبا‬

Which is 'Hello' in arabic will be converted like this:

"06450631062D06280627"

You can send this hexidecimal string to the modem:

06450631062D06280627 <CTRL-Z>

After some seconds the modem will respond with the message ID of the message, indicating
that the message was sent correctly:

+CMGS: 63

The message will arrive on the mobile phone shortly.

4
Receiving SMS messages using AT commands

Introduction

Some advanced GSM modems like WaveCom and Multitech, support the SMS text mode. This
mode allows you to send and receive SMS messages using AT commands, without the need to
decode the binairy PDU field of the SMS first. This is done by the GSM modem.

To send the commands discussed in this tutorial, you can use a terminal program, for instance
Hyperterminal.

To check if your modem supports this text mode, you can try the following command:

AT+CMGF=1 <ENTER>

If the modem reponds with "OK" this mode is supported. Please note that using this mode it is
onluy possible to send simple text messages. It is not possible to send multipart, Unicode, data
and other types of messages.

Setting up the modem

If the modem contains a SIM card with is secured with a PIN code, we have to enter this pin
code first:

AT+CPIN="0000" <ENTER> (replace 0000 with your PIN code).

Please not that in most cases you have only 3 attemps to set the correct PIN code. After setting
the PIN code, wait some seconds before issueing the next command to give the modem some
time to register with the GSM network.

In order to send a SMS, the modem has to be put in SMS text mode first using the following
command:

AT+CMGF=1 <ENTER>

If the modem responds with error, either the modem does not support SMS text mode, or the
SIM card is not ready. In this case please check that the SIM card is inserted and the pincode is
entered. You can also turn on extended error reports by using the following command:

AT+CMEE=1 <ENTER>

Instead of just an "ERROR" the modem will now respond with "+CMS ERROR: xxx" or "+CME
ERROR: xxx". For a list of possible error codes please check this list.

Selecting the preferred message storage

5
A GSM phone or modem receives messages automatically. Basically you are just retrieving the
messages from the memory of the device or SIM card. To select the message storage used to
read the messages from, you have to use the "AT+CPMS" command. You can select one of the
following message storages, not all storages are supported on every device.

Storage ID Description

Read SMS messages from the SIM card. This storage is supported on every GSM
SM phone, because a SIM card should always be present. Usually a SIM card can
store up to 15 messages.

Read SMS messages from the modem or mobile phone memory. The number of
ME
messages that can be stored here depends on the size of the phones memory.

Read SMS messages from all storages on the mobile phone. For instance when
MT the phone supports "ME" and "SM", the "MT" memory combines the "ME" and
"SM" memories as if it was a single storage.

This storage is only used to read stored incoming cell broadcast messages. It is
BM
normally not used to store SMS messages.

When you enable status reports when sending SMS messages, the status reports
SR that are received are stored in this memory. These reports can read the same way
as SMS messages.

To find out which storages are supported by your mobile phone, use the command line below:

AT+CPMS=?

The modem will respond with a list of supported storages, for instance:

+CPMS: (("SM","BM","SR"),("SM"))

The storage can be selected using the following command:

AT+CPMS=<read>[,<send>,<receive>] <ENTER>

The first parameter sets the storage to read from the second optional specifies the storage to
send messages from and the last optional parameter tells the device where to store newly
received messages.

For example, to read messages from the SIM card use:

AT+CPMS="SM" <ENTER>

The modem should respond with the following string:

6
+CPMS: <used_space>,<max_space> <ENTER>

The used_space indicates the number of messages currently in this memory, the max_space
the number of messages that can be stored.

Listing the messages

Once you have successfully set the messages storage, you can list the messages available using
the list command:

AT+CMGL="ALL" <ENTER>

Please not that "ALL" has to be send in uppercase on some modems. The modem will respond
with a list of decoded SMS messages:

+CMGL: 1,"REC UNREAD","+31625012354",,"07/07/05,09:55:16+08"


Test message 1
+CMGL: 2,"REC UNREAD","+31625012354",,"07/07/05,09:56:03+08"
Test message 2

OK

The response messages are formatted like this:

+CMGL: <index>,<status>,<from_address>,<mr>,<scts><CRLF><data>

index The memory index number, use this index to read or delete this message.

The status of this message. For received messages this can be "REC READ" or "REC UNREAD"
status
on whether the messages has been read or listed before.

from_address The subscriber number of the person who sent the message.

mr The reference number of this message. Most modems keep this field empty.

scts The time the message was forwarded to this phone or modem.

data The actual message data in plain text

Reading a message

To list a single message, you have to use the read command. You must use the list command
first, so you know the indexes of the messages in the storage. For instance, to read the
message on memory location '2' use:

AT+CMGR=2 <ENTER>

7
The modem will list the single message:

+CMGR: "REC READ","+31625012254",,"07/07/05,09:56:03+08"


Test message 2

OK

Please note that the status of the message is now "REC_READ" instead of "REC_UNREAD"
because we read the message.

Deleting a message

Once you have read a message, you can free the memory by deleting the message from the
storage. For instance, to delete the message on memory location '2' use:

AT+CMGD=2 <ENTER>

The modem will delete the single message.

GSM Equipment and Network Error Codes

When controlling GSM devices using AT commands, the device can respond with either "OK" or
"ERROR". Sometimes you will receive an error and you do not know the cause of this error.

That's why most advanced GSM devices support extended errors. Instead of just displaying the
"ERROR" message, it also shows an error number. The syntax of this extended error is either
"+CMS ERROR: xxx" or "+CME ERROR: xxx".

8
When the error starts with "+CME ERROR", it means that the error is a device specific error
code. For instance, you are trying to read a phonebook entry before entering a pincode.

When there is a network error, for instance, when you try to send an SMS message when there
is no network coverage, you will receive an error which starts with "+CMS ERROR".

To enable these extended commands, execute the following commands, or add them to your
modems init string:

AT+CMEE=1
AT&W

Below you can find a list containing almost every error code supported by GSM devices. We try
to keep this list up to date, so please send your comments to webmaster@smssolutions.net or
post them in our forum.

CME ERROR's (GSM Equipment related codes)

Error Description

CME ERROR: 0 Phone failure

CME ERROR: 1 No connection to phone

CME ERROR: 2 Phone adapter link reserved

CME ERROR: 3 Operation not allowed

CME ERROR: 4 Operation not supported

CME ERROR: 5 PH_SIM PIN required

CME ERROR: 6 PH_FSIM PIN required

CME ERROR: 7 PH_FSIM PUK required

CME ERROR: 10 SIM not inserted

CME ERROR: 11 SIM PIN required

CME ERROR: 12 SIM PUK required

CME ERROR: 13 SIM failure

CME ERROR: 14 SIM busy

CME ERROR: 15 SIM wrong

CME ERROR: 16 Incorrect password

CME ERROR: 17 SIM PIN2 required

CME ERROR: 18 SIM PUK2 required

CME ERROR: 20 Memory full

9
Error Description

CME ERROR: 21 Invalid index

CME ERROR: 22 Not found

CME ERROR: 23 Memory failure

CME ERROR: 24 Text string too long

CME ERROR: 25 Invalid characters in text string

CME ERROR: 26 Dial string too long

CME ERROR: 27 Invalid characters in dial string

CME ERROR: 30 No network service

CME ERROR: 31 Network timeout

CME ERROR: 32 Network not allowed, emergency calls only

CME ERROR: 40 Network personalization PIN required

CME ERROR: 41 Network personalization PUK required

CME ERROR: 42 Network subset personalization PIN required

CME ERROR: 43 Network subset personalization PUK required

CME ERROR: 44 Service provider personalization PIN required

CME ERROR: 45 Service provider personalization PUK required

CME ERROR: 46 Corporate personalization PIN required

CME ERROR: 47 Corporate personalization PUK required

CME ERROR: 48 PH-SIM PUK required

CME ERROR: 100 Unknown error

CME ERROR: 103 Illegal MS

CME ERROR: 106 Illegal ME

CME ERROR: 107 GPRS services not allowed

CME ERROR: 111 PLMN not allowed

CME ERROR: 112 Location area not allowed

CME ERROR: 113 Roaming not allowed in this location area

CME ERROR: 126 Operation temporary not allowed

CME ERROR: 132 Service operation not supported

CME ERROR: 133 Requested service option not subscribed

CME ERROR: 134 Service option temporary out of order

10
Error Description

CME ERROR: 148 Unspecified GPRS error

CME ERROR: 149 PDP authentication failure

CME ERROR: 150 Invalid mobile class

CME ERROR: 256 Operation temporarily not allowed

CME ERROR: 257 Call barred

CME ERROR: 258 Phone is busy

CME ERROR: 259 User abort

CME ERROR: 260 Invalid dial string

CME ERROR: 261 SS not executed

CME ERROR: 262 SIM Blocked

CME ERROR: 263 Invalid block

CME ERROR: 772 SIM powered down

CMS ERROR's (GSM Network related codes)

Error Description

CMS ERROR: 1 Unassigned number

CMS ERROR: 8 Operator determined barring

CMS ERROR: 10 Call bared

CMS ERROR: 21 Short message transfer rejected

CMS ERROR: 27 Destination out of service

CMS ERROR: 28 Unindentified subscriber

CMS ERROR: 29 Facility rejected

CMS ERROR: 30 Unknown subscriber

CMS ERROR: 38 Network out of order

CMS ERROR: 41 Temporary failure

CMS ERROR: 42 Congestion

CMS ERROR: 47 Recources unavailable

CMS ERROR: 50 Requested facility not subscribed

CMS ERROR: 69 Requested facility not implemented

11
Error Description

CMS ERROR: 81 Invalid short message transfer reference value

CMS ERROR: 95 Invalid message unspecified

CMS ERROR: 96 Invalid mandatory information

CMS ERROR: 97 Message type non existent or not implemented

CMS ERROR: 98 Message not compatible with short message protocol

CMS ERROR: 99 Information element non-existent or not implemente

CMS ERROR: 111 Protocol error, unspecified

CMS ERROR: 127 Internetworking , unspecified

CMS ERROR: 128 Telematic internetworking not supported

CMS ERROR: 129 Short message type 0 not supported

CMS ERROR: 130 Cannot replace short message

CMS ERROR: 143 Unspecified TP-PID error

CMS ERROR: 144 Data code scheme not supported

CMS ERROR: 145 Message class not supported

CMS ERROR: 159 Unspecified TP-DCS error

CMS ERROR: 160 Command cannot be actioned

CMS ERROR: 161 Command unsupported

CMS ERROR: 175 Unspecified TP-Command error

CMS ERROR: 176 TPDU not supported

CMS ERROR: 192 SC busy

CMS ERROR: 193 No SC subscription

CMS ERROR: 194 SC System failure

CMS ERROR: 195 Invalid SME address

CMS ERROR: 196 Destination SME barred

CMS ERROR: 197 SM Rejected-Duplicate SM

CMS ERROR: 198 TP-VPF not supported

CMS ERROR: 199 TP-VP not supported

CMS ERROR: 208 D0 SIM SMS Storage full

CMS ERROR: 209 No SMS Storage capability in SIM

12
Error Description

CMS ERROR: 210 Error in MS

CMS ERROR: 211 Memory capacity exceeded

CMS ERROR: 212 Sim application toolkit busy

CMS ERROR: 213 SIM data download error

CMS ERROR: 255 Unspecified error cause

CMS ERROR: 300 ME Failure

CMS ERROR: 301 SMS service of ME reserved

CMS ERROR: 302 Operation not allowed

CMS ERROR: 303 Operation not supported

CMS ERROR: 304 Invalid PDU mode parameter

CMS ERROR: 305 Invalid Text mode parameter

CMS ERROR: 310 SIM not inserted

CMS ERROR: 311 SIM PIN required

CMS ERROR: 312 PH-SIM PIN required

CMS ERROR: 313 SIM failure

CMS ERROR: 314 SIM busy

CMS ERROR: 315 SIM wrong

CMS ERROR: 316 SIM PUK required

CMS ERROR: 317 SIM PIN2 required

CMS ERROR: 318 SIM PUK2 required

CMS ERROR: 320 Memory failure

CMS ERROR: 321 Invalid memory index

CMS ERROR: 322 Memory full

CMS ERROR: 330 SMSC address unknown

CMS ERROR: 331 No network service

CMS ERROR: 332 Network timeout

CMS ERROR: 340 No +CNMA expected

CMS ERROR: 500 Unknown error

CMS ERROR: 512 User abort

13
Error Description

CMS ERROR: 513 Unable to store

CMS ERROR: 514 Invalid Status

CMS ERROR: 515 Device busy or Invalid Character in string

CMS ERROR: 516 Invalid length

CMS ERROR: 517 Invalid character in PDU

CMS ERROR: 518 Invalid parameter

CMS ERROR: 519 Invalid length or character

CMS ERROR: 520 Invalid character in text

CMS ERROR: 521 Timer expired

CMS ERROR: 522 Operation temporary not allowed

CMS ERROR: 532 SIM not ready

CMS ERROR: 534 Cell Broadcast error unknown

CMS ERROR: 535 Protocol stack busy

CMS ERROR: 538 Invalid parameter

14
SMS Cell Broadcast
SMS Cell Broadcast is designed for simultaneous delivery of messages to multiple users in a
specified area. Whereas the Short Message Service (SMS) is a one-to-one and one-to-a-few
service, Cell Broadcast is one-to-many geographically focused service. It enables messages to
be communicated to multiple mobile phone customers who are located within a given part of its
network coverage area at the time the message is broadcast. Cell Broadcast is more akin to
other mass distribution media such as teletext or Radio Data System (RDS).

SMS Cell Broadcast is defined within Phase 2 of the GSM standard in GSM 03.49. Cell Broadcast
has some similarities with SMS since both services use the GSM network's signaling path. A
(Each) Cell Broadcast message may be from 1 to 15 pages in length. Each page can be up to
93 alphanumeric characters or 82 octets of binary data in length. Additionally, up to 15 Cell
Broadcast messages can be concatenated. Cell Broadcast messages are transmitted to the
applicable Base Station Controllers (BSCs) for subsequent broadcast. The Message Destination
is described in terms of cell identifiers which the BSC uses to route the message content to
Base Transceiver Station Cells. Messages are broadcast for a user defined number of broadcasts
with a user specified broadcast repetition rate. Cell Broadcast messages may be updated or
removed from the BSC and subsequent BTS/ Cells anytime during the message broadcast
period. (The BTSs are selected to determine the area over which the message is broadcast).

On Cell Broadcast the GSM operators send different news or data. Often they offer business
news, weather forcast and so one. The German GSM operator Mannesmann D2 offers a way to
build your own Cell Broadcast channel. The costs of that service will be charged to the owner of
the service, to the user of that service or the costs can be shared.

What are DTMF tones ?

There are companies which have a telephone system which can be controlled by DTMF tones
(for instance: pager systems). To use these services you need to have a phone which is capable
to send DTMF tones.

DTMF stands for Dual Tone Multiple Frequency. When a key on the phone is pressed during a
phone call this character is send using DTMF. The following characters can be send using
DTMF: 0,1,2,3,4,5,6,7,8,9,A,B,C,D,* and #.

The DTMF keypad is laid out in a 4?4 matrix, with each row representing a low frequency, and
each column representing a high frequency (see table). Pressing a single key such as '1' will
send a sinusoidal tone of the two frequencies 697 and 1209 hertz (Hz). The original keypads
had levers inside, so each button activated two contacts. The multiple tones are the reason for

15
calling the system multifrequency. These tones are then decoded by the switching center to
determine which key was pressed.

1209Hz 1336Hz 1477Hz 1633Hz


697Hz 1 2 3 A
770 4 5 6 B
852Hz 7 8 9 C
941Hz * 0 # D

How to send DTMF tones

Of course you can send DTMF phones using your fixed line phone or cellphone, but if you want
to automate the sending of these tones over a phone connection, it becomes difficult because
most modems can only send DTMF to dial a number, but when the connection is made, there is
no way to send these tones. Some GSM modems do have this featuresuch as the WaveCom
and the Multitech GSM modems.

Sending DTMF tones using a GSM modem

The following code sample demonstrates how to send a numeric text message to a pager using
a GSM modem. The sample checks if there is a PIN code on the SIM card in the GSM modem
and sets the code.

If the code is correct, the modem will dial the number in voice mode, waits till the connection
has been established and sends the DTMF code. Finally, the connection is terminated.

The following AT Commands are used:

ATDxxxxxxxxxxxxxxx;

The ATD command is used to dial a number. The semi-colon at the end of this number
indicates that this connection has to be setup as a voice call. When leaving this semi-colon, the
connection is set up as a data call.

AT+VTD=xx

This command is optional, and is used to set the DTMF tone duration in 100mS steps.

AT+VTS=x

To send the actual DTMF code, you have to call this command for every digit sent. To send, for
instance "*1234#", you have to send:

AT+VTD=*;+VTD=1;+VTD=2;+VTD=3;+VTD=4;+VTD=#

ATH0

16
Terminates the phone connection (hangup).

17

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy