* [PATCH v2] atmodem: telit - re-attach gprs automatically
@ 2017-03-28 11:42 Lukasz Nowak
2017-03-28 17:04 ` Denis Kenzior
0 siblings, 1 reply; 2+ messages in thread
From: Lukasz Nowak @ 2017-03-28 11:42 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2795 bytes --]
From: Lukasz Nowak <lnowak@tycoint.com>
Telit AT modem firmware (tested with UE910-EUR) generates
+CGREG: 0\r\n\r\n+CGEV: NW DETACH
after a context is de-activated and ppp connection closed.
Then, after a random amount of time (observed from a few seconds
to a few hours), an unsolicited +CGREG: 1 arrives.
Attempt to fix the problem, by sending AT+CGATT=1 once.
This does not re-activate the context, but if a network connection
is still correct, will generate an immediate +CGREG: 1.
---
drivers/atmodem/gprs.c | 32 +++++++++++++++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/drivers/atmodem/gprs.c b/drivers/atmodem/gprs.c
index 7ea9f00..3a6364e 100644
--- a/drivers/atmodem/gprs.c
+++ b/drivers/atmodem/gprs.c
@@ -50,6 +50,8 @@ struct gprs_data {
GAtChat *chat;
unsigned int vendor;
unsigned int last_auto_context_id;
+ gboolean telit_try_reattach;
+ int attached;
};
static void at_cgatt_cb(gboolean ok, GAtResult *result, gpointer user_data)
@@ -73,8 +75,10 @@ static void at_gprs_set_attached(struct ofono_gprs *gprs, int attached,
snprintf(buf, sizeof(buf), "AT+CGATT=%i", attached ? 1 : 0);
if (g_at_chat_send(gd->chat, buf, none_prefix,
- at_cgatt_cb, cbd, g_free) > 0)
+ at_cgatt_cb, cbd, g_free) > 0) {
+ gd->attached = attached;
return;
+ }
g_free(cbd);
@@ -194,6 +198,28 @@ static void cgreg_notify(GAtResult *result, gpointer user_data)
NULL, NULL, NULL, gd->vendor) == FALSE)
return;
+ /*
+ * Telit AT modem firmware (tested with UE910-EUR) generates
+ * +CGREG: 0\r\n\r\n+CGEV: NW DETACH
+ * after a context is de-activated and ppp connection closed.
+ * Then, after a random amount of time (observed from a few seconds
+ * to a few hours), an unsolicited +CGREG: 1 arrives.
+ * Attempt to fix the problem, by sending AT+CGATT=1 once.
+ * This does not re-activate the context, but if a network connection
+ * is still correct, will generate an immediate +CGREG: 1.
+ */
+ if (gd->vendor == OFONO_VENDOR_TELIT) {
+ if (gd->attached && !status && !gd->telit_try_reattach) {
+ DBG("Trying to re-attach gprs network");
+ gd->telit_try_reattach = TRUE;
+ g_at_chat_send(gd->chat, "AT+CGATT=1", none_prefix,
+ NULL, NULL, NULL);
+ return;
+ }
+
+ gd->telit_try_reattach = FALSE;
+ }
+
ofono_gprs_status_notify(gprs, status);
}
@@ -214,6 +240,10 @@ static void cgev_notify(GAtResult *result, gpointer user_data)
if (g_str_equal(event, "NW DETACH") ||
g_str_equal(event, "ME DETACH")) {
+ if (gd->vendor == OFONO_VENDOR_TELIT &&
+ gd->telit_try_reattach)
+ return;
+
ofono_gprs_detached_notify(gprs);
return;
} else if (g_str_has_prefix(event, "ME PDN ACT")) {
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2] atmodem: telit - re-attach gprs automatically
2017-03-28 11:42 [PATCH v2] atmodem: telit - re-attach gprs automatically Lukasz Nowak
@ 2017-03-28 17:04 ` Denis Kenzior
0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2017-03-28 17:04 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 485 bytes --]
Hi Lukasz,
> @@ -214,6 +240,10 @@ static void cgev_notify(GAtResult *result, gpointer user_data)
>
> if (g_str_equal(event, "NW DETACH") ||
> g_str_equal(event, "ME DETACH")) {
> + if (gd->vendor == OFONO_VENDOR_TELIT &&
> + gd->telit_try_reattach)
> + return;
> +
> ofono_gprs_detached_notify(gprs);
I think you're missing setting gd->attached to FALSE here
> return;
> } else if (g_str_has_prefix(event, "ME PDN ACT")) {
>
Regards,
-Denis
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-03-28 17:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-28 11:42 [PATCH v2] atmodem: telit - re-attach gprs automatically Lukasz Nowak
2017-03-28 17:04 ` 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.