summaryrefslogtreecommitdiffstats
path: root/plugins/ifx.c
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2010-10-01 06:38:02 +0200
committerMarcel Holtmann <marcel@holtmann.org>2010-10-01 06:38:02 +0200
commit7dbdf462152c6c1a7acea51576bcd6ce8234f014 (patch)
treef90393c29e05b486f3809c0524581f00a1578a1a /plugins/ifx.c
parent99afae03935da5b24bd99fa1f884b43157c19fa3 (diff)
downloadofono-7dbdf462152c6c1a7acea51576bcd6ce8234f014.tar.bz2
ifx: Use XGENDATA for modem model detection
The XGENDATA result contains various strings that also contain the modem model. Make this command mandatory for the modem bringup and after it succeeded, check for the XMM6260 string to setup specific audio settings. This makes using ENV{OFONO_IFX_MODEL}="XMM6260" obsolete, but for now it is still left as a possible option. It might be removed later.
Diffstat (limited to 'plugins/ifx.c')
-rw-r--r--plugins/ifx.c57
1 files changed, 45 insertions, 12 deletions
diff --git a/plugins/ifx.c b/plugins/ifx.c
index 3e8bcb0f..58e6db1f 100644
--- a/plugins/ifx.c
+++ b/plugins/ifx.c
@@ -75,7 +75,6 @@ static const char *dlc_nodes[NUM_DLC] = { "/dev/ttyGSM1", "/dev/ttyGSM2",
static const char *none_prefix[] = { NULL };
static const char *xdrv_prefix[] = { "+XDRV:", NULL };
-static const char *xgendata_prefix[] = { "+XGENDATA:", NULL };
struct ifx_data {
GIOChannel *device;
@@ -235,25 +234,38 @@ done:
data->device = NULL;
}
-static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
+static void xgendata_query(gboolean ok, GAtResult *result, gpointer user_data)
{
struct ofono_modem *modem = user_data;
struct ifx_data *data = ofono_modem_get_data(modem);
- char buf[64];
+ GAtResultIter iter;
+ const char *gendata;
DBG("");
- if (!ok) {
- shutdown_device(data);
+ if (!ok)
+ goto error;
- ofono_modem_set_powered(modem, FALSE);
- return;
- }
+ g_at_result_iter_init(&iter, result);
- g_at_chat_send(data->dlcs[AUX_DLC], "AT+XGENDATA", xgendata_prefix,
- NULL, NULL, NULL);
+ if (!g_at_result_iter_next(&iter, "+XGENDATA:"))
+ goto error;
+
+ if (!g_at_result_iter_next_string(&iter, &gendata))
+ goto error;
+
+ DBG("\n%s", gendata);
+
+ if (g_str_has_prefix(gendata, " XMM6260") == TRUE) {
+ ofono_info("Detected XMM6260 modem");
+ data->audio_source = 4;
+ data->audio_dest = 3;
+ data->audio_context = 0;
+ }
if (data->audio_setting && data->audio_source && data->audio_dest) {
+ char buf[64];
+
/* configure source */
snprintf(buf, sizeof(buf), "AT+XDRV=40,4,%d,%d,%s",
data->audio_source,
@@ -296,6 +308,29 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
/* enable XSIM and XLOCK notifications */
g_at_chat_send(data->dlcs[AUX_DLC], "AT+XSIMSTATE=1", none_prefix,
NULL, NULL, NULL);
+
+ return;
+
+error:
+ shutdown_device(data);
+ ofono_modem_set_powered(modem, FALSE);
+}
+
+static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ struct ifx_data *data = ofono_modem_get_data(modem);
+
+ DBG("");
+
+ if (!ok) {
+ shutdown_device(data);
+ ofono_modem_set_powered(modem, FALSE);
+ return;
+ }
+
+ g_at_chat_send(data->dlcs[AUX_DLC], "AT+XGENDATA", NULL,
+ xgendata_query, NULL, NULL);
}
static gboolean dlc_ready_check(gpointer user_data)
@@ -338,7 +373,6 @@ error:
data->dlc_poll_source = 0;
shutdown_device(data);
-
ofono_modem_set_powered(modem, FALSE);
return FALSE;
@@ -384,7 +418,6 @@ static void setup_internal_mux(struct ofono_modem *modem)
error:
shutdown_device(data);
-
ofono_modem_set_powered(modem, FALSE);
}