mirror of git://git.sysmocom.de/ofono
ublox: gprs: React on context deactivation
In case a context get deactivated when a AT+CGACT=0 is not issued, indicate that to gprs core. This can happen if the device has an auto activated LTE context and modem switches over to for instance UTRAN.
This commit is contained in:
parent
62e8e3c1e2
commit
2d868fac1f
|
@ -40,6 +40,8 @@
|
||||||
|
|
||||||
#include "ubloxmodem.h"
|
#include "ubloxmodem.h"
|
||||||
|
|
||||||
|
#define UBLOX_FLAG_DEACTIVATING 0x01
|
||||||
|
|
||||||
static const char *none_prefix[] = { NULL };
|
static const char *none_prefix[] = { NULL };
|
||||||
static const char *cgcontrdp_prefix[] = { "+CGCONTRDP:", NULL };
|
static const char *cgcontrdp_prefix[] = { "+CGCONTRDP:", NULL };
|
||||||
static const char *uipaddr_prefix[] = { "+UIPADDR:", NULL };
|
static const char *uipaddr_prefix[] = { "+UIPADDR:", NULL };
|
||||||
|
@ -57,6 +59,7 @@ struct gprs_context_data {
|
||||||
ofono_gprs_context_cb_t cb;
|
ofono_gprs_context_cb_t cb;
|
||||||
void *cb_data;
|
void *cb_data;
|
||||||
enum netmode networking_mode;
|
enum netmode networking_mode;
|
||||||
|
int flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void uipaddr_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
static void uipaddr_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
||||||
|
@ -426,6 +429,8 @@ static void cgact_disable_cb(gboolean ok, GAtResult *result, gpointer user_data)
|
||||||
|
|
||||||
DBG("ok %d", ok);
|
DBG("ok %d", ok);
|
||||||
|
|
||||||
|
gcd->flags &= ~UBLOX_FLAG_DEACTIVATING;
|
||||||
|
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
CALLBACK_WITH_FAILURE(gcd->cb, gcd->cb_data);
|
CALLBACK_WITH_FAILURE(gcd->cb, gcd->cb_data);
|
||||||
return;
|
return;
|
||||||
|
@ -448,6 +453,8 @@ static void ublox_gprs_deactivate_primary(struct ofono_gprs_context *gc,
|
||||||
gcd->cb = cb;
|
gcd->cb = cb;
|
||||||
gcd->cb_data = data;
|
gcd->cb_data = data;
|
||||||
|
|
||||||
|
gcd->flags |= UBLOX_FLAG_DEACTIVATING;
|
||||||
|
|
||||||
snprintf(buf, sizeof(buf), "AT+CGACT=0,%u", gcd->active_context);
|
snprintf(buf, sizeof(buf), "AT+CGACT=0,%u", gcd->active_context);
|
||||||
g_at_chat_send(gcd->chat, buf, none_prefix,
|
g_at_chat_send(gcd->chat, buf, none_prefix,
|
||||||
cgact_disable_cb, gc, NULL);
|
cgact_disable_cb, gc, NULL);
|
||||||
|
@ -473,10 +480,16 @@ static void cgev_notify(GAtResult *result, gpointer user_data)
|
||||||
sscanf(event, "%*s %*s %*s %u", &cid);
|
sscanf(event, "%*s %*s %*s %u", &cid);
|
||||||
else if (g_str_has_prefix(event, "NW DEACT"))
|
else if (g_str_has_prefix(event, "NW DEACT"))
|
||||||
sscanf(event, "%*s %*s %u", &cid);
|
sscanf(event, "%*s %*s %u", &cid);
|
||||||
|
else if (!(gcd->flags & UBLOX_FLAG_DEACTIVATING) &&
|
||||||
|
g_str_has_prefix(event, "ME PDN DEACT"))
|
||||||
|
/* The modem might consider the ME deactivating without
|
||||||
|
* an explicit CGACT=0 beeing sent
|
||||||
|
*/
|
||||||
|
sscanf(event, "%*s %*s %*s %u", &cid);
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DBG("cid %d", cid);
|
DBG("cid %d, active cid: %d", cid, gcd->active_context);
|
||||||
|
|
||||||
if ((unsigned int) cid != gcd->active_context)
|
if ((unsigned int) cid != gcd->active_context)
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue