Developer's Guide
From GnokiiWiki
Contents |
Developing the library
You can help adding support for new phones or new functions, but first read the Roadmap and join the mailing lists to avoid duplicate efforts.
Get the sources from the git repository:
git clone git://git.savannah.nongnu.org/gnokii.git
Read Docs/gnokii-hackers-howto for a description of how the library works.
See also the other documents in Docs/ and the source of existing libgnokii functions.
Read the gnokii Changelog to know the latest changes in the code base and subscribe to the gnokii users mailing list and the gnokii commit mailing list and join the #gnokii IRC channel at irc.freenode.net. See gnokii support page for other details.
Adding new functions to libgnokii
This is a (possibly incomplete) checklist for adding a new function to libgnokii:
- if you need to create a new source file:
- create a new include file in
include/or ininclude/gnokiiusing existing files as a guide - add the new include file to
include/Makefile.amor toinclude/gnokii/Makefile.amas appropriate - add the new include file to
include/gnokii.h.inor only the public functions as appropriate - create the new source file in
common/ - add the new source file to
common/Makefile.amand to the files in the win32 directory (see below)
- create a new include file in
- if you DO NOT need to create a new source file:
- add the new public functions to
include/gnokii.h.in
- add the new public functions to
- if you're adding new commands to drivers add a new
GN_OP_*enum togn_operationbeforeGN_OP_Maxininclude/gnokii/data.h
Changes to win32/ directory
While only the latest Microsoft compiler is supported, the following files should be updated:
MSVC6/libgnokii.dsp MSVC8/libgnokii.vcproj MSVS2005/libgnokii.vcproj MSVS2008/libgnokii.vcproj
Developing gnokii
Adding a new command to gnokii
This is a (possibly incomplete) checklist for adding a new command to gnokii:
Changes to gnokii/ directory
- create the new source file in
gnokii/ - add the new source file to
gnokii/Makefile.amand to the files in the win32 directory (see below) - add a new
OPT_*enum in opt_index at the beginning ofgnokii/gnokii.c(add the enum value in a comment every 10 lines) - add a line to
long_options[]before{ 0, 0, 0, 0 }ingnokii/gnokii.c:parse_options() - add a line to
gals[]before{ 0, 0, 0, 0 }ingnokii/gnokii.c:parse_options() - add a "case" with a call to the appropriate function in the appropriate switch in
gnokii/gnokii.c:parse_options() - add a call to the appropriate function in the new source file to display usage in
gnokii/gnokii.c:usage()and its prototype ingnokii/gnokii-app.h
Changes to win32/ directory
While only the latest Microsoft compiler is supported, the following files should be updated:
MSVC6/gnokii.dsp MSVC8/gnokii.vcproj MSVS2005/gnokii.vcproj MSVS2008/gnokii.vcproj
Developing your programs
For a quick hack you can add your code to foogle() in gnokii/gnokii.c. Before trying to use functions that communicate with the phone remember to call businit(): it will connect to the phone and register busterminate() for you with atexit().
Even if libgnokii is already installed you must get the sources (see above) to use the include files.
From version 0.6.20 to 0.6.22 the make install target doesn't install the development files, you need to use make install-devel instead.
You just need to include one file that in turn includes all other files.
#include <gnokii.h>
You need to link your program with libgnokii:
gcc -Wall -o foo foo.c `pkg-config --libs gnokii`
Read the gnokii Changelog to know the latest changes in the code base and subscribe to gnokii mailing list, see gnokii support page for details on how to join the mailing list.
Sample programs written in C are available at Gnokii-extras
Other programming languages bindings
Perl
There is a perl module available for gnokii. It gives access to some of the public libgnokii routines from a perl-program. It is intended for application developers who want to use their favorite language in interfacing the phone data with databases, ldap-directories and (in the future) different calendar applications. It is written by Konstantin Agouros and support starts with revision 0.2.6-pre3 of gnokii.
The homepage of this module is http://www.agouros.de/gnokii
Please note that Perl binding has not been updated for some time and may not work with current libgnokii.
- A perl module called Gnokiismsd.pm for the SMS::Send module which allows easy sending via the mysql part of smsd.
PHP
Daniele Forsi prepared PHP bindings for libgnokii. It should be mostly up-to-date and
supports most of the useful things that you might use from a webpage, but not everything that gnokii supports (see the README for details).
Note that the easier solution for handling SMS from PHP is using smsd with the file module.
This extension has been tested with PHP 4 and with PHP 5.
Sources for current version are available from gnokii-extras git module:
git clone git://git.savannah.nongnu.org/gnokii/gnokii-extras.git
You can find information about older versions of phpgnokii at Daniele's site.
RUBY
Thyagarajan Shanmugham written a demonstration of ruby bindings for libgnokii. You can find it at http://github.com/thyagarajan/rubynokii/wikis/home
Bugs
Read instructions on the bug tracking system in gnokii support page, paragraph Bugzilla and other.
Examples
The main programs use almost all library functions and therefore are the biggest examples available:
- gnokii (see ChangeLog)
- xgnokii (see ChangeLog)
- smsd (see ChangeLog)
The following utilities may clarify usage of some functions in a more concise way:
- ppm2nokia (in
gnokii-extras/snippets/logo/) - sendsms (in
gnokii/utils/) - todologo (in
gnokii-extras/snippets/logo/) - waitcall (in
gnokii-extras/snippets/monitor/)
Browse the sources of all those programs (and some more) with a WWW interface:
- Main repository
- Applet for Symbian phones
- Alternate GUI
- Optional graphic files
- Additional programs and language bindings
- CODA file system
- KDE Address Book synchronization
- Zaurus frontend
The following examples use version 3 of libgnokii:
- dial a voice call by Daniele Forsi
- get battery level by Daniele Forsi
The following examples use version 2 of libgnokii:
- libgnokii example by BORBELY Zoltan.
- libgnokii example by Pawel Kot
- libgnokii example by Daniele Forsi
Error Codes
| Number | Constant | Description |
|---|---|---|
| 0 | GN_ERR_NONE | No error. |
| 1 | GN_ERR_FAILED | Command failed. |
| 2 | GN_ERR_UNKNOWNMODEL | Model specified isn't known/supported. |
| 3 | GN_ERR_INVALIDSECURITYCODE | Invalid Security code. |
| 4 | GN_ERR_INTERNALERROR | Problem occurred internal to model specific code. |
| 5 | GN_ERR_NOTIMPLEMENTED | Command called isn't implemented in model. |
| 6 | GN_ERR_NOTSUPPORTED | Function or connection type not supported by the phone or by the phone driver. |
| 7 | GN_ERR_USERCANCELED | User aborted the action. |
| 8 | GN_ERR_UNKNOWN | Unknown error - well better than nothing!! |
| 9 | GN_ERR_MEMORYFULL | The specified memory is full. |
| 10 | GN_ERR_NOLINK | Couldn't establish link with phone. |
| 11 | GN_ERR_TIMEOUT | Command timed out. |
| 12 | GN_ERR_TRYAGAIN | Try again. |
| 13 | GN_ERR_WAITING | Waiting for the next part of the message. |
| 14 | GN_ERR_NOTREADY | Device not ready. |
| 15 | GN_ERR_BUSY | Command is still being executed. |
| 16 | GN_ERR_INVALIDLOCATION | The given memory location is invalid. |
| 17 | GN_ERR_INVALIDMEMORYTYPE | Invalid type of memory. |
| 18 | GN_ERR_EMPTYLOCATION | The given location is empty. |
| 19 | GN_ERR_ENTRYTOOLONG | The given entry is too long. |
| 20 | GN_ERR_WRONGDATAFORMAT | Data format is not valid. |
| 21 | GN_ERR_INVALIDSIZE | Wrong size of the object. |
| 22 | GN_ERR_LINEBUSY | Outgoing call requested reported line busy. |
| 23 | GN_ERR_NOCARRIER | No Carrier error during data call setup? |
| 24 | GN_ERR_UNHANDLEDFRAME | The current frame isn't handled by the incoming function. |
| 25 | GN_ERR_UNSOLICITED | Unsolicited message received. |
| 26 | GN_ERR_NONEWCBRECEIVED | Attempt to read CB when no new CB received. |
| 27 | GN_ERR_SIMPROBLEM | SIM card missing or damaged. |
| 28 | GN_ERR_CODEREQUIRED | PIN or PUK code required. |
| 29 | GN_ERR_NOTAVAILABLE | The requested information is not available. |
| 30 | GN_ERR_NOCONFIG | Config file cannot be read. |
| 31 | GN_ERR_NOPHONE | Either global or given phone section cannot be found. |
| 32 | GN_ERR_NOLOG | Incorrect logging section configuration. |
| 33 | GN_ERR_NOMODEL | No phone model specified in the config file. |
| 34 | GN_ERR_NOPORT | No port specified in the config file. |
| 35 | GN_ERR_NOCONNECTION | No connection type specified in the config file. |
| 36 | GN_ERR_ASYNC | The actual response will be sent asynchronously. |

