Text messages from terminal.

I’m testing new GSM modem which then I’m going to use as a SMS gateway. But before I’m going to start coding I need to be able to check if box is doing all the things that I would expect.

The SMS specification has defined a way for a computer to send SMS messages through a GSM modem ( or mobile phone). GSM modem is really similar with approach as a regular copper modem. After connecting a GSM modem to a computer, you can control it by sending AT instructions. In addition to this common set of standard AT commands, GSM modems support an extended set of AT commands. One use of the extended AT commands are for control of sending and receiving of SMS messages. To establish connection I use minicom.

So lets go:

1. First try to check if modem is responding:

AT
OK

2. Then I need to supply PIN:

AT+CPIN="XXXX"
READY

3. The AT command +CMGF is used to instruct the modem to operate in SMS text mode. Result OK indicates the command line “AT+CMGF=1” has been executed successfully. If the result code “ERROR” is returned, it is likely that modem does not support text mode. To check, type “AT+CMGF?” in the terminal. If the response is “+CMGF: (0,1)” (0=PDU mode and 1=text mode), then SMS text mode is supported. If the response is “+CMGF: (0)”, then SMS text mode is not supported. When you type in your message you have to end it up with CTRL+Z key combination. CMGW response is important also indicates location in sending queue ( on modem storage ) which we will use in next command.

AT+CMGW="+31XXXXXXXXX"
> TEST
+CMGW: 1
OK

4. The AT command +CMSS is used to send the SMS text message from the message storage of the GSM modem. “1” is the index of the SMS text message obtained from previous line. It could be 20 as well or any other number. Maximum depends on how big storage on modem is. The CMSS response is just reference number.

AT+CMSS=1
+CMSS: 12
OK

That’s pretty much all about text messages. You probably already going to realize the first drawback of using GSM modem as SMS gateway – speed. Realistically you can’t send more than 10 messages per minute. The performance is not affected by the connection between the computer and modem and does not depend on whether modem is used for voice.