Hi Lukasz,
On 03/27/2017 12:18 PM, Lukasz Nowak wrote:
From: Lukasz Nowak <lnowak(a)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 | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/drivers/atmodem/gprs.c b/drivers/atmodem/gprs.c
index 7ea9f00..ba8646c 100644
--- a/drivers/atmodem/gprs.c
+++ b/drivers/atmodem/gprs.c
@@ -50,6 +50,7 @@ struct gprs_data {
GAtChat *chat;
unsigned int vendor;
unsigned int last_auto_context_id;
+ gboolean network_detach_retry;
This variable makes no sense. telit_try_reattach or something.
};
static void at_cgatt_cb(gboolean ok, GAtResult *result, gpointer user_data)
@@ -194,6 +195,28 @@ static void cgreg_notify(GAtResult *result, gpointer user_data)
NULL, NULL, NULL, gd->vendor) == FALSE)
return;
+ DBG("status=%d vendor=%d retry=%d", status, gd->vendor,
gd->network_detach_retry);
+
+ /*
+ * 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 &&
+ !status && !gd->network_detach_retry) {
doc/coding-style.txt item M4
Also, this should probably be done only in the case that the driver has
been attached. E.g. .set_attached was last called with attached=1
+ DBG("Trying to re-attach gprs network");
+ gd->network_detach_retry = TRUE;
+ g_at_chat_send(gd->chat, "AT+CGATT=1", none_prefix,
+ NULL, NULL, NULL);
+ return;
+ }
+ gd->network_detach_retry = FALSE;
+
doc/coding-style.txt item M1
Also, this belongs in an if-block for the TELIT vendor.
e.g.
if (vendor == TELIT) {
if (status ...) {
}
gd->telit_attach_retry = ...
}
ofono_gprs_status_notify(gprs, status);
}
@@ -214,6 +237,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->network_detach_retry)
+ return;
doc/coding-style.txt item M1.
ofono_gprs_detached_notify(gprs);
return;
} else if (g_str_has_prefix(event, "ME PDN ACT")) {
Regards,
-Denis