Monday, October 02, 2006

 

SMS Gateway using Gammu and MySQL on Linux

The applications of the SMS gateway can be searched and downloaded from the internet. You will be able to find a number of SMS gateway applications from various platforms.

The one that we will discuss here is Gammu in this article. We are going to use Gammu application for sms gateway for number of good reasons. Primarily because Gammu is easily configurable, usable for both Windows and Linux and last but not least it is freely downloadableJ. It is compatible with mysql as well.

Here we will only discuss:

“How to setup SMS gateway using Gammu with Linux”


The mobile phone that succeeded in being tried by me is Nokia 3310 and Siemens C35i using Linux platform.

Before installation is done, first read information repeatedly about Gammu here:

http://www.mwiacek.com/gsm/soft/gammu.html


Have you gathered the information?
OK.
.
Now let’s gather the requirement to dev
elop the SMS Gateway using Gammu.


Download Gammu.

1. gammu.tar.gz
Download the gammu package from: www.mwiacek.com/zips/gsm/gammu/gammu.tar.gz

# wget www.mwiacek.com/zips/gsm/gammu/gammu.tar.gz

2. Web Server (If you have webserver, don’t ignore this, if not yet then you must install first apache, myslq, php)

3. The Nokia mobile phone 3310 or Siemens C35i. For other mobiles phone please read again:

http://www.mwiacek.com/gsm/soft/gammu.html


Gammu supports various types of the mobile phones. How come? look this: Gammu currently supports: majority of Nokia phones from DCT3 generation with Nokia operating system - for example Nokia 3210, 3310, 3315, 3410, 5110, 5130, 6110, 6510, 6610, 7210, 8310
Many AT devices - for example many Siemens, Sony Ericsson, Nokia, Alcatel models, Alcatel from BE5/BF5/BH4 generation - for example 501, 511, 512, also some functions with OBEX and Sym
bian devices

4. The Serial cable for the mobile phone

If you have successfully downloaded gammu.tar.gz, please extract it:

#tar xvfz gammu.tar.gz

After extracted automatically you will find the folder gammu-1.08.00, now enter into the extracted folder.

#cd gammu-1.08.00

Before installation make a custom read README, INSTALL, etc.

#. /configure

#make

Here at this stage one thing needs attention that there may be some error “lssl was not found”. This happens when mysql does not support Gammu or gammu database is not configured yet, (his installation process repeatedly try to find the mysql library which is needed)
#make shared
#make install
#make installshared

Further it’s necessary for you to upgrade the “library”

# vi/etc/ld.so.conf
Add the library link /usr/local/lib to file ld.so.conf, once you have done upgrade the library:

#/sbin/ldconfig

Note: If you did not find any error to this stage means you have successfully installed the Gammu sms Gateway.

Now tried to enter again into the folder where you extracted gammu.tar.gz and copy the available files in folder /docs/example/config/* here you will find 3 files by the name of gammurc, mysql.sql, smsdrc and gammurc.

Copy the gammurc and smsdrc into the /etc directory

#cp gammurc smsdrc /etc/

Further search edited file like this:

[gammu]
port = /dev/ttyS0 #if you are using COM2 then substitute it with ttyS1
#model = 6110 #model of mobile phone was ignored by you, because it does’t need often to mention the phone model.
connection = fbus #With Nokia mobile phone connection should be “fbus” if you used the Siemens mobile phone then substitute the “fbus” with “at19200″
#synchronizetime = yes
#logfile = gammulog
#logformat = textall
#use locking = yes
#gammuloc = locfile
#startinfo = yes
#gammucoding = utf8
#rsslevel = teststable
#usephonedb = yes


If you are still confused, inside the gammurc file it has the guidance available. If you are lazy to edit the file, then you can get the file from www.posmetropadang.com/gammu/gammurc

Now confirm if the data cable and your mobile phone are connected to port COM1 to your computer, if everything is just fine, run the following command.

#gammu –identify

I hope you could see output as being supervised here:

Manufacturer : Nokia
Model : 3310 (NHM-5)
Firmware : 06.33 F (28-11-03)
Hardware : 1012
IMEI : 350835608671298
Original IMEI : 350835608671298
Manufactured : 0802
Product code : 0505201
Simlock 1 : MCC+MNC 00101, opened, user , counter 0
Simlock 2 : GID1 0000, opened, factory, counter 0
Simlock 3 : GID2 0000, opened, factory, counter 0
Simlock 4 : MSIN 0000000001, opened, factory, counter 0
MSID : 830d50880846870ebedd126096
MCU checksum : 9C79
DSP ROM : 6

If you got the connection info like above gammu means Gammu detected your mobile phone and now you can continue to the next step.

Now let’s configure that how all the phone’s SMS’s will be kept by MySQL database to put forward on the webpage using php scripts.

OK further bro… our work has almost finished, possibly have some coffee or cigarettes that could disrupted previously hehe…??

Now try to open the file smsdrc that you copied earlier to directory /etc

#vi /etc/smsdrc

[smsd]
PIN = 1234
logfile = smsdlog
commtimeout = 1
sendtimeout = 10

Search and edit the part that you configured in the mysql database:

# ————————- SETTINGS FOR –smsd MYSQL —————————
user = root
password = password_mysql_user
pc = localhost
database = Database_name

Note: The above lines are to make connection with mysql database.

Now enter to the directory /docs/example/config/ and get the file ‘mysql.Sql’, that is a table structure. Now put this file to the database that we are creating in the MySQL database for SMS gateway.

For sms database
#mysqladmin –u root –p create sms

To create tables for gammu grab the file ‘mysql.sql’

#mysql –u root –p <>

Or it can be easier for you if you make Gammu tables through phpadmin.

http://localhost/phpmyadmin

Once you are finished, you can start the smsd deamon:

#gammu –smsd MYSQL/etc/smsdrc

The Log filename Is “smsdlog”
Press Ctrl+C to stopped the program …

After the issuing above command if output is like above means your SMS gateway is done successfully and you can use it according to your requirements. And all the available sms in your mobile phone will be entered inside the mysql database.

For your further stage is to putting forward your SMS’s to the web which is using php scripts, The required php script can be downloaded from http://posmetropadang.com/gammu/sms.zip


You must edit the SMS database info in the sms.php file.

If all goes well, now you can open the SMS’s through your favorite browser:

http://localhost/sms.php

Now what must be done by you??
The smsd service deamon must be running to grab the SMS’s from the phone and you and you could see on the web.

Create a Gammu startup script.sh and place it in the directory /usr/local/Bin/#cd/usr/local/bin/

#vi gammu.sh

File contents are as follows:
#! /bin/sh
export LANG=da
DK
/usr/local/bin/gam you –smsd MYSQL/etc/smsdrc

After edited that file open /etc/inittab

#vi /etc/inittab

And add the below line in the inittab

GA:345:respawn:/usr/local/bin/gammu.sh

Wow… was long enough also, hmmm hopefully did not have the problem ya… now finished your coffee, until you finished developed the SMS Gateway by using Gammu.
If you are having comments and questions, do not hesitate, just feel free to ask.

Comments:
Hi, I am a Linux user from Kenya, East Africa. I use SUSE 10.1/10.2. I have configured the app and its running OK. The output is just like you have mentioned here:
-------------------------
useracc@useracc:~/Desktop/SysTest/cmake-2.4.7-Linux-i386/bin/gammu> ./gammu --smsd MYSQL /home/useracc/.smsdrc
Log filename is "smsdlog"
Press Ctrl+C to stop the program ...
-------------------------

However, when I check the database, there are no sms messages in the database... any help you could give on that?
 
Hi its me again... I found out what my issue was... I was running the application but the account I was using did not have rights to access the phone...BTW I am using a Motorola V3i and it works fine on Gammu.... this is an excellent API indeed.

Thanks for this tutorial as well.

IDS
 
ajaoM8 The best blog you have!
 
sQtzsG Good job!
 
Thanks to author.
 
Hello all!
 
Please write anything else!
 
Hello all!
 
Nice Article.
 
Please write anything else!
 
actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.
 
Magnific!
 
Please write anything else!
 
x2VRpN write more, thanks.
 
Wonderful blog.
 
Thanks to author.
 
Please write anything else!
 
actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.
 
Nice Article.
 
Please write anything else!
 
Please write anything else!
 
Nice Article.
 
Thanks to author.
 
Magnific!
 
Good job!
 
Thanks to author.
 
The gene pool could use a little chlorine.
 
Oops. My brain just hit a bad sector.
 
Hello all!
 
What is a free gift ? Aren't all gifts free?
 
Lottery: A tax on people who are bad at math.
 
640K ought to be enough for anybody. - Bill Gates 81
 
A lot of people mistake a short memory for a clear conscience.
 
Hello all!
 
Thanks to author.
 
Please write anything else!
 
Thanks to author.
 
What is a free gift ? Aren't all gifts free?
 
Give me ambiguity or give me something else.
 
Friends help you move. Real friends help you move bodies.
 
Friends help you move. Real friends help you move bodies
 
Good job!
 
640K ought to be enough for anybody. - Bill Gates 81
 
Hello all!
 
Oops. My brain just hit a bad sector.
 
actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.
 
Wonderful blog.
 
C++ should have been called B
 
Good job!
 
Clap on! , Clap off! clap@#&$NO CARRIER
 
Give me ambiguity or give me something else.
 
A flashlight is a case for holding dead batteries.
 
640K ought to be enough for anybody. - Bill Gates 81
 
Build a watch in 179 easy steps - by C. Forsberg.
 
Nice Article.
 
A lot of people mistake a short memory for a clear conscience.
 
Save the whales, collect the whole set
 
When there's a will, I want to be in it.
 
Change is inevitable, except from a vending machine.
 
Friends help you move. Real friends help you move bodies.
 
640K ought to be enough for anybody. - Bill Gates 81
 
What is a free gift ? Aren't all gifts free?
 
Energizer Bunny Arrested! Charged with battery.
 
Nice Article.
 
actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.
 
actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.
 
A lot of people mistake a short memory for a clear conscience.
 
actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.
 
Give me ambiguity or give me something else.
 
Give me ambiguity or give me something else.
 
All generalizations are false, including this one.
 
Suicidal twin kills sister by mistake!
 
640K ought to be enough for anybody. - Bill Gates 81
 
When there's a will, I want to be in it.
 
Energizer Bunny Arrested! Charged with battery.
 
Energizer Bunny Arrested! Charged with battery.
 
The gene pool could use a little chlorine.
 
Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?