Tuesday, October 13, 2009

Installing configuring Gnokii on Linux

Gnokii provides tools and a user space driver for use with mobile phones under various operating systems (most testing is done under Linux but also Solaris, *BSD family and MS Windows families are known to work. Using Gnokii one can send/receive SMS, phonebook, call management and others.

Installation from rpm manager (yum)

Gnokii package is available via most of Linux distro repository, on Fedora 10 the below will install the gnokii package if not then do the installation from source.

yum install gnokii

Installing from Source:

1. Download the gnokii source download.
2. Untar the source and change (cd) to gnokii source directory

Run...

./configure (to configure)
make (to compile)
make install (to install the binaries)

Copy the example config file for gnokii from the Docs/sample/ directory to your home directory:

$ cp Docs/sample/gnokiirc ~/.gnokiirc

If you copied the .gnokiirc file to your home directory (not root) then do not forget to add your shell user account to uucp otherwise you wouldn't able to use gnokii due to permission problem on serial device you setup in .gnokiirc file.

$ groups
askar wheel uucp

I have tested Gnokii with my Motorola L6/L7 cell phones check gnokii.org whether your phone is supported or not. (Tip.

Configuration.

Gnokii uses gnokiirc file for all this configuration, if gnokii has been installed via package manager then most probably it may have installed a /etc/gnokiirc file, the settings in this file will be used in the absence of a .gnokiirc file in your home directory.

Below is the minimum setting we need.

Note: usually you only need to edit the port and model part only

[global]
port = /dev/ttyACM0 # Set to port on which your phone is connect Tip: check /var/log/messages ]
model = AT
initlength = default
connection = serial
use_locking = no
serial_baudrate = 19200
smsc_timeout = 10
[xgnokii]
allow_breakage = 0
[gnokiid]
bindir = /usr/sbin/
#[connect_script]
#TELEPHONE = 12345678
[disconnect_script]
[logging]
debug = off # Turn it on for debugging
rlpdebug = off
xdebug = off

While phone is connected and /etc/gnokiirc or .gnokiirc has been setup properly.

2. Check if you phone has been recognize by gnokii.

gnokii --identify

GNOKII Version 0.6.27
IMEI : IMEI359411000810925
Manufacturer : Motorola CE, Copyright 2000
Model : GSM900","GSM1800","GSM1900","GS
Product name : GSM900","GSM1800","GSM1900","GS
Revision : R4513_G_08.B7.DCR_R

This is what I get for my Motorola L7 connected with via USB cable with my laptop running Fedora 10.

Note: you should see gnokii identified your cellphone/gsm modem, if you don't see it, update your ~/.gnokiirc or /etc/gnokiirc to suit your need

Note: During testing use 'root' account or you will need read/write permissions on whatever serial port you specify in /etc/gnokiirc or .gnokiirc file.


Using Gnokii

All the below information and more can be found here.

Backup & Restoration of phonebook on phone SM card using gnokii

Backup

gnokii --getphonebook SM 1 end --vcard > myphonebook.vcf

Restore

gnokii --writephonebook --vcard \< myphonebook.vcf

Handling calls


To dial a voice call:

gnokii --dialvoice 12345678


SMS Sending and Receiving

Use smsd if you need both to send and to receive SMS. You can use it with a file or a database backend.

If you only need to send, you can also use gnokii --sendsms, which reads message body from stdin.

Example:

echo "This is a test message" | gnokii --sendsms +12345678

Or

gnokii --sendsms +12345678
type your text and press

Ctrl+d to exit.

You can also use the utils/sendsms bash script that uses a text based interface using dialog as a more friendly frontend to gnokii --sendsms, allowing you to pick recipient numbers from your phonebooks instead of typing them on the command line.

In my next article you can learn how to use Gnokii + Nagios for sending SMS Notifications from Nagios whenever there is problem with any of the monitored host/service

16 comments:

  1. Found this very useful, thank you. May I suggest adding [global] to the beginning of the .gnokiirc file you've given? That's what it took to get my motorola l7 working with Ubuntu Hardy.

    ReplyDelete
  2. Anoop Sinha,

    Thanks for the correction, yes the [global] section is required and it was skipped during the copy/pasting my gnokiirc into the blog.

    ReplyDelete
  3. Thanks for the info, it was really useful with my Motorola SLVR L7. :)

    ReplyDelete
  4. can any1 please tell me the full procedure of this and make this worthy for me and helpful.? i'm intending to follow up with this as my college project.

    ReplyDelete
    Replies
    1. Hi this is the complete procedure for installation and configuring gnokii for sending/receiving sms on Linux box. If you still need more help then i would suggest to check gnokii.org and its mailing list.

      Delete
  5. Hi AliKhan
    I was setup gnokii to step Check if you phone has been recognize by gnokii.
    but i have a error : Telephone interface init failed: Command timed out .. Quiting

    Pleas help me fix this error .. Thank's

    ReplyDelete
    Replies
    1. Hi,

      Sorry these days i am out of country and cant help, however i would suggest to check on www.gnokii.org and its mailing list which is supported by the gnokii author itself.

      Delete
  6. Hey, dude how do you receive sms ? what is the command

    ReplyDelete
  7. You know, dude you fuckin nailed this shit. i got it.

    ReplyDelete
  8. For Nokia 5800 try changing the port in gnokiirc, and then try to run gnokii --identify?

    [global]
    port = /dev/ttyACM0

    ReplyDelete
  9. hi askar
    when i connected the nokia phone to the usb port and type the command
    tail -f /var/log/messages
    iam getting like this

    Mar 25 11:51:36 localhost kernel: usb 1-8: new high speed USB device number 48 using ehci_hcd
    Mar 25 11:51:36 localhost kernel: usb 1-8: New USB device found, idVendor=0421, idProduct=02e2
    Mar 25 11:51:36 localhost kernel: usb 1-8: New USB device strings: Mfr=1, Product=2, SerialNumber=3
    Mar 25 11:51:36 localhost kernel: usb 1-8: Product: Nokia 5230
    Mar 25 11:51:36 localhost kernel: usb 1-8: Manufacturer: Nokia

    iam unable to decide to which port it is connectded wheather its /dev/ttyS0 or /dev/ttyACMo

    ReplyDelete
    Replies
    1. Try /dev/ttyACM0

      2. Check if you phone has been recognize by gnokii.

      gnokii --identify

      Delete
    2. Good to see your latest post. Keep it up

      Delete