All of lore.kernel.org
 help / color / mirror / Atom feed
* no connection after ofono restart while huawei modem connected
@ 2018-07-13  7:47 Christophe Ronco
  2018-07-13 16:09 ` Denis Kenzior
  0 siblings, 1 reply; 8+ messages in thread
From: Christophe Ronco @ 2018-07-13  7:47 UTC (permalink / raw)
  To: ofono

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

Hi,

I use a Huawei MS2372h-607. It is a classical AT+PPP modem. I have a
problem when I stop ofono while context is activated. When I restart
ofono (without unplugging the modem), I am not able to send any AT
command on Modem channel because this channel is still in data mode.

I made a patch to send escape sequence when gprs-context atom is
removed. It fixes the problem but I don't know if this is the right
thing to do.

Attached to this mail:

I/ reconnectError_01: traces of complete test (with debug and AT debug).
Test done:

1) board boot

2) Connection (success), start at line 1058:

connmanctl connect cellular...

3) stop ofono, start at line 1109:

/etc/init.d/ofono stop

4) start ofono, start at line 1348:

/etc/init.d/ofono start

5) Connection (error), start at line 2018:

connmanctl connect cellular...


I don't have PPP debug in this trace but here is what happens at PPP
level when Ofono is stopped:

ofonod[944]:
../ofono-1.24/drivers/atmodem/gprs-context.c:at_gprs_detach_shutdown() cid 0
ofonod[944]: PPP: lcp: pppcp_generate_event: current state 9:OPENED
ofonod[944]: PPP: event: 3 (Close), action: 8224, new_state: 4 (CLOSING)
ofonod[944]: PPP: lcp: pppcp_initialize_restart_count: current state
9:OPENED
ofonod[944]: PPP: lcp: pppcp_send_terminate_request: current state 9:OPENED
ofonod[944]: PPP: ipcp: pppcp_generate_event: current state 9:OPENED
ofonod[944]: PPP: event: 1 (Down), action: 201, new_state: 1 (STARTING)
ofonod[944]: PPP: ../ofono-1.24/gatchat/gatppp.c:ppp_enter_phase() 5

ofonod[944]: ../ofono-1.24/src/gprs.c:gprs_context_unregister()
0xc10ed0, 0xc10d90
ofonod[944]: ../ofono-1.24/src/gprs.c:gprs_context_remove() atom: 0xc10ef0
ofonod[944]:
../ofono-1.24/drivers/atmodem/gprs-context.c:at_gprs_context_remove()
ofonod[944]: ../ofono-1.24/src/gprs.c:gprs_unregister() 0xc10d90

Terminate request is sent and then gprs-context atom is removed before
Terminate Ack is received.


II/ 0001-PPP-send-escape-sequence-when-ofono-dies.patch

The patch I made to fix the problem. The idea is to immediately send
escape sequence when removing gprs-context atom. This patch is not ready
to be sent (at least it must be split in two patches). Can you tell me
what you think about this patch? 


Best Regards,


Christophe Ronco


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-PPP-send-escape-sequence-when-ofono-dies.patch --]
[-- Type: text/x-patch, Size: 2042 bytes --]

From 124a67db2437b4619bb2a42d7776fa3b1aeab50c Mon Sep 17 00:00:00 2001
From: Christophe Ronco <c.ronco@kerlink.fr>
Date: Thu, 12 Jul 2018 18:04:44 +0200
Subject: [PATCH 1/1] PPP: send escape sequence when ofono dies

When ofono dies while connected using PPP, AT channel is not put back to
command mode.
If ofono is restarted, it won't be able to connect as it gets no answer to
AT commands on this AT channel.
---
 drivers/atmodem/gprs-context.c |  1 +
 gatchat/gatppp.c               | 16 ++++++++++++++++
 gatchat/gatppp.h               |  1 +
 3 files changed, 18 insertions(+)

diff --git a/drivers/atmodem/gprs-context.c b/drivers/atmodem/gprs-context.c
index 42ec556..5761b3c 100644
--- a/drivers/atmodem/gprs-context.c
+++ b/drivers/atmodem/gprs-context.c
@@ -465,6 +465,7 @@ static void at_gprs_context_remove(struct ofono_gprs_context *gc)
 	DBG("");
 
 	if (gcd->state != STATE_IDLE && gcd->ppp) {
+		g_at_ppp_send_escape_sequence(gcd->ppp);
 		g_at_ppp_unref(gcd->ppp);
 		g_at_chat_resume(gcd->chat);
 	}
diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c
index 4a80b4b..dbb99e3 100644
--- a/gatchat/gatppp.c
+++ b/gatchat/gatppp.c
@@ -712,6 +712,22 @@ static gboolean send_escape_sequence(gpointer user_data)
 	return FALSE;
 }
 
+void g_at_ppp_send_escape_sequence(GAtPPP *ppp)
+{
+	GAtIO *io;
+
+	DBG(ppp, "");
+	if (ppp == NULL)
+		return;
+
+	io = g_at_hdlc_get_io(ppp->hdlc);
+
+	if (io == NULL)
+		return;
+
+	g_at_io_write(io, "+++", 3);
+}
+
 void g_at_ppp_suspend(GAtPPP *ppp)
 {
 	if (ppp == NULL)
diff --git a/gatchat/gatppp.h b/gatchat/gatppp.h
index 213f7e9..ffd6879 100644
--- a/gatchat/gatppp.h
+++ b/gatchat/gatppp.h
@@ -69,6 +69,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_send_escape_sequence(GAtPPP *ppp);
 void g_at_ppp_suspend(GAtPPP *ppp);
 void g_at_ppp_resume(GAtPPP *ppp);
 void g_at_ppp_ref(GAtPPP *ppp);
-- 
2.7.4


[-- Attachment #3: reconnectError_01.tar.gz --]
[-- Type: application/gzip, Size: 24583 bytes --]

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

end of thread, other threads:[~2018-07-25 19:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-13  7:47 no connection after ofono restart while huawei modem connected Christophe Ronco
2018-07-13 16:09 ` Denis Kenzior
2018-07-19 10:40   ` Christophe Ronco
2018-07-19 16:20     ` Denis Kenzior
2018-07-25 13:43       ` Christophe Ronco
2018-07-25 13:45         ` [PATCH 1/2] atmodem: Add gprs-context quirk for HUAWEI vendor Christophe Ronco
2018-07-25 13:45           ` [PATCH 2/2] huawei: use VENDOR_HUAWEI quirk on gprs context creation Christophe Ronco
2018-07-25 19:12           ` [PATCH 1/2] atmodem: Add gprs-context quirk for HUAWEI vendor 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.