All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH_v6 0/5] Escape sequence and ATO0 implementation
@ 2011-05-20  9:38 Guillaume Zajac
  2011-05-20  9:38 ` [PATCH_v6 1/5] gathdlc: add g_at_hdlc_resume() API Guillaume Zajac
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Guillaume Zajac @ 2011-05-20  9:38 UTC (permalink / raw)
  To: ofono

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

Hi,

Change log from v5:
	- regroups multiple patches in one patch
	- contains ATO0 implementation
	- contains all resume function
	- contains fix for not removing io_disconnect function
	  while unrefing GAtPPP if it is suspended

Guillaume Zajac (5):
  gathdlc: add g_at_hdlc_resume() API
  ppp_net: add ppp_net_resume_interface() API
  gatppp: add public suspend/resume APIs and suspended state
  emulator: add dun_ato_cb() definition and register it in GAtServer
  gsmdial: add escape sequence/ATH0/ATO0 testing option

 gatchat/gathdlc.c |   16 +++++++++++
 gatchat/gathdlc.h |    1 +
 gatchat/gatppp.c  |   64 +++++++++++++++++++++++++++++++++++++++++++++-
 gatchat/gatppp.h  |    2 +
 gatchat/gsmdial.c |   73 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 gatchat/ppp.h     |    1 +
 gatchat/ppp_net.c |   10 +++++++
 src/emulator.c    |   54 +++++++++++++++++++++++++++++++++++++++
 8 files changed, 219 insertions(+), 2 deletions(-)


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

* [PATCH_v6 1/5] gathdlc: add g_at_hdlc_resume() API
  2011-05-20  9:38 [PATCH_v6 0/5] Escape sequence and ATO0 implementation Guillaume Zajac
@ 2011-05-20  9:38 ` 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
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Guillaume Zajac @ 2011-05-20  9:38 UTC (permalink / raw)
  To: ofono

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

---
 gatchat/gathdlc.c |   16 ++++++++++++++++
 gatchat/gathdlc.h |    1 +
 2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/gatchat/gathdlc.c b/gatchat/gathdlc.c
index 7989bd7..d04ba38 100644
--- a/gatchat/gathdlc.c
+++ b/gatchat/gathdlc.c
@@ -622,3 +622,19 @@ void g_at_hdlc_suspend(GAtHDLC *hdlc)
 	g_at_io_set_write_handler(hdlc->io, NULL, NULL);
 	g_at_io_set_read_handler(hdlc->io, NULL, NULL);
 }
+
+static void hdlc_wakeup_writer(GAtHDLC *hdlc)
+{
+	g_at_io_set_write_handler(hdlc->io, can_write_data, hdlc);
+}
+
+void g_at_hdlc_resume(GAtHDLC *hdlc)
+{
+	if (hdlc == NULL)
+		return;
+
+	g_at_io_set_read_handler(hdlc->io, new_bytes, hdlc);
+
+	if (g_queue_get_length(hdlc->write_queue) > 0)
+		hdlc_wakeup_writer(hdlc);
+}
diff --git a/gatchat/gathdlc.h b/gatchat/gathdlc.h
index 556e383..e82b33e 100644
--- a/gatchat/gathdlc.h
+++ b/gatchat/gathdlc.h
@@ -61,6 +61,7 @@ void g_at_hdlc_set_suspend_function(GAtHDLC *hdlc, GAtSuspendFunc func,
 							gpointer user_data);
 
 void g_at_hdlc_suspend(GAtHDLC *hdlc);
+void g_at_hdlc_resume(GAtHDLC *hdlc);
 
 #ifdef __cplusplus
 }
-- 
1.7.1


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

* [PATCH_v6 2/5] ppp_net: add ppp_net_resume_interface() API
  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-20  9:38 ` 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
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Guillaume Zajac @ 2011-05-20  9:38 UTC (permalink / raw)
  To: ofono

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

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

diff --git a/gatchat/ppp.h b/gatchat/ppp.h
index 22809d8..ae96e42 100644
--- a/gatchat/ppp.h
+++ b/gatchat/ppp.h
@@ -108,6 +108,7 @@ 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);
+void ppp_net_resume_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 25bcfa4..39cfdfd 100644
--- a/gatchat/ppp_net.c
+++ b/gatchat/ppp_net.c
@@ -212,3 +212,13 @@ void ppp_net_suspend_interface(struct ppp_net *net)
 	g_source_remove(net->watch);
 	net->watch = 0;
 }
+
+void ppp_net_resume_interface(struct ppp_net *net)
+{
+	if (net == NULL || net->channel == NULL)
+		return;
+
+	net->watch = g_io_add_watch(net->channel,
+			G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+			ppp_net_callback, net);
+}
-- 
1.7.1


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

* [PATCH_v6 3/5] gatppp: add public suspend/resume APIs and suspended state
  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-20  9:38 ` [PATCH_v6 2/5] ppp_net: add ppp_net_resume_interface() API Guillaume Zajac
@ 2011-05-20  9:38 ` 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-20  9:38 ` [PATCH_v6 5/5] gsmdial: add escape sequence/ATH0/ATO0 testing option Guillaume Zajac
  4 siblings, 1 reply; 11+ messages in thread
From: Guillaume Zajac @ 2011-05-20  9:38 UTC (permalink / raw)
  To: ofono

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

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

diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c
index c776811..efa909b 100644
--- a/gatchat/gatppp.c
+++ b/gatchat/gatppp.c
@@ -46,6 +46,8 @@
 #define PPP_ADDR_FIELD	0xff
 #define PPP_CTRL	0x03
 
+#define GUARD_TIMEOUTS 1500
+
 enum ppp_phase {
 	PPP_PHASE_DEAD = 0,		/* Link dead */
 	PPP_PHASE_ESTABLISHMENT,	/* LCP started */
@@ -78,6 +80,8 @@ struct _GAtPPP {
 	guint ppp_dead_source;
 	GAtSuspendFunc suspend_func;
 	gpointer suspend_data;
+	guint guard_timeout_src;
+	gboolean suspended;
 };
 
 void ppp_debug(GAtPPP *ppp, const char *str)
@@ -473,6 +477,7 @@ static void ppp_proxy_suspend_net_interface(gpointer user_data)
 {
 	GAtPPP *ppp = user_data;
 
+	ppp->suspended = TRUE;
 	ppp_net_suspend_interface(ppp->net);
 
 	if (ppp->suspend_func)
@@ -500,6 +505,60 @@ void g_at_ppp_shutdown(GAtPPP *ppp)
 	pppcp_signal_close(ppp->lcp);
 }
 
+static gboolean call_suspend_cb(gpointer user_data)
+{
+	GAtPPP *ppp = user_data;
+
+	ppp->guard_timeout_src = 0;
+
+	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);
+
+	ppp->guard_timeout_src = 0;
+	g_at_io_write(io, "+++", 3);
+	ppp->guard_timeout_src  = g_timeout_add(GUARD_TIMEOUTS,
+						call_suspend_cb, ppp);
+
+	return FALSE;
+}
+
+void g_at_ppp_suspend(GAtPPP *ppp)
+{
+	if (ppp == NULL)
+		return;
+
+	ppp->suspended = TRUE;
+	ppp_net_suspend_interface(ppp->net);
+	g_at_hdlc_suspend(ppp->hdlc);
+	ppp->guard_timeout_src = g_timeout_add(GUARD_TIMEOUTS,
+						send_escape_sequence, ppp);
+}
+
+void g_at_ppp_resume(GAtPPP *ppp)
+{
+	if (ppp == NULL)
+		return;
+
+	if (g_at_hdlc_get_io(ppp->hdlc) == NULL) {
+		io_disconnect(ppp);
+		return;
+	}
+
+	ppp->suspended = FALSE;
+	g_at_io_set_disconnect_function(g_at_hdlc_get_io(ppp->hdlc),
+							io_disconnect, ppp);
+	ppp_net_resume_interface(ppp->net);
+	g_at_hdlc_resume(ppp->hdlc);
+}
+
 void g_at_ppp_ref(GAtPPP *ppp)
 {
 	g_atomic_int_inc(&ppp->ref_count);
@@ -517,8 +576,9 @@ void g_at_ppp_unref(GAtPPP *ppp)
 	if (is_zero == FALSE)
 		return;
 
-	g_at_io_set_disconnect_function(g_at_hdlc_get_io(ppp->hdlc),
-						NULL, NULL);
+	if (ppp->suspended == FALSE)
+		g_at_io_set_disconnect_function(g_at_hdlc_get_io(ppp->hdlc),
+							NULL, NULL);
 
 	if (ppp->net)
 		ppp_net_free(ppp->net);
diff --git a/gatchat/gatppp.h b/gatchat/gatppp.h
index 9464ffd..ab337d7 100644
--- a/gatchat/gatppp.h
+++ b/gatchat/gatppp.h
@@ -64,6 +64,8 @@ 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_resume(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] 11+ messages in thread

* [PATCH_v6 4/5] emulator: add dun_ato_cb() definition and register it in GAtServer
  2011-05-20  9:38 [PATCH_v6 0/5] Escape sequence and ATO0 implementation Guillaume Zajac
                   ` (2 preceding siblings ...)
  2011-05-20  9:38 ` [PATCH_v6 3/5] gatppp: add public suspend/resume APIs and suspended state Guillaume Zajac
@ 2011-05-20  9:38 ` Guillaume Zajac
  2011-05-25 10:43   ` Denis Kenzior
  2011-05-20  9:38 ` [PATCH_v6 5/5] gsmdial: add escape sequence/ATH0/ATO0 testing option Guillaume Zajac
  4 siblings, 1 reply; 11+ messages in thread
From: Guillaume Zajac @ 2011-05-20  9:38 UTC (permalink / raw)
  To: ofono

[-- 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


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

* [PATCH_v6 5/5] gsmdial: add escape sequence/ATH0/ATO0 testing option
  2011-05-20  9:38 [PATCH_v6 0/5] Escape sequence and ATO0 implementation Guillaume Zajac
                   ` (3 preceding siblings ...)
  2011-05-20  9:38 ` [PATCH_v6 4/5] emulator: add dun_ato_cb() definition and register it in GAtServer Guillaume Zajac
@ 2011-05-20  9:38 ` Guillaume Zajac
  2011-05-25 10:43   ` Denis Kenzior
  4 siblings, 1 reply; 11+ messages in thread
From: Guillaume Zajac @ 2011-05-20  9:38 UTC (permalink / raw)
  To: ofono

[-- 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


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

* Re: [PATCH_v6 1/5] gathdlc: add g_at_hdlc_resume() API
  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
  0 siblings, 0 replies; 11+ messages in thread
From: Denis Kenzior @ 2011-05-25 10:39 UTC (permalink / raw)
  To: ofono

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

Hi Guillaume,

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

Patch has been applied, thanks.

Regards,
-Denis

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

* Re: [PATCH_v6 2/5] ppp_net: add ppp_net_resume_interface() API
  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
  0 siblings, 0 replies; 11+ messages in thread
From: Denis Kenzior @ 2011-05-25 10:39 UTC (permalink / raw)
  To: ofono

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

Hi Guillaume,

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

Patch has been applied, thanks.

Regards,
-Denis

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

* Re: [PATCH_v6 3/5] gatppp: add public suspend/resume APIs and suspended state
  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
  0 siblings, 0 replies; 11+ messages in thread
From: Denis Kenzior @ 2011-05-25 10:40 UTC (permalink / raw)
  To: ofono

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

Hi Guillaume,

On 05/20/2011 04:38 AM, Guillaume Zajac wrote:
> ---
>  gatchat/gatppp.c |   64 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  gatchat/gatppp.h |    2 +
>  2 files changed, 64 insertions(+), 2 deletions(-)

This patch has been applied, but I did break it up into three or so
separate commits.

Regards,
-Denis

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

* Re: [PATCH_v6 4/5] emulator: add dun_ato_cb() definition and register it in GAtServer
  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
  0 siblings, 0 replies; 11+ messages in thread
From: Denis Kenzior @ 2011-05-25 10:43 UTC (permalink / raw)
  To: ofono

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

Hi Guillaume,

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

I applied this patch, but fixed it up for you afterwards:

> +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;
> +	}

Please avoid doing this, syntax checking should be done beforehand (and
perhaps an appropriate error set).  Then the actual validity checking
should be done.

> +
> +	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);

This should have used set_write_done...

> +		break;
> +
> +	default:
> +error:
> +		g_at_server_send_final(server, G_AT_SERVER_RESULT_ERROR);
> +		break;
> +	}
> +
> +	return;

Please do not ever use return statements at the end of the function
returning void

> +}
> +
>  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);

Regards,
-Denis

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

* Re: [PATCH_v6 5/5] gsmdial: add escape sequence/ATH0/ATO0 testing option
  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
  0 siblings, 0 replies; 11+ messages in thread
From: Denis Kenzior @ 2011-05-25 10:43 UTC (permalink / raw)
  To: ofono

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

Hi Guillaume,

On 05/20/2011 04:38 AM, Guillaume Zajac wrote:
> ---
>  gatchat/gsmdial.c |   73 +++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 73 insertions(+), 0 deletions(-)
> 

I pushed my own version of this patch that utilizes signals.

Regards,
-Denis

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

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

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH_v6 5/5] gsmdial: add escape sequence/ATH0/ATO0 testing option Guillaume Zajac
2011-05-25 10:43   ` Denis Kenzior

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.