SMS'ing is a easy, (fairly) reliable way to get messages to people quickly. Now having a computer program send an SMS could be very handy. Based on the number of "How can I send an SMS from program XYZ..." questions asked in forums, lots of people think so. So I've been thinking of building a set of reusable classes for use in future projects of mine to enable me to inform an admin user when a problem has arisen or send a user information. In spite of lots of people asking these questions, it took me a while to find my answer, especially seeing that I had no idea of how to go about doing it.

There seem to be a few ways of achieving this; some involve using a third party service, like an SMS gateway, others a GSM device connected to a computer. As I don't want to use a subscription service which no doubt would be much easier, I was restricted to using one of my phones connected to my computer. After my initial quick search, I found some code which apparently allowed a program to communicate via a COM port with the phone. That was all good except the phone is connected via a USB port. Hmmmm... It took a while to realize that once the drivers for the phone are installed on the computer, a "virtual COM port" is created which is visible in the device manager in Windows.

So once I got this figured out, I downloaded the smslib code and examples and tried to run it. All I got was an unknown port exception (or something like that). After some more head-scratching, I found that I hadn't installed everything properly. The smslib relies on the commapi which is used to send data to a serial port. This api requires that a dll file and a properties file be placed in the correct folders. With this resolved, the code worked perfectly and I managed to send my first "Hello World" SMS to myself via my connected phone.

In all the searching for that elusive eureka moment I read a lot of information and learnt a few things. An interesting thing relates to the use of AT commands. At first I was totally confused, even though I had seen this relating to modems years ago. Basically, a special set of AT commands, which sent to a modem or phone via the serial port causes certain desired behavior or returns some information. The commands allow a program communicating with a phone to make a call, end a call, send data via GPRS/ 3G/ SMS, get information regarding battery life and many other functions. The exact implementation depends on the phone but it is generally standard. These commands can be easily tested using a utility program like HyperTerminal. So coupled with the AT command specification downloaded from Sony Ericsson for my phone, the commapi library and some imagination I could write a program to control virtually anything on my phone.

So now my final problem is that it seems as though the number of SMS’s sent from a GSM device is restricted to about 6/minute. I will probably have to write a server which allows multiply phones to be connected at the same time that read SMS’s to be sent off a queue. Maybe in the future I’ll expose this as a web service which leads on to the question of authentication and authorization relating to who can send or read SMS’s. Rather than just a side thing, this is turning out to be an interesting project in itself.

|

0 comments


Twitter Delicious Facebook Digg Stumbleupon Favorites More

    Subscribe