gnokii-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

howto change gnokii driver on the run


From: Pawel Kot
Subject: howto change gnokii driver on the run
Date: Sat, 7 Jul 2007 15:44:56 +0200

Hi,

For the applications using libgnokii it may be important to change the
driver being used without restarting application and even without user
manually disconnecting the phone and reconnecting. Here's the
developers recipe.

We don't provide a separate function for the switch for various
reasons. First of all, config provided for gnokii may ba a config file
or memory based configuration. Moreover you could change any single
variable from the config. If you would have proposal for such API
please let me know (with patches preferably).

It is surprisingly easy what should be done to switch the driver:

First, close current connection:
error = gn_lib_phone_close(state);

Now, prepare new configuration. When you have new configuration in the memory:
ret = gn_cfg_memory_read(mem);
When you want to reread config file:
ret = gn_cfg_file_read(file);
or
ret = gn_cfg_read_default();
You may want just to switch the phone section being used in already
read config file:
ret = gn_cfg_phone_load(section, state); /* default section is "global" */
If you want to change just some key value from the config:
ret = cfg_set(gn_cfg_info, section, key, value); /* to change the
driver to AT use key = "model", value = "AT" */
Please note that it will fail when the key is not present in the section.
We need definitely much improvement in out config API but current
functions seem to be quite powerful.

And finally reconnect:
error = gn_lib_phone_open(state);

I'll put this howto on gnokii wiki and feel free to comment and extend
it either here or on wiki.

take care,
pkot
--
Pawel Kot




reply via email to

[Prev in Thread] Current Thread [Next in Thread]