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 5/5] gsmdial: add escape sequence/ATH0/ATO0 testing option
Date: Fri, 20 May 2011 11:38:16 +0200	[thread overview]
Message-ID: <1305884296-2601-6-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: 3658 bytes --]

---
 gatchat/gsmdial.c |   73 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 73 insertions(+), 0 deletions(-)

diff --git a/gatchat/gsmdial.c b/gatchat/gsmdial.c
index a10e7cb..3fb6dfe 100644
--- a/gatchat/gsmdial.c
+++ b/gatchat/gsmdial.c
@@ -57,6 +57,7 @@ static gchar *option_username = NULL;
 static gchar *option_password = NULL;
 static gchar *option_pppdump = NULL;
 static gboolean option_bluetooth = FALSE;
+static gboolean option_esc = FALSE;
 
 static GAtPPP *ppp;
 static GAtChat *control;
@@ -237,6 +238,67 @@ static gboolean execute(const char *cmd)
 	return TRUE;
 }
 
+static void power_down_ppp(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	if (!ok)
+		return;
+
+	g_at_ppp_unref(ppp);
+	ppp = NULL;
+}
+
+static void ppp_suspend_ath0(gpointer user_data)
+{
+	g_at_chat_resume(modem);
+	g_at_chat_send(modem, "ATH0", none_prefix, power_down_ppp, NULL, NULL);
+}
+
+static void continue_test_sequence(gpointer data)
+{
+	/* Delete the write done CB */
+	g_at_io_set_write_done(g_at_chat_get_io(modem), NULL, NULL);
+
+	/*
+	 * We are sure there are no more PPP packets to be written,
+	 * we can suspend PPP client and send escape sequence
+	 */
+	g_at_ppp_suspend(ppp);
+}
+
+static void resume_ppp(gboolean ok, GAtResult *result, gpointer user_data)
+{
+	if (!ok)
+		return;
+
+	g_at_chat_suspend(modem);
+	g_at_ppp_set_suspend_function(ppp, ppp_suspend_ath0, NULL);
+	g_at_ppp_resume(ppp);
+	/*
+	 * As soon as a PPP packet is written by the client, we start
+	 * test sequence.
+	 */
+	g_at_io_set_write_done(g_at_chat_get_io(modem),
+					continue_test_sequence, NULL);
+}
+
+static void ppp_suspend_ato0(gpointer user_data)
+{
+	g_at_chat_resume(modem);
+	g_at_chat_send(modem, "ATO0", none_prefix, resume_ppp, NULL, NULL);
+}
+
+static void start_test_sequence(gpointer data)
+{
+	/* Delete the write done CB */
+	g_at_io_set_write_done(g_at_chat_get_io(modem), NULL, NULL);
+
+	/*
+	 * We are sure there are no more PPP packets to be written,
+	 * we can suspend PPP client and send escape sequence
+	 */
+	g_at_ppp_suspend(ppp);
+}
+
 static void ppp_connect(const char *iface, const char *local, const char *peer,
 			const char *dns1, const char *dns2,
 			gpointer user_data)
@@ -261,6 +323,14 @@ static void ppp_connect(const char *iface, const char *local, const char *peer,
 	snprintf(buf, sizeof(buf), "%s %s %s pointopoint %s", IFCONFIG_PATH,
 				iface, local, peer);
 	execute(buf);
+
+	/*
+	 * As soon as a PPP packet is written by the client, we start
+	 * test sequence.
+	 */
+	if (option_esc)
+		g_at_io_set_write_done(g_at_chat_get_io(modem),
+					start_test_sequence, NULL);
 }
 
 static void no_carrier_notify(GAtResult *result, gpointer user_data)
@@ -327,6 +397,7 @@ static void connect_cb(gboolean ok, GAtResult *result, gpointer user_data)
 	/* set connect and disconnect callbacks */
 	g_at_ppp_set_connect_function(ppp, ppp_connect, NULL);
 	g_at_ppp_set_disconnect_function(ppp, ppp_disconnect, NULL);
+	g_at_ppp_set_suspend_function(ppp, ppp_suspend_ato0, NULL);
 
 	/* open the ppp connection */
 	g_at_ppp_open(ppp);
@@ -624,6 +695,8 @@ static GOptionEntry options[] = {
 				"Use ATD*99***<cid>#" },
 	{ "bluetooth", 'b', 0, G_OPTION_ARG_NONE, &option_bluetooth,
 				"Use only ATD*99" },
+	{ "esc_seq", 'e', 0, G_OPTION_ARG_NONE, &option_esc,
+				"Send escape sequence test" },
 	{ "username", 'u', 0, G_OPTION_ARG_STRING, &option_username,
 				"Specify PPP username" },
 	{ "password", 'w', 0, G_OPTION_ARG_STRING, &option_password,
-- 
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 ` [PATCH_v6 4/5] emulator: add dun_ato_cb() definition and register it in GAtServer Guillaume Zajac
2011-05-25 10:43   ` Denis Kenzior
2011-05-20  9:38 ` Guillaume Zajac [this message]
2011-05-25 10:43   ` [PATCH_v6 5/5] gsmdial: add escape sequence/ATH0/ATO0 testing option 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-6-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.