Gammu on a Windows computer for SMS Database

Posted on Updated on

If this page has helped you, please let me know, I’d love to hear, even send me a donation through PayPal.

 

Update December 2016

There are Windows Binaries now available. While I haven’t tried them yet, I’m sure they will work fine.

https://wammu.eu/download/gammu/

 

UPDATE 2016 September.

It looks like there could be some exciting stuff happening at this site. I haven’t had a chance to try it yet though. But, it could be promising.
https://www.bountysource.com/issues/25900604-build-windows-binaries

UPDATE 2016 March 29:
While I hope you’ve succeeded in getting Gammu working, there is a chance you may not have as well. I struggled big time.

If you haven’t got anywhere, then I may have another solution for you.

I’ve just released some specialist software called ExtractSMSDB, that will extract the SMS data from a Mobile Partner database to a CSV file. On Sale! 50% off! Only $20!

Original Post:

Here we go again with trying to get some more technology working. Once again it’s for a radio station set up, where we can get SMS’s to be received on a screen in the studio, but also so that those messages can be viewed and analysed on a local intranet.

This is the journey of getting this working on a Windows computer network. I am writing it as I go too, so I remember an problems along the way.

As a side note, I used this post as a big help. Trouble was it’s in German. My German isn’t so good… But I believe it’s important to give credit where it’s due.

Firstly, I bought 2 modems from ebay. The cheapest 4G USB modems I could find with cheap postage – about $15 each or so I think. STC QUICKnet 4G 100Mbps. The tech specs are (which are the most important): Huawei E3276 (http://consumer.huawei.com/en/mobile-broadband/dongles/tech-specs/e3276-en.htm) It looks like this.

So they have now arrived, and I am trying to get this to work.

The first thing to do is plug it in and install the drivers if required. I’m doing it on a Windows 8.1 computer. There was some software on the modem call Mobile Partner. I’ve installed it and looks like this when I run it.

Screenshot 2015-06-26 13.11.07So the next thing to do is get the software required to make the SMS magic happen.

Get the software from this site: http://wammu.eu/download/gammu/1.33.0/

I discovered that if you get the installer files, they don’t have the sample config files. So just get the zip file you require.

http://dl.cihar.com/gammu/releases/windows/Gammu-1.33.0-Windows-64bit.zip

http://dl.cihar.com/gammu/releases/windows/Gammu-1.33.0-Windows.zip

Gammu doesn’t seem to have a Windows version or maintainer yet, so just check for the lastest version available. At the writing, this was the current version.

I didn’t try Wammu either, because I needed a web interface.

Extract those files to: c:\gammu

Screenshot 2015-06-26 13.15.22

Copy both files from C:\gammu\share\doc\gammu\examples\config\ to C:\gammu\bin\

Next, edit the “gammurc” in the C:\gammu\bin\ path.

For the modem I have, I checked what com port the modem was connected on. The computer reported COM9 in the software, however, I discovered that gammu actually thinks it is in COM8.

So when you edit the config file, keep in mind that you may have to fish around for the exact port.

Change your file to look like this:

[gammu]

device = com8:
connection = at19200

Screenshot 2015-06-26 13.18.48

When that is done, obviously save it.

Confirm this works

Screenshot 2015-06-26 13.20.29Download MAMP for Windows, or xammp or whatever setup for your webserver setup you want. I’m using MAMP because that was already installed on this computer and the deployment computer, but really, they all do the same thing.

Once you’ve set all that up, the real fun begins…

Open up http://localhost/phpMyAdmin/

There may be a port assigned to that website, just just check for your setup specifically. Could be 80, 8080, 8888… whatever.

For example, on my mac my MAMP setup comes up on this: http://localhost:8888/phpMyAdmin/

Click on “New” on the left side menu and enter ‘gammu’.

Screenshot 2015-06-26 13.28.09Choose ‘gammu’ on the left menu. When it’s loaded, go to Import at the top menu.

Click on “Browse” and choose the file: C:\gammu\share\doc\gammu\examples\sql\mysql.sql.

Scroll to the bottom of the browser window and chose “Go”

Screenshot 2015-06-26 13.30.37It should now look like this:

Screenshot 2015-06-26 13.31.28

Back to our text editor, we now also need to edit the file: ‘smsdrc’ and match the settings from ‘gammurc’. We we also be editing some other fields too, so be prepared. I just copied and pasted both lines with the device and connection.

Scroll down a little to around line 33 for “service = files”. Change this to “service = mysql”

Next, go download to about line 62 “# Database backends congfiguration”

Change your mysql database settings.

Because I’m lazy, and for ease of this tutorial I made it like this:

# Database backends congfiguration
user = root
password = root
pc = localhost
# pc can also contain port or socket path after colon (eg. localhost:/path/to/socket)
database = gammu

And finally, line 68 or so:

 # DBI configuration
driver = mysql

Next, you can text out if the device is working if you want. I’m tight and don’t have any credit on this SIM card, but it still worked.

 I next entered this: gammu -c smsdrc sendsms TEXT 04XXXXXXXX

Screenshot 2015-06-26 13.41.14I’m guessing the reference is if it sent correctly or not. I think 50 could be successful. Either way, I received a “You don’t have any credit” message from Optus. 🙂

Screenshot 2015-06-26 13.44.51As it’s now all working, it’s time to install gammu as a service, so that it automatically checks the SIM card on the modem.

You can do this by typing:

gammu-smsd -c smsdrc -i

Oops, you must be running CMD.exe as an Admin to do this.

Screenshot 2015-06-26 13.46.57If you do it wrong, you’ll get the message above. So, next, when you run CMD, do it this way: , cmd, ++

This is much better!
Screenshot 2015-06-26 13.50.11Now to get the text messaging web service working… Download Kalkun http://kalkun.sourceforge.net/ if you haven’t already. I just grabbed the zip file.

Next unzip that to the root path of your local website. For me, it’s going to be  C:\MAMP\htdocs\sms

It’ll look like this:

Screenshot 2015-06-26 14.25.17Edit this file with your correct database details around line 40:

C:\xampp\htdocs\sms\application\config\database.php

$db['default']['hostname'] = "localhost";

// MySQL
$db['default']['username'] = "root";
$db['default']['password'] = "root";
$db['default']['database'] = "gammu";
$db['default']['dbdriver'] = "mysql";

Open the website: http://localhost/sms and follow the instructions to set it up.

Hopefully that worked well for you.

Screenshot 2015-06-26 14.29.18 Screenshot 2015-06-26 14.30.21Next, you’ll see the bit that failed in red? Yep, that’s easy to fix. Now we go and remove that directory.

To be able to return to a setup again (if required), I’ve just renamed that path.

Screenshot 2015-06-26 14.31.26When you’ve done that, click on “Go to Application” and it should fire up.

Default username : kalkun
Password : kalkun

Next, is to test it…

So strangely enough, while I’m trying to get this working… I’ve got another problem. Gammu service is not working, or won’t start…

Screenshot 2015-06-26 14.48.54So right now, I’m chasing up a fix for this problem. It seems it could be a Microsoft .NET Framework 1.1 Service Pack 1

Downloaded and ran the file…

Screenshot 2015-06-26 14.56.46Ok, so next I go to the Gammu website looking for bugs. It has a solution. Let’s try it out.

Firstly, I uninstalled the service.

gammu-smsd -u

Next, I try the so-called solution. Ah, here is the problem… So let’s try and solve it.

Screenshot 2015-06-26 15.05.12So now after trying out a few things, I’ve copied the c:\gammu\bin\smsdrc file to c:\gammu\

Now to test it.

Yes, that worked, but now there is another problem…

Screenshot 2015-06-26 15.09.46I went searching for answers.

As it turns out, there are special things to do for a mysql setup

http://wammu.eu/docs/manual/smsd/sql.html#gammu-smsd-sql

http://wammu.eu/docs/manual/smsd/mysql.html#gammu-smsd-mysql

So I opened up phpmyadmin again and entered the following, and also followed the instructions.

Screenshot 2015-06-26 15.28.16A secondary BIG script is found here: C:\gammu\share\doc\gammu\examples\sql\mysql.sql – contrary to the documentation on the website.

So, we go to import: find that file and…

Discover all of those tables already exist, and so we get errors… Alright, let’s look again at something else.

C:\gammu\bin>gammu-smsd.exe -c c:\gammu
Log filename is "smsdlog"
gammu-smsd[22412]: Unknown DB driver
Failed to read config: Unknown error.

Unknown DB driver… So I look in my install path. C:\gammu\bin does not have any references to mysql. Eh?

So I download the not x64 bit version… whoa… look what is in the C:\gammu\bin path??? The libmysql.dll file. Ok, let’s copy it over and try that out.

Nope. no good still…

After playing and finding results, playing with settings… I’m going down a different path.

(maybe)

Apparently there is a compatibility issue with MySQL 5.5.?

After some more research… :/

Ok, for some reason, the X64 version DOES NOT WORK for me. Use the X86 version instead.

When you get the x86 version, you must download a file called libiconv-2.dll (download from here or somewhere else on the internet), but you must rename that file from libiconv2.dll to libiconv-2.dll. Don’t ask…

So right now, this is my smsdrc file

# This is a sample Gammu SMSD configuration file. It's required for gammu-smsd,
# see gammu-smsdrc(5) for documentation.

# Gammu configuration, this section is like section "gammu" in "gammurc" file,
# see gammurc(5) for documentation.
[gammu]
device = com8:
connection = at19200

# General SMSD settings, see gammu-smsdrc(5) for detailed description.
[smsd]
# SMSD service to use, one of FILES, MYSQL, PGSQL, DBI, SQL
service = SQL
# PIN for SIM card
PIN = 1234
# File (or stderr, syslog, eventlog) where information will be logged
logfile = smsdlog
# Amount of information being logged, each bit mean one level
debuglevel = 0

commtimeout = 30
sendtimeout = 30

# Database backends congfiguration
user = root
password = root
pc = localhost
database = gammu

host = localhost 
# DBI configuration
driver = native_mysql 


This is a nightmare right now. So much for out of the box.  After this I will try and do it in one go.

Ok, so after trying that stuff, it is working now. Kind of. These are the output results etc. To see the completed set up file, look at the bottom of this post.

Screenshot 2015-06-26 17.30.54So, you can see if that is working yourself by sending an SMS to your number, and then looking in the smsdlog file. It should be in the c:\gammu\bin path.

You will also see a few SMS messages in the phpmysqladmin like so:

Screenshot 2015-06-26 17.34.15However, the next stage to do is to get the daemon to do it’s magic and move the data around, so that when messages are received, they actually appear on the web interface. Right now… it is empty.

Screenshot 2015-06-26 17.36.09

So, we go back to c:\gammu\smsdrc and edit line 45 to:

runonreceive = C:\MAMP\htdocs\sms\scripts\daemon.bat

and we need to open and edit that file too and make it look like this:

:: Configure this (use absolute path)
:: php cli path
set PHP=C:\MAMP\bin\php\php5.5.0\php.exe
:: daemon.php path
set DAEMON=C:\MAMP\htdocs\sms\scripts\daemon.php

:: Execute
%PHP% %DAEMON%

This means that this script will get executed when a new message arrives.

I need to change the daemon.php file to the correct path.


And to test it, I just run C:\MAMP\htdocs\sms\scripts\daemon.bat And it works… Screenshot 2015-06-26 17.44.51Now to check the inbox… YES!!! Victory! Screenshot 2015-06-26 17.46.02Now to get the services permanently installed.

gammu-smsd -c smsdrc -i

Screenshot 2015-06-26 17.48.37And now to double check it. go to Run, and type in ‘services.msc’ and look for the service ‘Gammu SMSD Service’.

It should be set to Automatic. Next, double click on that option and it should look like the following, after you have clicked on start.

Screenshot 2015-06-26 17.50.04So hopefully now, you should have an install of Kalkun working on Gammu, in a Windows 8.1 environment.

Update: Just depending on how you’ve done it, like me, I have 2 config files that are mirrored. C:\gammu\smsdrc and C:\gammu\bin\smsdrc. I probably shouldn’t but that was due to all the testing and the multiple broken tutorials and foreign pages I searched through. I basically took a bit from here, and bit from there.

Here is the final smsdrc file:

# This is a sample Gammu SMSD configuration file. It's required for gammu-smsd,
# see gammu-smsdrc(5) for documentation.

# Gammu configuration, this section is like section "gammu" in "gammurc" file,
# see gammurc(5) for documentation.
[gammu]
device = com8:
connection = at19200
#device = /dev/ttyS1
#model = 6110
#connection = dlr3
#synchronizetime = yes
#logfile = gammulog # this is not used at all in SMSD mode
#logformat = textall
#use_locking = yes
#gammuloc = gammu.us
#startinfo = yes

# When uncomment this section and insert numbers here, smsd will process
# incoming sms only from numbers written here (incoming sms from all other
# numbers will be deleted)
#[include_numbers]
#number1 = 1234

# When uncomment this section and insert numbers here, smsd will process
# incoming sms from all numbers not written here (incoming sms from numbers
# written here will be deleted). This is "black" list.
# Note: after using "include_numbers" section this one will be ignored
#[exclude_numbers]
#number1 = 1234

# General SMSD settings, see gammu-smsdrc(5) for detailed description.
[smsd]
# SMSD service to use, one of FILES, MYSQL, PGSQL, DBI, SQL
service = SQL
# PIN for SIM card
PIN = 1234
# File (or stderr, syslog, eventlog) where information will be logged
logfile = smsdlog
# Amount of information being logged, each bit mean one level
debuglevel = 0
# Configuration for using more phones on same database
#phoneid = MyPhone1
# Script to be executed when new message has been received
runonreceive = C:\MAMP\htdocs\sms\scripts\daemon.bat 
# Commication frequency settings
commtimeout = 30
sendtimeout = 30
#receivefrequency = 0

# Phone communication settings
#checksecurity = 1
#resetfrequency = 0

# Delivery report configuration
#deliveryreport = no
#deliveryreportdelay = 10

# Ignoring broken SMSC
#skipsmscnumber = +48602123456

# Database backends congfiguration
user = root
password = root
pc = localhost
# pc can also contain port or socket path after colon (eg. localhost:/path/to/socket)
database = gammu

host = localhost 
# DBI configuration
driver = native_mysql 
# native_mysql
# driverspath = /gammu/bin/
# Database directory for sqlite
# dbdir = /var/lib/smsd

# Files backend configuration
#inboxpath = /var/spool/sms/inbox/
#outboxpath = /var/spool/sms/outbox/
#sentsmspath = /var/spool/sms/sent/
#errorsmspath = /var/spool/sms/error/
#inboxformat = unicode
#transmitformat = auto
#outboxformat = detail

Just in case you have trouble with the services:

Install: c:\gammu\bin\gammu-smsd -c smsdrc -i
Uninstall: c:\gammu\bin\gammu-smsd -u

I just hope this helps someone. It only took a whole afternoon! Let me know how you go!

Update: You may wish to double check that the service runs correctly. I’m still working of getting it to start automatically.

If you want an easy way of getting screenshots like this? Just install Dropbox, then when you get a window you want copied, press ALT+PRTSCRN. It’ll take that screen capture, and stick it in a folder called screenshots. Works a treat! 🙂

UPDATE 2015 Dec 24th:
I’ve had a lot of interest on this post. I’m curious how people go when using gammu as a front end, or Kalkun? I was unhappy with Kalkun due to some bugs in it.

Recently I have written my own front end, and I may reveal it in the coming months.

I’m considering releasing it for sale at some stage – probably around the $100-$400 mark depending on the license. My new version is has been designed for radio stations with some extra radio-specific bits thrown in. It’s currently in place at a studio and is working very well, but not quiet ready for a general release yet. So, consider this the first mention of it… like a sneak peak/spoiler.

Would anyone be interested in a new front end? 🙂 I have another under development.

UPDATE 2016 March 29:
While I hope you’ve succeeded in getting Gammu working, there is a chance you may not have as well. I struggled big time.

If you haven’t got anywhere, then I may have another solution for you.

I’ve just released some specialist software called ExtractSMSDB, that will extract the SMS data from a Mobile Partner database to a CSV file.

 

If this page has helped you, please let me know, I’d love to hear, even send me a donation through PayPal.

Advertisements

9 thoughts on “Gammu on a Windows computer for SMS Database

    Guntur said:
    July 30, 2015 at 4:00 am

    heyho, nice tutorial and walkthrough.
    i’m having trouble with my installation tho.
    i’m using win 7 and using odbc as driver to connect with gammu.
    i’m able to set up everything normal except this :

    – i can’t run Gammu-SMSD service from service.exe, when i click start, it is always give me Error #27 : The drive cannot find the sector requested.

    but, from cmd, if i type in ‘gammu-smsd -c smsdrc’, everything works normal, i am able to run kalkun with connected status, and be able send or receive sms.

    i need to install the service automatically, can you help me to solve this?

    thanks in advance.

      Stephen Monro responded:
      July 30, 2015 at 8:42 am

      Thanks for the message! Glad it could help you.

      Sadly I had the same problem. I can’t remember if I fixed it or or not. It seemed to be a common problem for windows users. I don’t know if a newer version would solve this or not, because a newer windows binary hasn’t been released yet.

      As a work around, maybe creating a batch file with “gammu-smsd -c smsdrc” could work, and just place the batch file in the windows startup folder? Just a thought. 🙂

      Also, sadly I’m not sure if Kalkun is being actively developed either. You may find a bug in it, where if you move a message to a folder that all messages from that number will be moved. I did at least.

    Stephen Monro responded:
    August 1, 2015 at 1:20 pm

    The other problem I’ve had with Gammu is that for text messages that have more than about 4 parts to it, they fail to import, or get hung up in the modem. I don’t know if it’s just me, but trying to run a message service, it needs to work. So unfortunately this has been a struggle for me at this stage…

    qtuanvt said:
    October 28, 2015 at 12:14 am

    Thanks. I installed it follow you.

    review said:
    January 9, 2016 at 1:19 pm

    Usually I do not learn article on blogs, but I would like to
    say that this write-up very compelled me to try and
    do it! Your writing taste has been surprised me. Thanks, very
    great article.

    Error, Start Gammu Service - gammu said:
    January 22, 2016 at 5:14 pm

    […] if helps, experienced lot of problems installing on windows yesterday, , documented successes , failures. may help you: https://stephenmonro.wordpress.com/2015/06/26/gammu-on-a-windows-computer-for-sms-database/ […]

    Tyias Yudha S said:
    August 5, 2016 at 10:33 pm

    i’m having error 1053 “timely fashion”, can you help me please how specific to solve it?
    Is there any corelation between gammu installation that is path too long on windows 10 and error 1053 ?

      Stephen Monro responded:
      August 5, 2016 at 10:56 pm

      Hi, I just googled the error, and found it’s a windiws service error, where the service is failing to load. https://wammu.eu/docs/manual/smsd/smsd.html
      That may point you in the right direction, as I dont have a good answer for you right now, and I’m currently overseas and not at my windows computer.

    ABHIJEET KUMAR said:
    June 25, 2017 at 2:25 am

    reagarding gammu smsd service, same problem was faced by me, and i just disabled the User Account Control (UAC) and it’s working fine. Open the following link for better idea-
    http://www.techgainer.com/disable-uac-prompts-specific-programs-windows/

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s