Manually using SMS/ru

From Openmoko

Revision as of 09:19, 28 January 2008 by Xnike (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

В этой статье рассказывается как посылать и получать SMS сообщения через GSM используя GSM - модуль Neo1973.

Если вы сведущи в технологии SMS, пожалуйста проверьте AT команды SMS и измените их, если найдете ошибки (и удалите этот параграф). I've done what I could with a single evening's crash course.

Если вы просто хотите преступить к практике без чтения дополнительной информации, переходите сразу к пункту Устройство.

Contents

Обзор

GSM - модуль в Neo1973 использует расширенную версию Набор команд Hayes AT для отправки и получения сообщений. Документацию по командам можно найти на Техническая Спецификация GSM форуме CTI. Так как в технических спецификациях стараются ради витиеватого слога и заключительного слова, я рекомендую почитать вместо них Документацию SMS на Developer's Home.

libgsmd-tool

Хотя использование команд Gsmd посредством libgsmd-tool должно работать правильно, 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
Connected.
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
Connected.
AT-Command Inter
OK
AT
OK

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.

ATE1
OK

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".

AT+CFUN=1
OK

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:

AT+CFUN=0
OK

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.

AT+COPS
OK

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

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.

AT+CMGF=1
OK

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.

AT+CMGS="5555551212"
> HOWDY
> <Ctrl-Z>
OK

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.

AT+CMGL="ALL"
+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 my.t-mobile.com 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 my.t-mobile.com 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
Hello
+CMGL: 4,"REC READ","501",,"07/08/02,15:14:43-20",129,92
tselfcare@t-mobile.com /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!

OK

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

AT+CMGL="REC UNREAD"
...
OK

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

AT+CMGL="REC READ"
...
OK

Существуют другие команды для выборки (поиска) сообщений. Вы можете познакомиться с ними, почитав в свободное время литературу по ссылкам, приведенным в статье.

Заключение

Для выхода из cu, воспользуйтесь "~.". Заметим, что ssh также использует escape последовательность для завершения соединения, поэтому вам надо напечатать "~~." в терминале для передачи "~." на другую сторону.

Существуют как правило команды для удаления и сохранения сообщений. Вы можете узнать о них больше, прочитав литературу по ссылкам, приведенным в статье.

Personal tools

В этой статье рассказывается как посылать и получать SMS сообщения через GSM используя GSM - модуль Neo1973.

Если вы сведущи в технологии SMS, пожалуйста проверьте AT команды SMS и измените их, если найдете ошибки (и удалите этот параграф). I've done what I could with a single evening's crash course.

Если вы просто хотите преступить к практике без чтения дополнительной информации, переходите сразу к пункту Устройство.

Обзор

GSM - модуль в Neo1973 использует расширенную версию Набор команд Hayes AT для отправки и получения сообщений. Документацию по командам можно найти на Техническая Спецификация GSM форуме CTI. Так как в технических спецификациях стараются ради витиеватого слога и заключительного слова, я рекомендую почитать вместо них Документацию SMS на Developer's Home.

libgsmd-tool

Хотя использование команд Gsmd посредством libgsmd-tool должно работать правильно, 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
Connected.
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
Connected.
AT-Command Inter
OK
AT
OK

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.

ATE1
OK

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".

AT+CFUN=1
OK

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:

AT+CFUN=0
OK

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.

AT+COPS
OK

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

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.

AT+CMGF=1
OK

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.

AT+CMGS="5555551212"
> HOWDY
> <Ctrl-Z>
OK

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.

AT+CMGL="ALL"
+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 my.t-mobile.com 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 my.t-mobile.com 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
Hello
+CMGL: 4,"REC READ","501",,"07/08/02,15:14:43-20",129,92
tselfcare@t-mobile.com /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!

OK

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

AT+CMGL="REC UNREAD"
...
OK

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

AT+CMGL="REC READ"
...
OK

Существуют другие команды для выборки (поиска) сообщений. Вы можете познакомиться с ними, почитав в свободное время литературу по ссылкам, приведенным в статье.

Заключение

Для выхода из cu, воспользуйтесь "~.". Заметим, что ssh также использует escape последовательность для завершения соединения, поэтому вам надо напечатать "~~." в терминале для передачи "~." на другую сторону.

Существуют как правило команды для удаления и сохранения сообщений. Вы можете узнать о них больше, прочитав литературу по ссылкам, приведенным в статье.