Ericsson W25 Sending and receiving SMS

The firmware of the W25 doesn't support the handling of the SMS, but the bult in 3G modem does. So let's dig a bit into it and use this possibility. (In order to do this you need to have access to the command line of the W25).

To control the modem of the W25 there are two commands to use:
  1. msctl - this is a high level handling with predefined command

  2. mctl - this is a low level command, which you can use to send AT command to the modem

Try out:

msctl rscp - this will give you the actual strength of your reception

msctl issue ATI - this will give you information about the modem included in your device.

Now if we would like to know, which AT commands we can use, we have to download the AT command book from the Sierra Wireless site: AT command reference. If this download will not work, just search the Sierre Wireless site for the AT command reference.

When looking into this document, you will find a lot of interesting command, but you will soon realize that the command related to SMS sending are just marked supported or not supported in chapter 2, but there is no description. We have to download the 3gpp standards 27.005 and 27.007 to see the detailed syntax. If the link here doesn't work, you can find them on the http://www.3gpp.com/ site.

Now we have everything to handle SMS.

Reading SMS

To read SMS, first we switch the SMS mode to text:

mctl issue at+cmgf=1

then we list the unread SMS:

mctl issue at+cmgl

or the already read messages:

mctl issue at+cmgl='"rec read"'

Sending SMS

Sending SMS is a bit more complicated becuase we have to include a new line in the AT command, and I could not manage to do it with mctl. But we should not panic, we have the chat command on the system which is exacty designed to send AT commands to modems. So lets put together the appropriate chat script:

REPORT ERROR
"" ATZ
OK AT+cmgf=1
OK AT+cmgs="\T"
> \U^Z


We start with ATZ to reset the modem settings, then set the text mode, then use the command at+cmgs to send the message. The \T is one of the parameters to chat, we use this for the phone number, \U is the other, we use it for the message itself. We are ready, but for making it easier to use, we write a script to send SMS in one step:

usage() {
echo "Usage: $0 'phone number' 'message'"
echo "Sends the SMS message"
}

if [ $# -ne 2 ]; then
usage
exit 1
else
chat -T "$1" -U "$2" -f /root/testchat -v /dev/modemctl
fi

exit 0


If you have spaces in the message then you should surround it between quotes (").

There is only one problem with this, that the W25 is collecting some statistical data every minute so if we send the SMS exactly at the same time, the two modem commands may mix together. To avoid this you may extend the script, whith a small part which checks the actual time and if it is beetween 55 and 05 seconds then just waits for some more seconds.

Of course it would be nicer to have this on a WEB interface, with handling all kind of unicode characters, but as Shrek said in relation to the Dragon, don't worry, it is on my list :-)

Comments

Anonymous said…
thanks for your blog, it's awesome. I've been playing with a w25 and your hacking has uncovered a lot of useful stuff.

Have you noticed there's a getty running on ttyS0? dmesg reports two serial ports .. I was curious, so I took the lid off and found a 5-pin header which it seems to inhabit. A bit of playing with a multimeter found the ground pin, two pins at 3.3v and one at 0.05v. Counting from the side closest to the bottom of the board we have:

0.05v

disconnected

Rx

Gnd

Tx

(Rx/Tx assumed from the Intel docs). Hooking this up to a PC produced garbage, which changed as I stty'ed the port on the w25 to different settings but still garbage. Unfortunately I can't kill the getty on ttyS0 because init restarts it and inittab is not writeable. But echoing > /dev/ttyS0 produced correlating junk on the PC .. just can't get the bloody terminal settings right, I'm guessing!

On the other hand, that first pin might be important for something. Or my dodgy cable might be problematic: 2 times out of 4 the w25 refused to boot with the serial port connected!

Have you tried the serial port? Any interest in pushing this angle?
Lacó said…
Very interesting. I have not opened my W25 so far, because it is built into such place in our house that it is difficult to remove :-) And it has to provide me the internet as well...

I have found a way to access the RedBoot manager trough the network, but I did not do anything with it. I am more looking into complementing the existing system rather than replacing the system.
Lacó said…
From your message I see that probably you matched the baud rate of your PC to the one of the serial port.

What I do not see if you have used the proper voltage level conversions in your cable. As far as I know, to connect a 5V based serial port to the PC you should use some kind of volatge corrector.
Anonymous said…
connecting to RedBoot via the network? Interesting .. I think OpenWRT does something like this as well -- listening for a magic packet which causes it to redirect the console to a TCP port.

You're probably right on the voltage levels. I was expecting 5v but got 3.3v and didn't do any sort of conversion, expecting that either my memory was faulty or the PC would automatically adjust. I'll look into conversion!t
g0lem said…
thanks for the information it is really helpful. i have a w25 myself and tried this but when i reach to the "mctl issue at+cmgl" step, it just says OK but doesn't display the message. i thought it may be because of the mctl command and its capabilities, but your post proofs it is not the case. i am following the at, at+cmgf=1 and at+cmgl commands (cmgf does change) and still nothing. what can i do? thanks
Lacó said…
In my unit the mctl issue at+cmgl also displays only ok, because there are no new messages. when I use mctl issue at+cmgl='"rec read"' exaclty with this quotes, then it displays my old messages.

Try to send some SMS to the unit and then check if you can read them.
Anonymous said…
Hi,
If I execute the send script, i just get the usage of the chat command. Should there be an > to /dev/modemctl?

Usage: chat [-e] [-E] [-v] [-V] [-t timeout] [-r report-file]
[-T phone-number] [-U phone-number2] {-f chat-file | chat-script}

2.
^Z how should this character written to the chat file? ctrl+Z or ctrl+V+Z

3.
Is it also possible to execute following command? chat -f [chatscriptfile]

chatscript:
REPORT ERROR
"" ATZ
OK AT+cmgf=1
OK at+cmgl='"rec read"'

Sending SMS with the procudure in your web is not really working.
thanks for your help

mh
Lacó said…
Hi anonymous!

You are right!

When I was pasting the code into this blog, the editor simply eated the smaller and bigger signs.

The correct invocation of chat is the following:

chat -T "$1" -U "$2" -f /root/smssendchat -v

Then redirect both input and output to

/dev/modemctl

I can not enter it here, because the less and greater signs are interpreted as part of a html tag :-)
developar said…
Please can you tell me how to access the command line of the device ?

I am on Windows XP
developar said…
Thank for your post :
http://networkingathome.blogspot.com/2007/10/accessing-command-line-interface-of.html

I know now how to do it, but unfortunatltly each time I enter the user name & password it says welcome then the cmd close ???

What coulb be the reason ?
developar said…
Sorry Again, it is working now, I entered user: root and password is: root and it is working now, I hope I will be able to make a UI to it

Thanks for the information
Lacó said…
Good...

Just a hint, that if your device has still the root-root user id/password, you should change it as soon as possible. The easiest way to do it is to log in to the standard web interface with the root user and there is a menu for changing the password.
boatbodger said…
Has anybody found a way to stop the msctl command from timing out for commands which take a long time like "network scan" which is AT+COPS=?

I've found that it it times out and you whack in the command again immediately you usually get the result, but this is rather horrid and won't be reliable.
Anonymous said…
this work if i use the operator user or only with the root?
Lacó said…
I think that it should, but I have not tried it.
Unknown said…
ok thanks another one :D when you create the script testchat
------------
REPORT ERROR
"" ATZ
AT+cmgf=1
AT+cmgs="\T"
------------
how important is "" ATZ command? can i ignore it? because that command its only executed if i enter as root and im only permited as operator
Lacó said…
The atz command just resets the module, I think that you can safely ignore it.

It is a bit strange that it doesn't work with the operator user, because I do not think that there is a access control on the module itself.
Anonymous said…
Hi, When i execute the sendsms script i recive the following error

cannot create 7dev/modemctl: Permission denied.

I don't have the root password, only i have the operator password.

Thanks.

Popular posts from this blog

Setting ethernet interface speed in /etc/network/interfaces