From 124a67db2437b4619bb2a42d7776fa3b1aeab50c Mon Sep 17 00:00:00 2001 From: Christophe Ronco 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