SMS Daemon

Posted by chris on Mon 17 Jul 2006 at 06:13

So you've got a webserver and you'd like to be able to send/receive SMS? You've seen adverts that read "Send FOO to to get ..." and would like something similar? With the gnokii package and a supported phone you should be able to do all that and more.

Having found an old mobile lying around I thought I'd give it a go.

First - lets get the packages installed.

root@host:~# aptitude install gnokii-smsd-mysql

This brought in all that was missing. Note that there is also a postgresql version of the package available, called gnokii-smsd-pgsql.

Now - what equipment will you need? Well - a mobile phone and data cable that is supported by gnokii along with a SIM card

I had an old Nokia 6210 and I obtained a DLR-3P cable from a local Nokia franchise. I then got a non-subscription SIM (pay-as-you-go/cash/whatever its called where you are - the one without a monthly fee)

Now all we need to do is get it all to play together

Software setup

Create a database and a user with permissions who can work with it. Grab the SQL from /usr/share/doc/gnokii-smsd-mysql/sms.tables.mysql.sql to create the required tables.

Now - we need to get gnokii configured. There is a sample config in /usr/share/doc/gnokii/examples/gnokiirc.gz which you can copy/extract to $HOME/.gnokiirc as a starting point. I found it quite well documented - and much good info on the gnokii home page particularly the Getting Started link.

Here is what I am now using

[global]
port = /dev/ttyS0
model = 6210
initlength = default
connection = dlr3p
use_locking = no
serial_baudrate = 19200
smsc_timeout = 10

[gnokiid]
bindir = /usr/local/sbin/

[connect_script]
TELEPHONE = 12345678
[disconnect_script]

[logging]
debug = off
rlpdebug = off
xdebug = off

This is basically the example gnokiirc with my port, model and connection and with all comments removed

Now we need to make sure that gnokii can see the phone

gnokii --identify

should be able to identify the phone with some meaningful info (see the getting started page on the gnokii site for more info on this). I spent ages on this - was working fine on my laptop running unstable but - on the server running stable - despite the correct permissions on /dev/ttyS0 (being a member of the dialout group) no dice. Took me ages to recall that the serial port was disabled in the BIOS. So - remember - serial port enabled - rw access (easiest to add your user to the dialout group)

If gnokii cannot identify your phone then you'll have to stop here. Acording to the website "most" Nokia phones are supported, but if you're using something else you're probably out of luck.

Finally - lets start the sms daemon

/usr/sbin/smsd -u dbusr -p dbpass -d dbname -c dbhost -m mysql -f logfile

Incoming SMS will be placed in the inbox table, entries in the outbox table will be sent. For more info see the file /usr/share/doc/gnokii-smsd/README.gz

So - from here - you can now create any script you like to check/update the tables - I'll probably be using perl scripts running from cron from this point in - Good Luck!


This article can be found online at the Debian Administration website at the following bookmarkable URL:

This article is copyright 2006 chris - please ask for permission to republish or translate.