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
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.
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 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:
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:
echo "Usage: $0 'phone number' 'message'"
echo "Sends the SMS message"
if [ $# -ne 2 ]; then
chat -T "$1" -U "$2" -f /root/testchat -v /dev/modemctl
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 :-)