Open Source Telephony
 help / color / mirror / Atom feed
* [PATCH_v4 0/8] Escape sequence test implementation
@ 2011-05-04 15:38 Guillaume Zajac
  2011-05-04 15:38 ` [PATCH_v4 1/8] gathdlc: delete read/write handler in hdlc_suspend and add public suspend function for testing Guillaume Zajac
                   ` (7 more replies)
  0 siblings, 8 replies; 16+ messages in thread
From: Guillaume Zajac @ 2011-05-04 15:38 UTC (permalink / raw)
  To: ofono

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

Hi all,

After set of patches has been applied, you can test it in launching:

sudo src/ofonod -nd '*' (with phonesim enabled and online)

sudo gsmdial -i xxx.xxx.xxx.xxx -p xxxx -b -e

This will establish a PPP connection and terminate it using "+++"
escape sequence and ATH0 command.

Change log from v3:
	- remove "+++" detection mechanism, use Denis implementation
	- "+++" is sent from GAtPPP not anymore from at_chat
	- suspend function is set in PPP server and PPP client
	  to resume at_chat
	- dun_ato_cb will be committed in separated set of patches

Guillaume Zajac (8):
  gathdlc: delete read/write handler in hdlc_suspend and add public
    suspend function for testing
  ppp_net: add ppp_net_suspend_interface() function
  gatppp: add function to set ppp_suspend() and proxy function to call
    ppp_net_suspend_interface()
  gatppp: add public suspend function for testing
  emulator: add suspend_ppp() definition and and register it into
    GAtPPP
  gsmdial: add new option to test escape sequence
  emulator: add dun_ath_cb() and register it
  gsmdial: add ATH0 command test

 gatchat/gathdlc.c |   12 +++++++++
 gatchat/gathdlc.h |    2 +
 gatchat/gatppp.c  |   59 +++++++++++++++++++++++++++++++++++++++++++++
 gatchat/gatppp.h  |    3 ++
 gatchat/gsmdial.c |   39 ++++++++++++++++++++++++++++++
 gatchat/ppp.h     |    1 +
 gatchat/ppp_net.c |    9 +++++++
 src/emulator.c    |   69 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 8 files changed, 192 insertions(+), 2 deletions(-)


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH_v4 1/8] gathdlc: delete read/write handler in hdlc_suspend and add public suspend function for testing
  2011-05-04 15:38 [PATCH_v4 0/8] Escape sequence test implementation Guillaume Zajac
@ 2011-05-04 15:38 ` Guillaume Zajac
  2011-05-09  4:10   ` Denis Kenzior
  2011-05-04 15:39 ` [PATCH_v4 2/8] ppp_net: add ppp_net_suspend_interface() function Guillaume Zajac
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Guillaume Zajac @ 2011-05-04 15:38 UTC (permalink / raw)
  To: ofono

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

---
 gatchat/gathdlc.c |   12 ++++++++++++
 gatchat/gathdlc.h |    2 ++
 2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/gatchat/gathdlc.c b/gatchat/gathdlc.c
index e3ab7ec..7989bd7 100644
--- a/gatchat/gathdlc.c
+++ b/gatchat/gathdlc.c
@@ -166,6 +166,9 @@ static gboolean hdlc_suspend(gpointer user_data)
 
 	g_at_io_drain_ring_buffer(hdlc->io, 3);
 
+	g_at_io_set_write_handler(hdlc->io, NULL, NULL);
+	g_at_io_set_read_handler(hdlc->io, NULL, NULL);
+
 	if (hdlc->suspend_func)
 		hdlc->suspend_func(hdlc->suspend_data);
 
@@ -610,3 +613,12 @@ void g_at_hdlc_set_no_carrier_detect(GAtHDLC *hdlc, gboolean detect)
 
 	hdlc->no_carrier_detect = detect;
 }
+
+void g_at_hdlc_suspend(GAtHDLC *hdlc)
+{
+	if (hdlc == NULL)
+		return;
+
+	g_at_io_set_write_handler(hdlc->io, NULL, NULL);
+	g_at_io_set_read_handler(hdlc->io, NULL, NULL);
+}
diff --git a/gatchat/gathdlc.h b/gatchat/gathdlc.h
index 158f27f..556e383 100644
--- a/gatchat/gathdlc.h
+++ b/gatchat/gathdlc.h
@@ -60,6 +60,8 @@ void g_at_hdlc_set_no_carrier_detect(GAtHDLC *hdlc, gboolean detect);
 void g_at_hdlc_set_suspend_function(GAtHDLC *hdlc, GAtSuspendFunc func,
 							gpointer user_data);
 
+void g_at_hdlc_suspend(GAtHDLC *hdlc);
+
 #ifdef __cplusplus
 }
 #endif
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH_v4 2/8] ppp_net: add ppp_net_suspend_interface() function
  2011-05-04 15:38 [PATCH_v4 0/8] Escape sequence test implementation Guillaume Zajac
  2011-05-04 15:38 ` [PATCH_v4 1/8] gathdlc: delete read/write handler in hdlc_suspend and add public suspend function for testing Guillaume Zajac
@ 2011-05-04 15:39 ` Guillaume Zajac
  2011-05-09  4:11   ` Denis Kenzior
  2011-05-04 15:39 ` [PATCH_v4 3/8] gatppp: add function to set ppp_suspend() and proxy function to call ppp_net_suspend_interface() Guillaume Zajac
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Guillaume Zajac @ 2011-05-04 15:39 UTC (permalink / raw)
  To: ofono

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

---
 gatchat/ppp.h     |    1 +
 gatchat/ppp_net.c |    9 +++++++++
 2 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/gatchat/ppp.h b/gatchat/ppp.h
index d2786d7..22809d8 100644
--- a/gatchat/ppp.h
+++ b/gatchat/ppp.h
@@ -107,6 +107,7 @@ const char *ppp_net_get_interface(struct ppp_net *net);
 void ppp_net_process_packet(struct ppp_net *net, const guint8 *packet);
 void ppp_net_free(struct ppp_net *net);
 gboolean ppp_net_set_mtu(struct ppp_net *net, guint16 mtu);
+void ppp_net_suspend_interface(struct ppp_net *net);
 
 /* PPP functions related to main GAtPPP object */
 void ppp_debug(GAtPPP *ppp, const char *str);
diff --git a/gatchat/ppp_net.c b/gatchat/ppp_net.c
index 1a6cdf7..9abf590 100644
--- a/gatchat/ppp_net.c
+++ b/gatchat/ppp_net.c
@@ -196,3 +196,12 @@ void ppp_net_free(struct ppp_net *net)
 	g_free(net->if_name);
 	g_free(net);
 }
+
+void ppp_net_suspend_interface(struct ppp_net *net)
+{
+	if (net == NULL || net->channel == NULL)
+		return;
+
+	if (net->watch)
+		g_source_remove(net->watch);
+}
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH_v4 3/8] gatppp: add function to set ppp_suspend() and proxy function to call ppp_net_suspend_interface()
  2011-05-04 15:38 [PATCH_v4 0/8] Escape sequence test implementation Guillaume Zajac
  2011-05-04 15:38 ` [PATCH_v4 1/8] gathdlc: delete read/write handler in hdlc_suspend and add public suspend function for testing Guillaume Zajac
  2011-05-04 15:39 ` [PATCH_v4 2/8] ppp_net: add ppp_net_suspend_interface() function Guillaume Zajac
@ 2011-05-04 15:39 ` Guillaume Zajac
  2011-05-09  4:12   ` Denis Kenzior
  2011-05-04 15:39 ` [PATCH_v4 4/8] gatppp: add public suspend function for testing Guillaume Zajac
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Guillaume Zajac @ 2011-05-04 15:39 UTC (permalink / raw)
  To: ofono

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

---
 gatchat/gatppp.c |   24 ++++++++++++++++++++++++
 gatchat/gatppp.h |    2 ++
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c
index 993b5ea..c776811 100644
--- a/gatchat/gatppp.c
+++ b/gatchat/gatppp.c
@@ -76,6 +76,8 @@ struct _GAtPPP {
 	gpointer debug_data;
 	gboolean sta_pending;
 	guint ppp_dead_source;
+	GAtSuspendFunc suspend_func;
+	gpointer suspend_data;
 };
 
 void ppp_debug(GAtPPP *ppp, const char *str)
@@ -467,6 +469,28 @@ void g_at_ppp_set_debug(GAtPPP *ppp, GAtDebugFunc func, gpointer user_data)
 	ppp->debug_data = user_data;
 }
 
+static void ppp_proxy_suspend_net_interface(gpointer user_data)
+{
+	GAtPPP *ppp = user_data;
+
+	ppp_net_suspend_interface(ppp->net);
+
+	if (ppp->suspend_func)
+		ppp->suspend_func(ppp->suspend_data);
+}
+
+void g_at_ppp_set_suspend_function(GAtPPP *ppp, GAtSuspendFunc func,
+					gpointer user_data)
+{
+	if (ppp == NULL)
+		return;
+
+	ppp->suspend_func = func;
+	ppp->suspend_data = user_data;
+	g_at_hdlc_set_suspend_function(ppp->hdlc,
+					ppp_proxy_suspend_net_interface, ppp);
+}
+
 void g_at_ppp_shutdown(GAtPPP *ppp)
 {
 	if (ppp->phase == PPP_PHASE_DEAD || ppp->phase == PPP_PHASE_TERMINATION)
diff --git a/gatchat/gatppp.h b/gatchat/gatppp.h
index fb5de4c..9464ffd 100644
--- a/gatchat/gatppp.h
+++ b/gatchat/gatppp.h
@@ -60,6 +60,8 @@ void g_at_ppp_set_connect_function(GAtPPP *ppp, GAtPPPConnectFunc callback,
 					gpointer user_data);
 void g_at_ppp_set_disconnect_function(GAtPPP *ppp, GAtPPPDisconnectFunc func,
 					gpointer user_data);
+void g_at_ppp_set_suspend_function(GAtPPP *ppp, GAtSuspendFunc func,
+					gpointer user_data);
 void g_at_ppp_set_debug(GAtPPP *ppp, GAtDebugFunc func, gpointer user_data);
 void g_at_ppp_shutdown(GAtPPP *ppp);
 void g_at_ppp_ref(GAtPPP *ppp);
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH_v4 4/8] gatppp: add public suspend function for testing
  2011-05-04 15:38 [PATCH_v4 0/8] Escape sequence test implementation Guillaume Zajac
                   ` (2 preceding siblings ...)
  2011-05-04 15:39 ` [PATCH_v4 3/8] gatppp: add function to set ppp_suspend() and proxy function to call ppp_net_suspend_interface() Guillaume Zajac
@ 2011-05-04 15:39 ` Guillaume Zajac
  2011-05-09  4:13   ` Denis Kenzior
  2011-05-04 15:39 ` [PATCH_v4 5/8] emulator: add suspend_ppp() definition and and register it into GAtPPP Guillaume Zajac
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Guillaume Zajac @ 2011-05-04 15:39 UTC (permalink / raw)
  To: ofono

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

---
 gatchat/gatppp.c |   35 +++++++++++++++++++++++++++++++++++
 gatchat/gatppp.h |    1 +
 2 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c
index c776811..67f0a28 100644
--- a/gatchat/gatppp.c
+++ b/gatchat/gatppp.c
@@ -46,6 +46,9 @@
 #define PPP_ADDR_FIELD	0xff
 #define PPP_CTRL	0x03
 
+/* Time to wait before and after +++ sequence */
+#define GUARD_TIMEOUTS 1500
+
 enum ppp_phase {
 	PPP_PHASE_DEAD = 0,		/* Link dead */
 	PPP_PHASE_ESTABLISHMENT,	/* LCP started */
@@ -500,6 +503,38 @@ void g_at_ppp_shutdown(GAtPPP *ppp)
 	pppcp_signal_close(ppp->lcp);
 }
 
+static gboolean call_suspend_cb(gpointer user_data)
+{
+	GAtPPP *ppp = user_data;
+
+	if (ppp->suspend_func)
+		ppp->suspend_func(ppp->suspend_data);
+
+	return FALSE;
+}
+
+static gboolean send_escape_sequence(gpointer user_data)
+{
+	GAtPPP *ppp = user_data;
+	GAtIO *io = g_at_hdlc_get_io(ppp->hdlc);
+
+	g_at_io_write(io, "+++", 3);
+
+	g_timeout_add(GUARD_TIMEOUTS, call_suspend_cb, ppp);
+
+	return FALSE;
+}
+
+void g_at_ppp_suspend(GAtPPP *ppp)
+{
+	if (ppp == NULL)
+		return;
+
+	ppp_net_suspend_interface(ppp->net);
+	g_at_hdlc_suspend(ppp->hdlc);
+	g_timeout_add(GUARD_TIMEOUTS, send_escape_sequence, ppp);
+}
+
 void g_at_ppp_ref(GAtPPP *ppp)
 {
 	g_atomic_int_inc(&ppp->ref_count);
diff --git a/gatchat/gatppp.h b/gatchat/gatppp.h
index 9464ffd..66e0ade 100644
--- a/gatchat/gatppp.h
+++ b/gatchat/gatppp.h
@@ -64,6 +64,7 @@ void g_at_ppp_set_suspend_function(GAtPPP *ppp, GAtSuspendFunc func,
 					gpointer user_data);
 void g_at_ppp_set_debug(GAtPPP *ppp, GAtDebugFunc func, gpointer user_data);
 void g_at_ppp_shutdown(GAtPPP *ppp);
+void g_at_ppp_suspend(GAtPPP *ppp);
 void g_at_ppp_ref(GAtPPP *ppp);
 void g_at_ppp_unref(GAtPPP *ppp);
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH_v4 5/8] emulator: add suspend_ppp() definition and and register it into GAtPPP
  2011-05-04 15:38 [PATCH_v4 0/8] Escape sequence test implementation Guillaume Zajac
                   ` (3 preceding siblings ...)
  2011-05-04 15:39 ` [PATCH_v4 4/8] gatppp: add public suspend function for testing Guillaume Zajac
@ 2011-05-04 15:39 ` Guillaume Zajac
  2011-05-09  4:16   ` Denis Kenzior
  2011-05-04 15:39 ` [PATCH_v4 6/8] gsmdial: add new option to test escape sequence Guillaume Zajac
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 16+ messages in thread
From: Guillaume Zajac @ 2011-05-04 15:39 UTC (permalink / raw)
  To: ofono

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

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

diff --git a/src/emulator.c b/src/emulator.c
index 9055909..5963ffb 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -105,6 +105,15 @@ static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data)
 	g_at_server_resume(em->server);
 }
 
+static void ppp_suspend(gpointer user_data)
+{
+	struct ofono_emulator *em = user_data;
+
+	DBG("");
+
+	g_at_server_resume(em->server);
+}
+
 static gboolean setup_ppp(gpointer user_data)
 {
 	struct ofono_emulator *em = user_data;
@@ -132,6 +141,7 @@ static gboolean setup_ppp(gpointer user_data)
 
 	g_at_ppp_set_connect_function(em->ppp, ppp_connect, em);
 	g_at_ppp_set_disconnect_function(em->ppp, ppp_disconnect, em);
+	g_at_ppp_set_suspend_function(em->ppp, ppp_suspend, em);
 
 	return FALSE;
 }
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH_v4 6/8] gsmdial: add new option to test escape sequence
  2011-05-04 15:38 [PATCH_v4 0/8] Escape sequence test implementation Guillaume Zajac
                   ` (4 preceding siblings ...)
  2011-05-04 15:39 ` [PATCH_v4 5/8] emulator: add suspend_ppp() definition and and register it into GAtPPP Guillaume Zajac
@ 2011-05-04 15:39 ` Guillaume Zajac
  2011-05-04 15:39 ` [PATCH_v4 7/8] emulator: add dun_ath_cb() and register it Guillaume Zajac
  2011-05-04 15:39 ` [PATCH_v4 8/8] gsmdial: add ATH0 command test Guillaume Zajac
  7 siblings, 0 replies; 16+ messages in thread
From: Guillaume Zajac @ 2011-05-04 15:39 UTC (permalink / raw)
  To: ofono

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

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

diff --git a/gatchat/gsmdial.c b/gatchat/gsmdial.c
index a10e7cb..31bb910 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,23 @@ static gboolean execute(const char *cmd)
 	return TRUE;
 }
 
+static void ppp_suspend(gpointer user_data)
+{
+	g_at_chat_resume(modem);
+}
+
+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 +279,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 +353,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, NULL);
 
 	/* open the ppp connection */
 	g_at_ppp_open(ppp);
@@ -624,6 +651,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


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH_v4 7/8] emulator: add dun_ath_cb() and register it
  2011-05-04 15:38 [PATCH_v4 0/8] Escape sequence test implementation Guillaume Zajac
                   ` (5 preceding siblings ...)
  2011-05-04 15:39 ` [PATCH_v4 6/8] gsmdial: add new option to test escape sequence Guillaume Zajac
@ 2011-05-04 15:39 ` Guillaume Zajac
  2011-05-09  4:19   ` Denis Kenzior
  2011-05-04 15:39 ` [PATCH_v4 8/8] gsmdial: add ATH0 command test Guillaume Zajac
  7 siblings, 1 reply; 16+ messages in thread
From: Guillaume Zajac @ 2011-05-04 15:39 UTC (permalink / raw)
  To: ofono

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

---
 src/emulator.c |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 57 insertions(+), 2 deletions(-)

diff --git a/src/emulator.c b/src/emulator.c
index 5963ffb..e389387 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -193,6 +193,53 @@ error:
 	g_at_server_send_final(em->server, G_AT_SERVER_RESULT_ERROR);
 }
 
+static void dun_ath_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_ERROR);
+		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_ppp_unref(em->ppp);
+		em->ppp = NULL;
+
+		g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
+		break;
+
+	case G_AT_SERVER_REQUEST_TYPE_COMMAND_ONLY:
+		g_at_ppp_unref(em->ppp);
+		em->ppp = NULL;
+
+		g_at_server_send_final(server, G_AT_SERVER_RESULT_OK);
+		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)
 {
@@ -678,10 +725,18 @@ void ofono_emulator_register(struct ofono_emulator *em, int fd)
 
 	__ofono_atom_register(em->atom, emulator_unregister);
 
-	if (em->type == OFONO_EMULATOR_TYPE_DUN)
+	switch (em->type) {
+	case OFONO_EMULATOR_TYPE_DUN:
 		g_at_server_register(em->server, "D", dial_cb, em, NULL);
-	else if (em->type == OFONO_EMULATOR_TYPE_HFP)
+		g_at_server_register(em->server, "H", dun_ath_cb, em, NULL);
+		break;
+	case OFONO_EMULATOR_TYPE_HFP:
 		g_at_server_set_echo(em->server, FALSE);
+		break;
+
+	default:
+		break;
+	}
 }
 
 static void emulator_remove(struct ofono_atom *atom)
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH_v4 8/8] gsmdial: add ATH0 command test
  2011-05-04 15:38 [PATCH_v4 0/8] Escape sequence test implementation Guillaume Zajac
                   ` (6 preceding siblings ...)
  2011-05-04 15:39 ` [PATCH_v4 7/8] emulator: add dun_ath_cb() and register it Guillaume Zajac
@ 2011-05-04 15:39 ` Guillaume Zajac
  7 siblings, 0 replies; 16+ messages in thread
From: Guillaume Zajac @ 2011-05-04 15:39 UTC (permalink / raw)
  To: ofono

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

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

diff --git a/gatchat/gsmdial.c b/gatchat/gsmdial.c
index 31bb910..7c8ba47 100644
--- a/gatchat/gsmdial.c
+++ b/gatchat/gsmdial.c
@@ -238,9 +238,19 @@ 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(gpointer user_data)
 {
 	g_at_chat_resume(modem);
+	g_at_chat_send(modem, "ATH0", none_prefix, power_down_ppp, NULL, NULL);
 }
 
 static void start_test_sequence(gpointer data)
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH_v4 1/8] gathdlc: delete read/write handler in hdlc_suspend and add public suspend function for testing
  2011-05-04 15:38 ` [PATCH_v4 1/8] gathdlc: delete read/write handler in hdlc_suspend and add public suspend function for testing Guillaume Zajac
@ 2011-05-09  4:10   ` Denis Kenzior
  0 siblings, 0 replies; 16+ messages in thread
From: Denis Kenzior @ 2011-05-09  4:10 UTC (permalink / raw)
  To: ofono

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

Hi Guillaume,

On 05/04/2011 10:38 AM, Guillaume Zajac wrote:
> ---
>  gatchat/gathdlc.c |   12 ++++++++++++
>  gatchat/gathdlc.h |    2 ++
>  2 files changed, 14 insertions(+), 0 deletions(-)
> 

I applied this patch, but broke it up into two.  Here's a helpful hint,
if you're writing a commit message and you use the word 'and', then
chances are the commit should be broken up.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH_v4 2/8] ppp_net: add ppp_net_suspend_interface() function
  2011-05-04 15:39 ` [PATCH_v4 2/8] ppp_net: add ppp_net_suspend_interface() function Guillaume Zajac
@ 2011-05-09  4:11   ` Denis Kenzior
  2011-05-10  7:57     ` Guillaume Zajac
  0 siblings, 1 reply; 16+ messages in thread
From: Denis Kenzior @ 2011-05-09  4:11 UTC (permalink / raw)
  To: ofono

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

Hi Guillaume,

On 05/04/2011 10:39 AM, Guillaume Zajac wrote:
> ---
>  gatchat/ppp.h     |    1 +
>  gatchat/ppp_net.c |    9 +++++++++
>  2 files changed, 10 insertions(+), 0 deletions(-)
> 

I applied this patch, however I had to fix it slightly afterward:

> @@ -196,3 +196,12 @@ void ppp_net_free(struct ppp_net *net)
>  	g_free(net->if_name);
>  	g_free(net);
>  }
> +
> +void ppp_net_suspend_interface(struct ppp_net *net)
> +{
> +	if (net == NULL || net->channel == NULL)
> +		return;
> +
> +	if (net->watch)
> +		g_source_remove(net->watch);
> +}

Whenever removing a watch, please make sure to reset the watch variable
back to zero.

Also, I'm missing the _resume version of the above function...

Regards,
-Denis

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH_v4 3/8] gatppp: add function to set ppp_suspend() and proxy function to call ppp_net_suspend_interface()
  2011-05-04 15:39 ` [PATCH_v4 3/8] gatppp: add function to set ppp_suspend() and proxy function to call ppp_net_suspend_interface() Guillaume Zajac
@ 2011-05-09  4:12   ` Denis Kenzior
  0 siblings, 0 replies; 16+ messages in thread
From: Denis Kenzior @ 2011-05-09  4:12 UTC (permalink / raw)
  To: ofono

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

Hi Guillaume,

On 05/04/2011 10:39 AM, Guillaume Zajac wrote:
> ---
>  gatchat/gatppp.c |   24 ++++++++++++++++++++++++
>  gatchat/gatppp.h |    2 ++
>  2 files changed, 26 insertions(+), 0 deletions(-)
> 

Patch has been applied, thanks.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH_v4 4/8] gatppp: add public suspend function for testing
  2011-05-04 15:39 ` [PATCH_v4 4/8] gatppp: add public suspend function for testing Guillaume Zajac
@ 2011-05-09  4:13   ` Denis Kenzior
  0 siblings, 0 replies; 16+ messages in thread
From: Denis Kenzior @ 2011-05-09  4:13 UTC (permalink / raw)
  To: ofono

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

Hi Guillaume,

On 05/04/2011 10:39 AM, Guillaume Zajac wrote:
> ---
>  gatchat/gatppp.c |   35 +++++++++++++++++++++++++++++++++++
>  gatchat/gatppp.h |    1 +
>  2 files changed, 36 insertions(+), 0 deletions(-)
> 
> diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c
> index c776811..67f0a28 100644
> --- a/gatchat/gatppp.c
> +++ b/gatchat/gatppp.c
> @@ -46,6 +46,9 @@
>  #define PPP_ADDR_FIELD	0xff
>  #define PPP_CTRL	0x03
>  
> +/* Time to wait before and after +++ sequence */
> +#define GUARD_TIMEOUTS 1500
> +
>  enum ppp_phase {
>  	PPP_PHASE_DEAD = 0,		/* Link dead */
>  	PPP_PHASE_ESTABLISHMENT,	/* LCP started */
> @@ -500,6 +503,38 @@ void g_at_ppp_shutdown(GAtPPP *ppp)
>  	pppcp_signal_close(ppp->lcp);
>  }
>  
> +static gboolean call_suspend_cb(gpointer user_data)
> +{
> +	GAtPPP *ppp = user_data;
> +
> +	if (ppp->suspend_func)
> +		ppp->suspend_func(ppp->suspend_data);
> +
> +	return FALSE;
> +}
> +
> +static gboolean send_escape_sequence(gpointer user_data)
> +{
> +	GAtPPP *ppp = user_data;
> +	GAtIO *io = g_at_hdlc_get_io(ppp->hdlc);
> +
> +	g_at_io_write(io, "+++", 3);
> +
> +	g_timeout_add(GUARD_TIMEOUTS, call_suspend_cb, ppp);

Please make sure to track this GSource and remove it in case ppp is ever
forcefully removed.  Remember, we're writing a library and you must make
sure to clean up after yourself.

> +
> +	return FALSE;
> +}
> +
> +void g_at_ppp_suspend(GAtPPP *ppp)
> +{
> +	if (ppp == NULL)
> +		return;
> +
> +	ppp_net_suspend_interface(ppp->net);
> +	g_at_hdlc_suspend(ppp->hdlc);
> +	g_timeout_add(GUARD_TIMEOUTS, send_escape_sequence, ppp);
> +}
> +
>  void g_at_ppp_ref(GAtPPP *ppp)
>  {
>  	g_atomic_int_inc(&ppp->ref_count);
> diff --git a/gatchat/gatppp.h b/gatchat/gatppp.h
> index 9464ffd..66e0ade 100644
> --- a/gatchat/gatppp.h
> +++ b/gatchat/gatppp.h
> @@ -64,6 +64,7 @@ void g_at_ppp_set_suspend_function(GAtPPP *ppp, GAtSuspendFunc func,
>  					gpointer user_data);
>  void g_at_ppp_set_debug(GAtPPP *ppp, GAtDebugFunc func, gpointer user_data);
>  void g_at_ppp_shutdown(GAtPPP *ppp);
> +void g_at_ppp_suspend(GAtPPP *ppp);
>  void g_at_ppp_ref(GAtPPP *ppp);
>  void g_at_ppp_unref(GAtPPP *ppp);
>  

Is a _resume version of this patch forthcoming?

Regards,
-Denis

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH_v4 5/8] emulator: add suspend_ppp() definition and and register it into GAtPPP
  2011-05-04 15:39 ` [PATCH_v4 5/8] emulator: add suspend_ppp() definition and and register it into GAtPPP Guillaume Zajac
@ 2011-05-09  4:16   ` Denis Kenzior
  0 siblings, 0 replies; 16+ messages in thread
From: Denis Kenzior @ 2011-05-09  4:16 UTC (permalink / raw)
  To: ofono

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

Hi Guillaume,

On 05/04/2011 10:39 AM, Guillaume Zajac wrote:
> ---
>  src/emulator.c |   10 ++++++++++
>  1 files changed, 10 insertions(+), 0 deletions(-)
> 

Patch has been applied, thanks.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH_v4 7/8] emulator: add dun_ath_cb() and register it
  2011-05-04 15:39 ` [PATCH_v4 7/8] emulator: add dun_ath_cb() and register it Guillaume Zajac
@ 2011-05-09  4:19   ` Denis Kenzior
  0 siblings, 0 replies; 16+ messages in thread
From: Denis Kenzior @ 2011-05-09  4:19 UTC (permalink / raw)
  To: ofono

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

Hi Guillaume,

On 05/04/2011 10:39 AM, Guillaume Zajac wrote:
> ---
>  src/emulator.c |   59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 files changed, 57 insertions(+), 2 deletions(-)
> 

Patch has been applied, thanks.

Regards,
-Denis

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH_v4 2/8] ppp_net: add ppp_net_suspend_interface() function
  2011-05-09  4:11   ` Denis Kenzior
@ 2011-05-10  7:57     ` Guillaume Zajac
  0 siblings, 0 replies; 16+ messages in thread
From: Guillaume Zajac @ 2011-05-10  7:57 UTC (permalink / raw)
  To: ofono

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

Hi Denis,

On 09/05/2011 06:11, Denis Kenzior wrote:
> Hi Guillaume,
>
> On 05/04/2011 10:39 AM, Guillaume Zajac wrote:
>> ---
>>   gatchat/ppp.h     |    1 +
>>   gatchat/ppp_net.c |    9 +++++++++
>>   2 files changed, 10 insertions(+), 0 deletions(-)
>>
> I applied this patch, however I had to fix it slightly afterward:
>
>> @@ -196,3 +196,12 @@ void ppp_net_free(struct ppp_net *net)
>>   	g_free(net->if_name);
>>   	g_free(net);
>>   }
>> +
>> +void ppp_net_suspend_interface(struct ppp_net *net)
>> +{
>> +	if (net == NULL || net->channel == NULL)
>> +		return;
>> +
>> +	if (net->watch)
>> +		g_source_remove(net->watch);
>> +}
> Whenever removing a watch, please make sure to reset the watch variable
> back to zero.

Yes, sorry I had forgotten this one.

> Also, I'm missing the _resume version of the above function...

I would have implemented in the set of patches for ATO0 callback.

Kind regards,
Guillaume

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2011-05-10  7:57 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-04 15:38 [PATCH_v4 0/8] Escape sequence test implementation Guillaume Zajac
2011-05-04 15:38 ` [PATCH_v4 1/8] gathdlc: delete read/write handler in hdlc_suspend and add public suspend function for testing Guillaume Zajac
2011-05-09  4:10   ` Denis Kenzior
2011-05-04 15:39 ` [PATCH_v4 2/8] ppp_net: add ppp_net_suspend_interface() function Guillaume Zajac
2011-05-09  4:11   ` Denis Kenzior
2011-05-10  7:57     ` Guillaume Zajac
2011-05-04 15:39 ` [PATCH_v4 3/8] gatppp: add function to set ppp_suspend() and proxy function to call ppp_net_suspend_interface() Guillaume Zajac
2011-05-09  4:12   ` Denis Kenzior
2011-05-04 15:39 ` [PATCH_v4 4/8] gatppp: add public suspend function for testing Guillaume Zajac
2011-05-09  4:13   ` Denis Kenzior
2011-05-04 15:39 ` [PATCH_v4 5/8] emulator: add suspend_ppp() definition and and register it into GAtPPP Guillaume Zajac
2011-05-09  4:16   ` Denis Kenzior
2011-05-04 15:39 ` [PATCH_v4 6/8] gsmdial: add new option to test escape sequence Guillaume Zajac
2011-05-04 15:39 ` [PATCH_v4 7/8] emulator: add dun_ath_cb() and register it Guillaume Zajac
2011-05-09  4:19   ` Denis Kenzior
2011-05-04 15:39 ` [PATCH_v4 8/8] gsmdial: add ATH0 command test Guillaume Zajac

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox