Archive

Posts Tagged ‘gammu’

Using Kalkun and gammu-smsd with SQLite3

February 28, 2011 19 comments

It’s been a long time ago since i’ve started to thinking adding other database backend support besides MySQL. The problem is CodeIgniter (Kalkun is developed using CodeIgniter) and gammu-smsd both must support the database engine used, for example if CodeIgniter support PostgreSQL, than gammu-smsd must support PostgreSQL too, and so on. To make this dream comes true, i’ll have to “convert” all native SQL query to Codeigniter Active Record to make the query independent to all database engine because it’s handled by database driver.

Imagine that you want to install a software, but you only have SQLite3/PostgreSQL on your server, installing MySQL just for that can be huge problem. That’s the basic idea to support all database engine.

OK, for the first time, i’ve added SQLite3 support to Kalkun. But, it’s not as easy as i imagine to implement it. First, CodeIgniter doesn’t have official support for SQLite3, the driver only compatible with SQLite2, fortunately there’s community contribution that add SQLite3 through PDO (PHP Data Objects). So, you need pdo_sqlite extension on your PHP installation. Second, gammu-smsd also doesn’t have native support for sqlite3, otherwise it use libdbi.

Now let’s configure gammu-smsd to works with SQLite3 first. FYI, i’m using Mac OS X and gammu 1.29.0. Let’s install SQLite3 and libdbi drivers, i’m installing it using MacPorts.

$ sudo port install sqlite3
$ sudo port install libdbi
$ sudo port install libdbi-drivers

Next, compiling gammu with libdbi support. Make sure you get “Found libdbi: …” when running configure otherwise you can’t run gammu-smsd with SQLite3.

Create Kalkun database and import gammu database schema
Because of Kalkun New Installation, gammu database schema is not included on Kalkun source, now you’ve to import gammu database schema on your own (it’s included on gammu source eg. docs/sql/sqlite.sql). You can do the import using sqlite3 console:

$ sqlite3 kalkun.sqlite < docs/sql/sqlite.sql

or, if somehow it’s throw error “Error: near “/”: syntax error“, use this:

$ cat docs/sql/sqlite.sql | sqlite3 kalkun.sqlite

Or you can the import using SQLite3 client with GUI. I’m using SQLite Manager Firefox add-ons, off course you can use other SQLite client.

Next is import Kalkun database schema to the database, you can import it using your SQLite3 client or by Kalkun Installation. I’ll show you how to import using Kalkun installation. But before that you have to config the database first (it’s located on /application/config/database.php)

$db[‘default’][‘username’] = “”;
$db[‘default’][‘password’] = “”;
$db[‘default’][‘database’] = “sqlite:/path/to/database/kalkun.sqlite”;
$db[‘default’][‘dbdriver’] = “pdo”;

You only need to change the database path, SQLite doesn’t need username and password, and the driver should be pdo. It’s recommended to place your SQLite3 database outside your web root folder because of security issue.

Setting database permission, before launch Kalkun installation make sure the database is writable by web server user, you can give it world writable.

$ chmod 666 /path/to/sqlite3_db/
$ chmod 666 kalkun.sqlite

Next fire up Kalkun installation and choose SQLite3 on Database Setup.

Kalkun installation with SQLite3

Kalkun installation with SQLite3

Next, let’s configure gammu-smsd, open up your gammu-smsd configuration file a.k.a smsdrc

Service = SQL
Driver = sqlite3
database = kalkun.sqlite
dbdir = /path/to/sqlite3_db/

That’s all, now run your gammu-smsd, check logs and see if it’s working (no error). You can try sending SMS using gammu-smsd-inject:

$ gammu-smsd-inject TEXT 123456 -text “Hi, this is gammu sending using sqlite3”

Next, try sending SMS using Kalkun 😀

..

PS: SQLite is famously knows for it’s liteness, but it’s may slower with network access and lots of activity/user using the same resource. So make sure you know what are you doing before using it.

Implemented on commit #fa845a4

Categories: kalkun Tags: , ,

Backup/export your contacts using gammu

February 23, 2011 Leave a comment

This tutorial will explain step-by-step how to backup/export your contacts using gammu.

Some people might have hundred or even thousand contacts saved in their SIM card or phone memory. Imagine if such important data loss by accident and you don’t have backup? You must be so upset :/

So, let’s do the backup 😀

First, you need supported phone/modem by gammu.

Next, install gammu itself.
FYI, i’m using Mac OS X 10.5.8 and have installed gammu 1.28.0 version, but there is a bug as i mention on gammu bug tracker here. So, i try the 1.29.0 version, but no luck again, i got “ld: library not found for -lglib-2.0” when compiling, and looks someone also get same problem and report it to the developer. I’m trying the latest version again (1.29.90), but out of luck again, now i’m getting “cc1: warnings being treated as errors“. I decided to go back to 1.29.0 version and searching “glib” keyword on gammu documentation and it’s said that it needed by gammu-detect library, which i don’t need one so i decided to disable it on cmake.

$ mkdir build
$ cd build
$ cmake -DWITH_Glib=OFF ..
$ make

It’s works like a charm 😀

Now, let’s go to the main topic, the backup!

To list available contacts on your SIM card:

$ gammu getallmemory SM
List available contacts

List available contacts

Why there’s only 2 of them? Yes, it’s just an example, you may see hundred/thousand entry on your phone.
Please note there are another memory type supported by gammu, like ME for phone internal memory, you can see complete list here.

Now, to do the backup as vcf format:

$ gammu backup gammu_contact_backup.vcf -yes

That’s it! Now, you can open the file with your Contact Management Software like Address Book on Mac OS X, or if you open it text editor you’ll see something like this.

Open up vcf backup file with text editor

Open up vcf backup file with text editor

So, what’s next?

  • You can keep the backup file and restore it to your phone if you loss your contact.
  • Import it to other app, for example Gmail 😀
Import contact to Gmail

Import contact to Gmail

  • Or, even better, import it to Kalkun 😀
    But, Kalkun only support CSV import, so you need to convert it first. Fortunately, there is a online tool to do that, VCF to CSV converter
Convert VCF to CSV

Convert VCF to CSV

Next, fire up OpenOffice Calc or other spreadsheet and remove unneeded header.

Before clean up

Before clean up

After clean up

After clean up

And the rest, just follow instruction how to import it to Kalkun here.

That’s it! Hope it will help someone out there, cheers 😀

Using gammu-smsd with multiple phone

July 27, 2010 57 comments

This mini tutorial will show you how to use gammu-smsd with multiple modem.

The idea of using multiple modem is you want to have backup on your system, or you want to use some scheduler where the first modem work on the day and the second one works on the night, or anything else, it’s depends on your need.

In this implementation, i’m using gammu 1.28 (compilled with MySQL support) and my modem is Sierra Wireless Aircard 881 and Wavecom Fasttrack Supreme WM20392.

OK, now let’s create smsdrc config for these two modem. You can put it anywhere, i’m choosing /etc/.smsdrc-sierra and /etc/.smsdrc-fasttrack.

This is /etc/.smsdrc-sierra configuration:

[gammu]
device = /dev/tty.sierra05
connection = at115200

[smsd]
service = MYSQL
PIN = 1234
logfile = /etc/.smsdlog-sierra
debuglevel = 255
phoneid = sierra

user = root
password = password
pc = localhost
database = kalkun

And /etc/.smsdrc-fasttrack configuration:

[gammu]
device = /dev/tty.PL2303-0000101D
connection = at115200

[smsd]
service = MYSQL
PIN = 1234
logfile = /etc/.smsdlog-fasttrack
debuglevel = 255
phoneid = fasttrack

user = root
password = password
pc = localhost
database = kalkun

Now, you can run each daemon by passing configuration parameter on it:

$ gammu-smsd -c /etc/.smsdrc-sierra

and

$ gammu-smsd -c /etc/.smsdrc-fasttrack

As you can see, the configuration for this two modem is almost the same, except for one thing, phoneid. phoneid is the key, it’s unique string for every modem you’ve configured. So, if you want to send sms through the first modem (in this case, it’s sierra), you have to specified this in your CreatorID and SenderID field on outbox parameter, for example the SQL statement should be something like this:

INSERT INTO outbox (DestinationNumber, TextDecoded, SenderID, CreatorID, Coding) VALUES (‘123456’, ‘Hi, this is sierra.’, ‘sierra’, ‘sierra’, ‘Default_No_Compression’);

Or you can easily do that with gammu-smsd-inject:

$ gammu-smsd-inject -c /etc/.smsdrc-sierra TEXT 123456 -text “Hi, this is sierra.”

Where 123456 is your destination number, you’ve to change it.

So, if you want to send sms over the second modem (in this case, fasttrack), it’s should be like this:

INSERT INTO outbox (DestinationNumber, TextDecoded, SenderID, CreatorID, Coding) VALUES (‘123456’, ‘Hi, this is fasttrack.’, ‘fasttrack’, ‘fasttrack’, ‘Default_No_Compression’);

Or, if you are using gammu-smsd-inject:

$ gammu-smsd-inject -c /etc/.smsdrc-fasttrack TEXT 123456 -text “Hi, this is fasttrack.”

OK, now sending sms over multiple modem is works like a charm.

Now, you may ask, how to detect incoming sms comes from which modem? sierra or fasttrack?

The answer is look at the RecipientID from the inbox table, it’s show which modem has the incoming sms. Quick SQL code to get incoming sms from specific modem:

SELECT * FROM inbox where RecipientID=’sierra’;

Or, if you want to get incoming sms from fasttrack:

SELECT * FROM inbox where RecipientID=’fasttrack’;

That’s all for multiple modem 😀
Kalkun should have this feature in the future 🙂

Installing gammu on Mac OS X

July 16, 2010 48 comments

This mini tutorial will explain howto install gammu on Mac OS X, i’m using Mac OS X 10.5.8 and gammu 1.28.0.
To install gammu, you need cmake, and i’m using cmake 2.8.2, i installed it using Homebrew package manager.

To install Homebrew:

$ ruby -e "$(curl -fsS http://gist.github.com/raw/323731/install_homebrew.rb)"

Then, you can install cmake with:

$ brew install cmake
Download gammu 1.28.0 here
Next, extract and install it:
$ ./configure
$ make
If you got errors like this:
Scanning dependencies of target array-test
[ 35%] Building C object tests/CMakeFiles/array-test.dir/array-test.o
Linking C executable array-test
[ 35%] Built target array-test
Scanning dependencies of target at-charset
[ 35%] Building C object tests/CMakeFiles/at-charset.dir/at-charset.o
Linking C executable at-charset
Undefined symbols:
“_iconv_open”, referenced from:
_IconvDecode in libGammu.a(coding.o)
_IconvEncode in libGammu.a(coding.o)
“_iconv_close”, referenced from:
_IconvDecode in libGammu.a(coding.o)
_IconvEncode in libGammu.a(coding.o)
“_iconv”, referenced from:
_IconvDecode in libGammu.a(coding.o)
_IconvEncode in libGammu.a(coding.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status
make[3]: *** [tests/at-charset] Error 1
make[2]: *** [tests/CMakeFiles/at-charset.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [all] Error 2
Then you’ve to configure cmake build to disable libiconv
$ mkdir build
$ cd build
$ cmake -DWITH_Iconv=OFF ..
$ make
$ sudo make install
Now, let’s connect the modem, i’m using Sierra USB Connect 881, and i got this information on /var/log/system.log:
Jul 16 22:34:10 macbooks-macbook kernel[0]: SierraSwitch: Version number – 1.2.1
Jul 16 22:34:10 macbooks-macbook kernel[0]: SierraSwitch: Driver Mode is 2 (Force Modem)
Jul 16 22:34:10 macbooks-macbook kernel[0]: SierraSwitch: Device version information for Mac OS:
Jul 16 22:34:10 macbooks-macbook kernel[0]: SierraSwitch: Revision = 0, SIPC = 24577(6001), SI Version = 1(1), CDPC = 0, CD Version = 0.0.0
Jul 16 22:34:10 macbooks-macbook kernel[0]: USBF:    41970.457    IOUSBInterface[0x418a700]::joinPMtree – could not find the hub device
Jul 16 22:34:13 macbooks-macbook kernel[0]: 0        0 SierraSupport: start – Default, suspend enabled for this device
Jul 16 22:34:13 macbooks-macbook kernel[0]: SierraSupport: Version number – 1.4.7, Input buffers 16, Output buffers 24
Unfortunately, it does not show where the modem attached on /dev/, because we need it to gammu configuration. So, i search it manually:
$ ls -la /dev | grep sierra
And it shows:
crw-rw-rw-   1 root   wheel      17,   9 Jul 16 22:34 cu.sierra001
crw-rw-rw-   1 root   wheel      17,  13 Jul 16 22:34 cu.sierra05
crw-rw-rw-   1 root   wheel      17,  11 Jul 16 22:34 cu.sierracntl
crw-rw-rw-   1 root   wheel      17,   8 Jul 16 22:34 tty.sierra001
crw-rw-rw-   1 root   wheel      17,  12 Jul 17 01:04 tty.sierra05
crw-rw-rw-   1 root   wheel      17,  10 Jul 17 01:04 tty.sierracntl
Now, let’s create gammu config:
$ cp /usr/local/share/doc/gammu/examples/config/gammurc ~/.gammurc
Mine is something like this:
[gammu]
device = /dev/tty.sierra05
connection = at115200
Finally, test the connection:
===============================
Add MySQL support
===============================
For example, i’ve smsdrc (gammu-smsd config file) like this:
[gammu]
device = /dev/tty.sierra05
connection = at115200
[smsd]
service = MYSQL
PIN = 1234
logfile = /Users/White/.smsdlog
debuglevel = 255
Then i run gammu-smsd and it throws error:
macbooks-macbook:~ White$ gammu-smsd -c /Users/White/.smsdrc
Log filename is “/Users/White/.smsdlog”
gammu-smsd[97218]: MYSQL service was not compiled in!
gammu-smsd[97218]: Failed to setup SMSD service: Desired functionality has been disabled on compile time. (DISABLED[62])
Failed to run SMSD: Desired functionality has been disabled on compile time.
gammu-smsd[97218]: MYSQL service was not compiled in!
It’s because gammu can’t find mysql header library when you compile it.
To add MySQL support to gammu-smsd you need mysql installed, for example i use xampp for Mac OS X, and i’m using 1.7.3 version. All you need to do is download and install the XAMPP itself and the Developer package, cause it contains the header library we need.
.
Now, let’s compile gammu with mysql support, extract gammu as usual, edit cmake/FindMySQL.cmake, add your XAMPP mysql path, it should be look like this:
find_program(MYSQL_CONFIG mysql_config
${MYSQL_CONFIG_PREFER_PATH}
/usr/local/mysql/bin/
/usr/local/bin/
/usr/bin/
/Applications/XAMPP/xamppfiles/bin/
)
Then, let’s configure cmake:
$ mkdir build
$ cd build
$ cmake -DMYSQL_LIBRARIES=/Applications/XAMPP/xamppfiles/lib/mysql/libmysqlclient_r.dylib ..
If everything OK, then it should be show something like this one:
— Configuring Gammu 1.28.0
— Could NOT find Doxygen  (missing:  DOXYGEN_EXECUTABLE)
— Using mysql-config: /Applications/XAMPP/xamppfiles/bin/mysql_config
— Found MySQL: /Applications/XAMPP/xamppfiles/include/mysql, /Applications/XAMPP/xamppfiles/lib/mysql/libmysqlclient_r.dylib
— Could not find PostgreSQL
Then make and make install:
$ make
$ sudo make install
Finally, run gammu-smsd again, if it doesn’t throw errors, then you’ve succeded, congrats 🙂
Have fun with gammu and gammu-smsd  😀
Categories: Open Source Tags: ,

Dicari: Penterjemah untuk [GW]ammu

December 21, 2009 Leave a comment

Agak miris memang, gammu yang menurut google trends dan alexa paling banyak diakses dan dicari oleh orang Indonesia, tapi menurut statistik, translation untuk bahasa Indonesia tenyata masih sangat minim. Kemanakah orang-orang kita? Apakah hanya mau pakai nya saja? saya rasa tidak, mungkin belum banyak yang tahu saja bahwa gammu ini membutuhkan kontributor untuk penterjemah ke bahasa kita masing-masing, supaya orang-orang yang tidak terlalu mengerti bahasa Inggris tetap bisa menggunakan software ini.

Jadi, bagaimana cara saya berkontribusi?
Ada beberapa cara dalam men-translate gammu dan wammu ini (seperti dijelaskan disini), tapi menurut saya yang paling enak dan nyaman adalah dengan menggunakan pottle, karena sistem nya berbasis web, silahkan daftar kemudian pilih bahasa Indonesia dan mulai men-translate.

Ingat:
Berkontribusi bukan hanya dengan ikut memprogram dan memberikan donasi, menterjemah juga adalah suatu bentuk kontribusi, yang akan membantu orang lain nantinya.

Categories: Open Source Tags: ,