From 057860c4c7731a490c451b8c7c3d68e4257159ee Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Wed, 2 Sep 2009 19:37:55 -0700 Subject: [PATCH] Parse and use Device option from modem.conf --- plugins/g1.c | 7 ++++++- plugins/mbm.c | 7 ++++++- plugins/modemconf.c | 21 +++++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/plugins/g1.c b/plugins/g1.c index c5155757..c0f35f35 100644 --- a/plugins/g1.c +++ b/plugins/g1.c @@ -143,11 +143,16 @@ static int g1_probe(struct ofono_modem *modem) { GAtSyntax *syntax; GAtChat *chat; + const char *device; DBG(""); + device = ofono_modem_get_string(modem, "Device"); + if (device == NULL) + return -EINVAL; + syntax = g_at_syntax_new_full(g1_feed, g1_hint, G1_STATE_IDLE); - chat = g_at_chat_new_from_tty("/dev/smd0", syntax); + chat = g_at_chat_new_from_tty(device, syntax); g_at_syntax_unref(syntax); if (chat == NULL) diff --git a/plugins/mbm.c b/plugins/mbm.c index 5fbb3a42..c11c9c40 100644 --- a/plugins/mbm.c +++ b/plugins/mbm.c @@ -87,11 +87,16 @@ static int mbm_enable(struct ofono_modem *modem) { struct mbm_data *data = ofono_modem_get_data(modem); GAtSyntax *syntax; + const char *device; DBG("%p", modem); + device = ofono_modem_get_string(modem, "Device"); + if (!device) + return -EINVAL; + syntax = g_at_syntax_new_gsmv1(); - data->chat = g_at_chat_new_from_tty("/dev/ttyACM0", syntax); + data->chat = g_at_chat_new_from_tty(device, syntax); g_at_syntax_unref(syntax); if (!data->chat) diff --git a/plugins/modemconf.c b/plugins/modemconf.c index 3b34a6df..3a199382 100644 --- a/plugins/modemconf.c +++ b/plugins/modemconf.c @@ -23,6 +23,8 @@ #include #endif +#include + #include #define OFONO_API_SUBJECT_TO_CHANGE @@ -32,6 +34,22 @@ static GSList *modem_list = NULL; +static int set_device(struct ofono_modem *modem, + GKeyFile *keyfile, const char *group) +{ + char *device; + + device = g_key_file_get_string(keyfile, group, "Device", NULL); + if (!device) + return -EINVAL; + + ofono_modem_set_string(modem, "Device", device); + + g_free(device); + + return 0; +} + static struct ofono_modem *create_modem(GKeyFile *keyfile, const char *group) { struct ofono_modem *modem; @@ -43,6 +61,9 @@ static struct ofono_modem *create_modem(GKeyFile *keyfile, const char *group) modem = ofono_modem_create(driver); + if (!g_strcmp0(driver, "g1") || !g_strcmp0(driver, "mbm")) + set_device(modem, keyfile, group); + g_free(driver); return modem;