Howto build SMS server with gammu

Feb 10, 2012 6:16 AM


  ▄████  ▄▄▄       ███▄ ▄███▓ ███▄ ▄███▓ █    ██ 
 ██▒ ▀█▒▒████▄    ▓██▒▀█▀ ██▒▓██▒▀█▀ ██▒ ██  ▓██▒
▒██░▄▄▄░▒██  ▀█▄  ▓██    ▓██░▓██    ▓██░▓██  ▒██░
░▓█  ██▓░██▄▄▄▄██ ▒██    ▒██ ▒██    ▒██ ▓▓█  ░██░
░▒▓███▀▒ ▓█   ▓██▒▒██▒   ░██▒▒██▒   ░██▒▒▒█████▓ 
 ░▒   ▒  ▒▒   ▓▒█░░ ▒░   ░  ░░ ▒░   ░  ░░▒▓▒ ▒ ▒ 
  ░   ░   ▒   ▒▒ ░░  ░      ░░  ░      ░░░▒░ ░ ░ 
░ ░   ░   ░   ▒   ░      ░   ░      ░    ░░░ ░ ░ 

      ░       ░  ░       ░          ░      ░  

There are many companies and organizations need tool to spread information to their members or partners. Short message service (SMS) is a simple, cheap, and fast service for that requirement. One of the tool for this sms engine called gammu. Gammu is a sms engine, which control for sending and receiving messages. Gammu is open source tool that provides abstraction layer access for cell phones. It covers wide range of phones, focussing on AT compatible and nokia phones.


Before you build and install gammu, you must have prepared the source or binary file of gammu. For windows based operating system, you can download at http://wammu.eu/gammu. For older windows family you will also need ShFolder DLL which can be downloaded at here. How does it dependencies?, before compile gammu source files, you must have cmake tool that could be downloaded at http://www.cmake.org. Building gammu from source file doesn't need some special libraries, but you can include some optional libraries like: blues-lib, libcurl, libconv, gettext, mysql, postgresql, unixODBC, libdbi, ... and more, you can googling to find it.


After unpacking the gammu source file, and make sure the libraries and dependencies are correctly installed on your system. Don't forget to install the devel packages if you want, all of them are optional. Development packages can be installed by following command:

For ubuntu,

war49@0x49494949:~$ apt-get install cmake python-dev pkg-config libmysqlclient-dev libpq-dev libcurl4-gnutls-dev libusb-1.0-0-dev libdbi0-dev libbluetooth-dev libgudev-1.0-dev libglib2.0-dev unixodbc-dev

then you can configure and make as usual.

+++++++++++++++++++++++++++++++++++++++
war49@0x49494949:~$ ./configure
war49@0x49494949:~$ make
war49@0x49494949:~$ sudo make install

+++++++++++++++++++++++++++++++++++++++

If you have a tool like cmake, you can tweak build a bit more than configure wrapper when you need it. So, you must create a build directory, and come in.

+++++++++++++++++++++++++++++++++
war49@0x49494949:~$ mkdir build
war49@0x49494949:~$ cd build

Configure with cmake, make

war49@0x494949491:~$ cmake ..
war49@0x49494949:~$ make test
war49@0x49494949:~$ make
root@0x49494949:~# make install

+++++++++++++++++++++++++++++++++

Go to mysql database, create database for gammu.

mysql> create database livesms;

Goto gammu extraction path, find mysql.sql file in sql directory .../gammu-[version]/docs/sql insert gammu's database structure in file mysql.sql for livesms database.

++++++++++++++++++++++++++++
root@0x49494949:~# mysql -u root -p livesms < mysql.sql mysql> use livesms;
Database changed
mysql> show tables;
+-------------------+
| Tables_in_livesms |
+-------------------+
| daemons           |
| gammu             |
| inbox             |
| outbox            |
| outbox_multipart  |
| pbk               |
| pbk_groups        |
| phones            |
| sentitems         |
+-------------------+
9 rows in set (0.00 sec)

Setup user ; allow war49 user to connect to the server in localhost using password 'warwar123'.
Grant all privileges of livesms database to war49.

mysql> grant all privileges on livesms.* to war49@localhost identified by 'war12345';
Query OK, 0 rows affected (0.00 sec)

war49@war49:~$ mysql -u war49 -p
Enter password:

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| livesms            |
+--------------------+
2 rows in set (0.00 sec)

mysql> use livesms;
Database changed

mysql> show tables;
+-------------------+
| Tables_in_livesms |
+-------------------+
| daemons           |
| gammu             |
| inbox             |
| outbox            |
| outbox_multipart  |
| pbk               |
| pbk_groups        |
| phones            |
| sentitems         |
+-------------------+
9 rows in set (0.00 sec)

+++++++++++++++++++++++++++++++++++

After finishing the installation, you must create smsdrc config file and placed it in /etc directory. Or you can copy smsdrc config file from unpacked gammu source file. Note: i am using huawei usb modem, so i choose 'at' for connection and model parameter. Find your model and connection setting for your modem/phone. For this documentation is available at gammu official web site.

+++++++++++++++++++++++++++++++++++
root@0x49494949:~$ vim /etc/smsdrc
[gammu]
port = /dev/ttyUSB1
connection = at
model = at

[smsd]
service = mysql
PIN = 1234
logfile = /var/log/smsd.log
debuglevel = 1
commtimeout = 1
sendtimeout = 10
checksecurity = 0
deliveryreport = yes
user = war49
password = warwar123
pc = localhost
database = livesms
driver = mysql

+++++++++++++++++++++++++++++++++++++


Configuration was done, start gammu-smsd as a service.

++++++++++++++++++++++++++++++++++++++++++++++++++
root@0x49494949:~# /usr/local/bin/gammu-smsd -c /etc/smsdrc &
root@0x49494949:~# ps ax | grep gammu
26977 ? S 5:27 /usr/local/bin/gammu-smsd -c /etc/smsdrc

++++++++++++++++++++++++++++++++++++++++++++++++++

You can test for sending sms by gammu-smsd-inject command as appeared below.

++++++++++++++++++++++++++++++++++++++++++++++++++
root@0x49494949:~# gammu-smsd-inject -c /etc/smsdrc Text [destination-number] -text [SMS-Message]
root@0x49494949:~# gammu-smsd-inject -c /etc/smsdrc Text +628122674562 -text "Don't forget tonight"

++++++++++++++++++++++++++++++++++++++++++++++++++

Good luck !

0 comments:

Article list :