SMS with Java and GSM Modem

DIY, Geek Add comments

This is a quick tutorial about sending and receiving  SMS from/of the computer with a GSM/GPRS modem and Java.

Requirements

Introduction
It is possible to use a programming language to send Hayes Commands (aka AT commands) through the serial port to a cellphone modem, plugged into a PC . With these commands the cellphone can send SMS.

We could do the connection with the Serial port and write every AT command programatically. However, it is complex and would require learning the the AT Commands list.
In order to avoid this complexity you can use the SMSLib, intead of writting it manually.

Installing

  • Configure the Java communication library according to the SMSLib Installation guide
  • The installation guide tells how to build SMSLib with Ant. I prefer building it with Eclipse. Thue, I have imported the sources to a new Java Project inside of Eclipse.
  • Add a reference to the Slf4j library and Commons.Net library in the recently created Eclipse project.
  • Connect the cellphone in the computer. You can use USB, BlueTooth, IrD, etc.
  • Find out what is the COM port associated to the new connection and its baud rate. Keep it in memory.
    On Windows: Contro Panel -> system -> Device Manager -> Modens. Right click on the modem, tab Modem and get the value of “port”. This value is similar to COM3.

Running a sample
The SMSLib comes with some good samples. The SendMessage class is the simple one. Open it and make the following modifications in the instantiation of SerialModemGateway:

- Change the cellphone number to a valid one.
- Change the COM port and the baud rate with the value you me memorized before.

The result is something like this:
new SerialModemGateway(“modem.com3″, “COM3″, 115200, “Sony Ericsson”, “W580″);

If you are looking for a SMS server, the class ReadMessages is a good beginning.

Limitation
A regular GSM modem is slow and can send about 6 messages per minute.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists

Leave a Reply

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in