From: Dragos Tatulea <dragos@endocode.com>
To: ofono@ofono.org
Subject: [PATCH 9/9] ubloxmodem: support automatic ctx activation
Date: Thu, 17 Mar 2016 18:02:20 +0100 [thread overview]
Message-ID: <1458234140-7936-10-git-send-email-dragos@endocode.com> (raw)
In-Reply-To: <1458234140-7936-1-git-send-email-dragos@endocode.com>
[-- Attachment #1: Type: text/plain, Size: 2596 bytes --]
... by imlementing read_settings.
---
drivers/ubloxmodem/gprs-context.c | 39 +++++++++++++++++++++++++++++----------
1 file changed, 29 insertions(+), 10 deletions(-)
diff --git a/drivers/ubloxmodem/gprs-context.c b/drivers/ubloxmodem/gprs-context.c
index 63f6ac2..25e0447 100644
--- a/drivers/ubloxmodem/gprs-context.c
+++ b/drivers/ubloxmodem/gprs-context.c
@@ -35,6 +35,7 @@
#include <ofono/log.h>
#include <ofono/modem.h>
#include <ofono/gprs-context.h>
+#include <ofono/gprs.h>
#include "gatchat.h"
#include "gatresult.h"
@@ -181,6 +182,27 @@ static void ublox_read_settings(struct ofono_gprs_context *gc)
CALLBACK_WITH_FAILURE(gcd->cb, gcd->cb_data);
}
+static void ublox_gprs_read_settings(struct ofono_gprs_context *gc,
+ const struct ofono_gprs_primary_context *ctx,
+ ofono_gprs_context_cb_t cb, void *data)
+{
+ struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
+
+ /* IPv6 support not implemented */
+ if (ctx->proto != OFONO_GPRS_PROTO_IP) {
+ CALLBACK_WITH_FAILURE(cb, data);
+ return;
+ }
+
+ DBG("cid %u", ctx->cid);
+
+ gcd->active_context = ctx->cid;
+ gcd->cb = cb;
+ gcd->cb_data = data;
+
+ ublox_read_settings(gc);
+}
+
static void cgact_enable_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct ofono_gprs_context *gc = user_data;
@@ -370,6 +392,7 @@ static void cgev_notify(GAtResult *result, gpointer user_data)
GAtResultIter iter;
const char *event;
gint cid;
+ char tmp[16] = {0};
g_at_result_iter_init(&iter, result);
@@ -379,16 +402,11 @@ static void cgev_notify(GAtResult *result, gpointer user_data)
if (!g_at_result_iter_next_unquoted_string(&iter, &event))
return;
- if (g_str_has_prefix(event, "NW PDN DEACT")) {
- if (!g_at_result_iter_skip_next(&iter))
- return;
- } else if (g_str_has_prefix(event, "NW DEACT") == FALSE)
- return;
-
- if (!g_at_result_iter_skip_next(&iter))
- return;
-
- if (!g_at_result_iter_next_number(&iter, &cid))
+ if (g_str_has_prefix(event, "NW PDN DEACT"))
+ sscanf(event, "%s %s %s %u", tmp, tmp, tmp, &cid);
+ else if (g_str_has_prefix(event, "NW DEACT"))
+ sscanf(event, "%s %s %u", tmp, tmp, &cid);
+ else
return;
DBG("cid %d", cid);
@@ -440,6 +458,7 @@ static struct ofono_gprs_context_driver driver = {
.remove = ublox_gprs_context_remove,
.activate_primary = ublox_gprs_activate_primary,
.deactivate_primary = ublox_gprs_deactivate_primary,
+ .read_settings = ublox_gprs_read_settings,
};
void ublox_gprs_context_init(void)
--
2.5.0
prev parent reply other threads:[~2016-03-17 17:02 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-17 17:02 [PATCH 0/9] allow automatic context activation Dragos Tatulea
2016-03-17 17:02 ` [PATCH 1/9] idmap: add api for finding a certain id in map Dragos Tatulea
2016-03-17 17:42 ` Denis Kenzior
2016-03-17 17:02 ` [PATCH 2/9] gprs-context.h: add op for reading context config Dragos Tatulea
2016-03-17 17:29 ` Denis Kenzior
2016-03-17 17:02 ` [PATCH 3/9] gprs.h: automatic context configuration notifier Dragos Tatulea
2016-03-17 17:33 ` Denis Kenzior
2016-03-17 17:02 ` [PATCH 4/9] gprs: pri_activate_callback: optional msg reply Dragos Tatulea
2016-03-17 17:41 ` Denis Kenzior
2016-03-17 17:02 ` [PATCH 5/9] gprs: pri_set_apn: make reply msg optional Dragos Tatulea
2016-03-17 17:39 ` Denis Kenzior
2016-03-17 17:02 ` [PATCH 6/9] gprs: custom cid for assign_context Dragos Tatulea
2016-03-17 17:27 ` Denis Kenzior
2016-03-17 17:02 ` [PATCH 7/9] gprs: implement ofono_gprs_cid_activated Dragos Tatulea
2016-03-17 17:48 ` Denis Kenzior
2016-03-17 17:02 ` [PATCH 8/9] atmodem: gprs: handle automatic context activation Dragos Tatulea
2016-03-17 17:56 ` Denis Kenzior
2016-03-17 17:02 ` Dragos Tatulea [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1458234140-7936-10-git-send-email-dragos@endocode.com \
--to=dragos@endocode.com \
--cc=ofono@ofono.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox