From 21a6a00646766c4751108878d18eaadc5306116c Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Tue, 26 Oct 2010 22:50:00 +0200 Subject: [PATCH] ifxmodem: Add support GPRS contexts with username and password --- drivers/ifxmodem/gprs-context.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/ifxmodem/gprs-context.c b/drivers/ifxmodem/gprs-context.c index 17a40528..b059f4ed 100644 --- a/drivers/ifxmodem/gprs-context.c +++ b/drivers/ifxmodem/gprs-context.c @@ -270,7 +270,7 @@ static void setup_cb(gboolean ok, GAtResult *result, gpointer user_data) { struct ofono_gprs_context *gc = user_data; struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc); - char buf[64]; + char buf[128]; if (!ok) { ofono_error("Failed to setup context"); @@ -278,14 +278,25 @@ static void setup_cb(gboolean ok, GAtResult *result, gpointer user_data) return; } + if (gcd->username[0] && gcd->password[0]) + sprintf(buf, "AT+XGAUTH=%u,1,\"%s\",\"%s\"", + gcd->active_context, gcd->username, gcd->password); + else + sprintf(buf, "AT+XGAUTH=%u,0,\"\",\"\"", gcd->active_context); + + if (g_at_chat_send(gcd->chat, buf, none_prefix, NULL, NULL, NULL) == 0) + goto error; + sprintf(buf, "AT+XDNS=%u,1", gcd->active_context); - g_at_chat_send(gcd->chat, buf, none_prefix, NULL, NULL, NULL); + if (g_at_chat_send(gcd->chat, buf, none_prefix, NULL, NULL, NULL) == 0) + goto error; sprintf(buf, "AT+CGACT=1,%u", gcd->active_context); if (g_at_chat_send(gcd->chat, buf, none_prefix, activate_cb, gc, NULL) > 0) return; +error: failed_setup(gc, NULL, FALSE); }