SkayaWiki

NokiaSms

JeromePetazzoni :: DerniersChangements :: DerniersCommentaires? :: ParametresUtilisateur :: http://www.enix.org/ :: Vous êtes ec2-100-26-196-222.compute-1.amazonaws.com
The following is NOT Nokia-specific ; it will allow you to send & receive SMS from your computer, by “connecting” it to your GSM phone thru bluetooth. You can write SMS from your keyboard and read them on your screen, while the phone stays in your bag/pocket/whatever.

UPDATE : I cleaned the code a bit, and removed some quirks which sometimes caused the last character of an incoming message to be truncated. I also added a lot of debugging hooks, and I am investigating multi-part messages support.

BIG FAT WARNING


This program works for me. It probably will not work for you. But if you know some Python and are willing to hack things a bit, you will probably get it to work, too.

Get the sms script, the sms alphabet (to translate to/from the sms "charset"), and for hacking purposes, I found the documentation of some GSM modem explaining how to send/receive SMS. This documentation is not enough to get everything working, but it was of (some) help.

Some technical details...


I am a SMS hard-core user, so I finally wanted to be able to send & receive SMS from my laptop. I have a Nokia 6230 cellphone. Both have bluetooth support. Here is what I did.

Send some AT commands to the cellphone


Bluetooth setup itself is beyond the scope of this document. Enable bluetooth on the phone, be sure that the phone is setup to be visible on scans (if you don't know what this means, don't bother), and you should be able to see your phone like this :

jpetazzo@skalinka:~$ hcitool scan
Scanning ...
00:0E:ED:12 (interwiki):34:56 Nokia 6230
jpetazzo@skalinka:~$


Then, do the following (as root ; or you can setup udev or whatever so that /dev/rfcomm[0-9]* are read-writable by your user) :

rfcomm connect 0 00:0E:ED:12 (interwiki):34:56 1
Connected /dev/rfcomm2 to 00:0E:ED:12 (interwiki):34:56 on channel 1
Press CTRL-C for hangup

You cannot type AT-commands there ; you only made a binding between the cellphone and /dev/rfcomm2.

Now, start minicom or you favourite serial communication program, and aim it at /dev/rfcomm2 (I think that bitrate etc. are irrelevant ; I used 115200 N81 + hardware flow control).


ATI
Nokia
OK


Congratulations for reaching thus far.

Some explanations about SMS and AT-commands


If you are not familiar with "classic" Hayes commands (ATZ, ATDT, etc), try to find a good old US Robotics modem and learn to use it. :-)

Seriously, there is a set of more-or-less standardized commands, all starting with AT, all returning some information - and OK or ERROR at the end.

There are a lot of different ways to get/send SMSes. All commands start with AT+CMG. Then there is a letter to specify the action, and then either a question mark when you want to check the value of a flag, or a equal sign to specify a parameter.

List of (some) commands :
- AT+CMGF : get/set format (0 for SMS PDU, 1 for ASCII)
- AT+CMGL : list sms on the phone
- AT+CPMS : set message storage (by default you read messages from the sim ; if you want to read from the phone memory, do AT+CPMS="ME")

For instance, AT+CMGF? allows to see the current format ; AT+CMGF=1 sets the format to ASCII. AT+CMGL? makes no sense ; if you want to list the SMS on the phone, to AT+CMGL=4 (when you are in PDU mode) or AT+CMGL="ALL" (when you are in ASCII mode). To list only new messages (warning, this will mark them as "read"), to AT+CMGL=0 or AT+CMGL="REC UNREAD". Warning : this only scans the current storage (use AT+CPMS to change it)

This is very verbose but very, very, very informative : http://gatling.ikk.sztaki.hu/~kissg/gsm/at+c.html

Decoding and Encoding SMS PDU


See this excellent site : http://www.dreamfabric.com/sms/

How do I use the program?


Setup /dev/rfcomm2 as specified above. Then, run sms.py send +33612345678 "hello this is a nice sms"... You can also use sms.py readnew and sms.py readall. See the source for other commands. I use a lot of little scripts, for instance "michel" is a two-line scripts : #!/bin/sh on the first ;-) and sms.py send +3312345678 "$*" on the second one.
Il n'y a pas de commentaire sur cette page. [Afficher commentaires/formulaire]