Manually using SMS

From Openmoko

Jump to: navigation, search

This article explains how to send and receive SMS messages over GSM using the GSM hardware in the Neo1973.

If you're well versed in SMS, please review the SMS commands and update them (and remove this paragraph). I've done what I could with a single evening's crash course.

If you just want to do this without reading any background, skip directly to Setup.



The GSM hardware in the Neo1973 uses an extended version of the Hayes AT command set for sending and receiving messages. Documentation on this command set can be found in the GSM Technical Specification at CTI Forum. Since technical specs are usually referenced for the finer details and the final word, I recommend reading through the SMS documentation at Developer's Home instead.


Though issuing the commands to Gsmd via libgsmd-tool seems to work properly, gsmd would complain about "unsolicited responses" when reading back a list of SMS messages. This would happen when multiple messages needed to be read, then sent back to libgsmd-tool. It probably works properly when retrieving a single message. This problem showed itself by libgsmd-tool displaying duplicate messages, or not displaying response lines.

For this reason, I recommend using cu, a program used to "call up" another computer. If you have trouble using cu, you may want to refer to the article about manually using GSM for more information.


The article on manually using GSM goes through the process of making sure no other process was accessing the GSM modem device, then setting up the system for UUCP locking so cu can set up locking for the GSM modem device. Personal experience with the Neo is that the directories for UUCP locking are already set up, and that stopping gsmd is sufficient. Again, if you have any problems, refer to the manually using GSM article for additional setup details.

Stop the GSM Daemon

This ensures gsmd is not using the GSM modem and will not interfere with your hacking.

root@fic-gta01:~$ /etc/init.d/gsmd stop 
Shutting down gsmd: Terminated

Reset the GSM Modem

This can be done by powering off, then powering back on the modem. It is inferred this can be done by the Powering up the GSM Modem section of the manually using GSM article. If anyone can validate, or add the proper procedure, please update here.

root@fic-gta01:~$ echo 0 > /sys/bus/platform/devices/gta01-pm-gsm.0/power_on
root@fic-gta01:~$ echo 1 > /sys/bus/platform/devices/gta01-pm-gsm.0/power_on

Is there a location in /proc where one can verify the state of the GSM modem?

Connect to the GSM Device

Use cu to connect to the GSM device at /dev/ttySAC0. At this point, if you have a typing mistake, don't use the [Backspace] or [Delete] key to correct it. Use [Ctrl-H].

root@fic-gta01:~$ cu -l /dev/ttySAC0
AT-Command Inter

Verify your connection by typing "AT" followed by [Enter] a few times. You should eventually get an "OK" response.

root@fic-gta01:~$ cu -l /dev/ttySAC0
AT-Command Inter

GSM Modem Setup

At this point, the GSM modem has been reset and you are connected to it. You'll need to connect to the network and configure SMS test mode by issuing a few commands.

I am unable to send/receive SMS consistently without issuing all of the following commands every time start up.

Turn on Echo

Turning on echo lets you see what you're doing. This is done using the "ATE1" command.


Miscellaneous Setup

Depending on your SIM card and your country, the following commands may not be sufficient for you. For a T-Mobile SIM card in the United States, these instructions are adequate. For a PIN enabled SIM card, you may need to use the AT+CPIN="<PIN #>" command or in another country, you may need to enter an SMS Center with the AT+CSCA command.

If you find you need additional setup, please help everyone else by documenting it on this page.

Power Up the GSM Modem

Power up the GSM modem using "AT+CFUN=1".


The best reference I've found for this command are the commands in gsmd (usock.c). According to the code, the GSM modem can be turned off and on using the "AT+CFUN" command. Refer to Reset the GSM Modem to see how this is apparently accomplished from the command line.

To power down the modem:


Reference: Source code for gsmd - usock.c Reference: Mobile Termination Control and Status Commands

Register with the GSM Network

Use "AT+COPS" to ensure you are connected to a GSM network.

You may receive a variety of responses depending on the current state of the GSM modem. This command makes sure you are connected to a provider.


To check the current GSM network, use "AT+COPS?".

+COPS: 0,0,"T - Mobile"

Reference: Network Service Related Commands Reference: AT Commands Introduction

SMS Text Mode

Select SMS text mode with the "AT+CMGF=1" command. Note that the goal of gsmd seems to be to make use of the SMS PDU (protocol data unit) mode which is better for programming. However, use text mode here as it makes sending and receiving messages possible by mere humans.


Reference: Operating Mode Reference: Select the Operating Mode

Send SMS

To send an SMS, use the "AT+CMGS="<Phone #>"" command. You will be prompted for text with a ">" prompt. Enter your text message and press [Enter]. Hit <Ctrl-Z> to signal the end of your text. The message will be sent on its way.

> <Ctrl-Z>

Receive SMS

Send an SMS to your Neo from an Internet service or another phone. On your Neo, retrieve all your messages using the "AT+CMGL="ALL"" command. It should be the last one listed.

+CMGL: 1,"REC READ","907",,"07/07/30,18:21:45-20",129,156
Welcome to T-Mobile! To check your balance and refill your account, go to or visit t-zones on your phone. Your T-Mobile number is 5555551212
+CMGL: 2,"REC READ","907",,"07/07/30,18:59:33-20",129,156
Welcome to T-Mobile! To check your balance and refill your account, go to or visit t-zones on your phone. Your T-Mobile number is 5555551212
+CMGL: 3,"REC READ","15555551212",,"07/08/02,15:01:51-20",145,5
+CMGL: 4,"REC READ","501",,"07/08/02,15:14:43-20",129,92 /Temporary Password /Dear Customer, Your temporary password is XXXXXX
+CMGL: 5,"REC READ","724",,"07/08/02,15:18:42-20",129,150
Your balance is 140 minutes ($28.04). You are $75 from Gold Rewards where you get 15% more minutes on subsequent refills & unused minutes last a year.
+CMGL: 6,"REC READ","724",,"07/08/02,15:18:42-20",129,145
Free MSG: $25.00 has been added to your account. Your new balance is 140 minutes and the new expiration date is 10-31-2007. Thanks for refilling!


To retrieve unread messages, use "AT+CMGL="REC UNREAD"".


To retrieve read messages, use "AT+CMGL="REC READ"".


There are other commands for retrieving messages. Learn by reading through the references at your leisure.


To exit cu, use "~.". Note that ssh also uses this escape sequence to disconnect a connection, so you may need to type "~~." into your terminal to produce a "~." on the other end.

There are commands for deleting and storing messages, as well. Learn more about these by reading through the references listed throughout this page.

Personal tools