All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guillaume Zajac <guillaume.zajac@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH_v6 4/5] emulator: add dun_ato_cb() definition and register it in GAtServer
Date: Fri, 20 May 2011 11:38:15 +0200	[thread overview]
Message-ID: <1305884296-2601-5-git-send-email-guillaume.zajac@linux.intel.com> (raw)
In-Reply-To: <1305884296-2601-1-git-send-email-guillaume.zajac@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 2006 bytes --]

---
 src/emulator.c |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/src/emulator.c b/src/emulator.c
index c17b901..fe2132d 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -241,6 +241,59 @@ error:
 	return;
 }
 
+static gboolean resume_ppp(gpointer user_data)
+{
+	struct ofono_emulator *em = user_data;
+
+	g_at_server_suspend(em->server);
+	g_at_ppp_resume(em->ppp);
+
+	return FALSE;
+}
+
+static void dun_ato_cb(GAtServer *server, GAtServerRequestType type,
+			GAtResult *result, gpointer user_data)
+{
+	struct ofono_emulator *em = user_data;
+	GAtResultIter iter;
+	int val;
+
+	DBG("");
+
+	if (em->ppp == NULL) {
+		g_at_server_send_final(server, G_AT_SERVER_RESULT_NO_CARRIER);
+		return;
+	}
+
+	switch (type) {
+	case G_AT_SERVER_REQUEST_TYPE_SET:
+		g_at_result_iter_init(&iter, result);
+		g_at_result_iter_next(&iter, "");
+
+		if (g_at_result_iter_next_number(&iter, &val) == FALSE)
+			goto error;
+
+		if (val != 0)
+			goto error;
+
+		g_at_server_send_intermediate(em->server, "CONNECT");
+		em->source = g_idle_add(resume_ppp, em);
+		break;
+
+	case G_AT_SERVER_REQUEST_TYPE_COMMAND_ONLY:
+		g_at_server_send_intermediate(em->server, "CONNECT");
+		em->source = g_idle_add(resume_ppp, em);
+		break;
+
+	default:
+error:
+		g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR);
+		break;
+	}
+
+	return;
+}
+
 static struct indicator *find_indicator(struct ofono_emulator *em,
 						const char *name, int *index)
 {
@@ -775,6 +828,7 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
 	case OFONO_EMULATOR_TYPE_DUN:
 		g_at_server_register(em->server, "D", dial_cb, em, NULL);
 		g_at_server_register(em->server, "H", dun_ath_cb, em, NULL);
+		g_at_server_register(em->server, "O", dun_ato_cb, em, NULL);
 		break;
 	case OFONO_EMULATOR_TYPE_HFP:
 		g_at_server_set_echo(em->server, FALSE);
-- 
1.7.1


  parent reply	other threads:[~2011-05-20  9:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-20  9:38 [PATCH_v6 0/5] Escape sequence and ATO0 implementation Guillaume Zajac
2011-05-20  9:38 ` [PATCH_v6 1/5] gathdlc: add g_at_hdlc_resume() API Guillaume Zajac
2011-05-25 10:39   ` Denis Kenzior
2011-05-20  9:38 ` [PATCH_v6 2/5] ppp_net: add ppp_net_resume_interface() API Guillaume Zajac
2011-05-25 10:39   ` Denis Kenzior
2011-05-20  9:38 ` [PATCH_v6 3/5] gatppp: add public suspend/resume APIs and suspended state Guillaume Zajac
2011-05-25 10:40   ` Denis Kenzior
2011-05-20  9:38 ` Guillaume Zajac [this message]
2011-05-25 10:43   ` [PATCH_v6 4/5] emulator: add dun_ato_cb() definition and register it in GAtServer Denis Kenzior
2011-05-20  9:38 ` [PATCH_v6 5/5] gsmdial: add escape sequence/ATH0/ATO0 testing option Guillaume Zajac
2011-05-25 10:43   ` Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1305884296-2601-5-git-send-email-guillaume.zajac@linux.intel.com \
    --to=guillaume.zajac@linux.intel.com \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.