Thursday, November 30, 2006

So what we will do is set up a simple SMS based service using Kannel and Linux. Kannel is a famous, powerful, open source and free SMS gateway and WAP gateway. You can use it to connect to a mobile operator's SMS center (SMSC), or using a GSM mobile phone or GSM modem as a virtual SMS center. Kannel can handle multiple SMS centers and virtual SMS centers.

Kannel supports the use of AT-capable mobile phones as virtual SMS centers. Most GSM mobile phones are capable to work with AT commands these days. A small list of mobile phones and GSM modems that are known to work as virtual SMS centers with Kannel is available on its web site.

The SMSC access protocols supported by Kannel include SMPP, CIMD, UCP / EMI and SMS2000 / OIS. In addition, Kannel has an HTTP / HTTPS interface that you can use to send and receive SMS messages.

I use Fedora Core 6 as my OS (desktop). A few methods to setup kannel using FC is, log in as root. Then execute the following command on your console

yum -y install kannel

or download the tarball from Kannel web site and compile it

This will get kannel installed on your box. Next is if you are using a GSM mobile, you need to make it work with your linux box. One easy way is setup the mobile as a GSM modem, via bluetooth. In my case I use the Bluez library for bluetooth connectivity. If you don't have it get it installed. All from FC3 up come preconfigured with Bluez libraries and all. In case you are using other distributions please get Bluez libraries and install them. On FC do the following. In any case your box needs to have bluetooth support.

Anyway, the configuration is very simple and straight forward. If you want to bind to your mobile you need to configure Bluez.The configuration of blues will be located in /etc/bluetooth/ edit the following files and do medications as per your requirements. Add the following lines to rfcomm.conf

here 00:00:0E:6D:CC:04:7F is the mac address of my mobile. You need to change that accordingly . When you do a “hcitool scan” you'd get all the devices that your box finds. To make sure you are able to reach it you can even ping the device. Type l2ping mac; example

That will get Kannel started as a service. If you fail look into the logs at /tmp/ /tmp/kannel.log and tmp/smsbox.log. That will help you to get started to debug and solve the problem.

Ok, So now if kannel is working you should be able to send SMS using the kannel web interface. Example

http://127.0.0.1:13013/cgi-bin/sendsms?username=tester&password=foobar&to=&text=hello from kannel

Type that in your browser. Again. If it gives any problems get back to logs and if needed google around. There is not much help for kannel out on the web, except the kannel documentation and the mailing list. But its easy to figure out most of the issues.

If you have access to a SMSC (if you are a telecom operator) you will need the following to connect to the SMSC. Add the lines to the kannel.conf and bring the needed changes.

You will need to have routes added to access the SMSC from your network. In my case, I have a FC5 box setup a SMSGW running Kannel and using SMPP to communicate to the SMSC.

So what do we do next. A simple service we can setup is one like Dhiraagu has to offer. Example the Haveeru news service. If someone sends you a SMS with the text “haveeru” we want to SMS him/her the new headlines. To do this we need to write a simple script to fatch the news from haveeru. For this perl is a good choice. So you need to have perl installed on your system. You would also need a cpan library to read the RSS feeds. Execute the following command first

cpan install XML::RSS

This will get the library installed. Next create a perl script called haveeru.pl with the following lines.

When the subscriber sends a SMS to a set short code, with the text "haveeru", it will execute the script we have. Then the output will be sent back to the subscriber. So there you go. Now you have a SMS based service up and running. There is a lot more you can do with kannel and others; just play around. Simple and easy.

inn, actually kannel can help a lot. Example I've read abt mobile baking. One good example is here... lets say BML sets up a kannel box, connects to the telco's smsc. thats all they need. Everytime BML need to introduce a service they don't need to talk with the telco's.

Example. you want to setup a method for the customers to chk the bank balance. you pre register the customers and auth them via SMS. then if a sms is received from that MSISDN (mobile number) with the set pin code and a request like "BAL PIN" where "PIN" can be the pin given PIN number. you get the MSISDN and the corresponding account to which its registered to. Then run a script with the parameters and do a DB lookup, and give the balance. Simple as that. qprld