Ericsson W25 Sending and receiving SMS
To control the modem of the W25 there are two commands to use:
- msctl - this is a high level handling with predefined command
- 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
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?
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.
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.
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
Try to send some SMS to the unit and then check if you can read them.
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
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 :-)
I am on Windows XP
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 ?
Thanks for the information
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.
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.
------------
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
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.
cannot create 7dev/modemctl: Permission denied.
I don't have the root password, only i have the operator password.
Thanks.