Tutorial: How to Send and Receive SMS using GSM Modem


Introduction

It is very easy to incorporate SMS capability to any PC or Embedded Controller using Serial Port and any of your favourite programing language (C,C#,Basic,Pascal). Enfora GSM Modem provide a standard API set for communicating with Modem and setup for send and receive SMS. To understand and try out the varioius AT Command to send and receive SMS so that you can incorporate these into your own software project you will need a serial port (WINXP has built in hyperterminal or else for vista you can download third party serial terminal program from web). PC that does not have any serial Commport can buy standard off the shelves USB to serial converter from any computer peripheral shops (such as ATEN UC-232A)

Equipment Needed

A PC with serial comm Port (or a USB to Serial Adaptor)

A Serial Terminal Program (in this case, we had chosen to use the free Hypterminal that is present on WIN9x/WINXP)

Setting Up Hypterminal

1) Run Start -> All Program -> Accessories -> Communication -> Hypterminal

2) In a dialog Box, it ask for a connection name. Just type a description (for example T115K). Select a Comport where the COMx is the communication port that the Enfora GSM Modem is physcically conneted to.

Click OK

3) Next in the configure button, click on it to set up the comport property. Set up the COMport for 115.2Kbps, 8 Databit, No Parity, 1 stop bit and Non Flow Control (or Hardware Flow Control). Apply and Save.  Pls note that if you install a USB to serial ComPort Adaptor, typically the COMPORT will be in a different COMx Number. Make sure that you select the correct COMx Number, and also ensure the USB to Serial Port Aaptor is always connected to the same comport that you installed the driver initially.

4) Now click on the icon to connect the ComPort by using the Connect.

  

5) Now folllowing the following steps by typing on the Hypterminal.

1). Type AT and press <ENTER> the modem should respond with OK. This will verify that you are communicating with the modem. If you cannot see characters entered on the screen, enter ATE1V1.

 2). The following examples provide the AT commands and responses for setting modem parameters. For more information about the commands and response codes, see the GSM0107AT001 Enfora Enabler IIG AT Command Set.

3).  Please refer to Application Note GSM0000AN005 - Enabler-G Automated Network Connection Configuration and Use, to set the appropriate network connection.

4).  To be able to send SMS text messages, the Enfora Enabler-G module must be initialized with the proper SMS mode. The following examples provide the AT commands and responses for initializing the SMS mode.

5)  The following command initializes the Enfora Enabler-G module by setting the text mode parameters.

AT+CSMP=17,167,0,0 Set text mode parameters:

AT+CSMP=<fo>,<vp>,<pid>,<dcs>

<fo>=17 Sets reply pat, user data header, status report request, validity period format, reject duplicates and message type.

<vp>=167 Sets validity period.

<pid>=0 Higher layer protocol indicator.

<dcs>=0 Information encode format.

OK Modem Response.

6). After initializing the module with the proper SMS mode, query the module for the correct service center. The service center is required fro proper routing of an SMS through the network. The service center is programmed into the SIM by the network service provider. The following command queries the service center.

AT+CSCA? Query service center.

+CSCA: "+12063130004" Modem Response. (VoiceStream USA)

7). If no service center is entered, then contact your service provider for correct service center. To enter the correct service center, enter the following command:

AT+CSCA="+12063130004" Sets the service center. (VoiceStream USA)

OK Modem Response.

8). The following command selects TEXT mode for SMS messages.

AT+CMGF=1 Set message format to TEXT mode.

OK Modem Response.

9). The following command sets the indicators for receiving an SMS message.

AT+CNMI=1,1,0,0,0 Set the new message indicators.

AT+CNMI=<mode>,<mt>,<bm>,<ds>,<bfr>

<mode>=1 discard unsolicited result codes indication when TA TE link is reserved.

<mt>=1 SMS-DELIVERs are delivered to the SIM and routed using unsolicited code.

<bm>=0 no CBM indications are routed to the TE.

<ds>=0 no SMS-STATUS-REPORTs are routed.

<bfr>=0 TA buffer of unsolicited result codes defined within this command is flushed to the TE.

OK Modem Response.

10). The following command saves the SMS settings. Once the SMS commands have been saved, the initialization commands do not need to be sent again until they are changed.

AT+CSAS Save SMS settings. This may take up to 10 seconds.

OK Modem Response.

11)  For more advanced SMS options, see the GSM0107AT001 Enfora Enabler IIG AT Command Set for the following AT commands:

AT+CSCS Character set.

AT+CSMS Select message service.

AT+CPMS Preferred storage.

AT+CSDH Show text mode parameters.

12) . After the Enfora Enabler-G module has been initialized, the following commands demonstrate the transmission of an SMS message to a GSM mobile number.

AT+CMGS="12017572673" Send a message to the telephone number.

> Ready to enter a message.

This is a test message^Z Enter the text message. End the message with Control Z.

+CMGS: 1 Successful transmission. The number will increment with each SMS sent.

OK Modem Response.

13) . For an incoming SMS with the above initialization settings, the following indication will be displayed over the serial port:

+CMTI: "SM",1 Incoming message indication stored in message location 1.

GSM0000AN004 Page 3

14). To read the above message, enter the following:

AT+CMGR=1 Read SMS message in SIM location 1.

+CMGR: 1,"REC READ","12145551212",,"02/08/01,14:24:41+08", 145,4,0,0,"12063130004",145,5

This is a test message

OK Modem response. See GSM0107AT001 Enfora Enabler IIG AT Command Set for parameter details.

15) To store an SMS message on the SIM for later retrieval, enter the following:

AT+CMGW="12017572673" Store a message on the SIM.

> Ready to enter a message.

This is a stored message^Z Enter the text message. End the message with Control Z.

+CMGW: 2 Successfully stored in memory location 2.

OK Modem Response.

16). To send a message previously stored on the SIM, enter the following:

AT+CMSS=2 Send message from memory location 2.

+CMSS:2 Successful transmission. The number will increment with each SMS sent.

OK Modem Response.

17)  To list all of the messages stored on the SIM, enter the following:

AT+CMGL="ALL" List messages on the SIM.

+CMGL: 1,"REC UNREAD","12145551212",,"02/08/01,14:24:41+08",145,5 This is a test message

+CMGL: 2,"STO SENT","17192326602",,,129,22

This is a stored message

OK Modem response. See  Enfora Enabler IIG AT Command Set for parameter details.

18). The following command deletes a message from the SIM location specified.

AT+CMGD=1 Delete SMS message in SIM location 1.

OK Modem response upon successful delete.

Link: Documentation and AT Command Set for Enfora GSM Modem


 

  Back to Enfora Main Page    |    Back to Testech Home Page    |    Wireless Modules