Open Source Telephony
 help / color / mirror / Atom feed
From: Dragos Tatulea <dragos@endocode.com>
To: ofono@ofono.org
Subject: [PATCH 5/5] ubloxmodem: support automatic ctx activation
Date: Fri, 18 Mar 2016 12:53:14 +0100	[thread overview]
Message-ID: <1458301994-5567-9-git-send-email-dragos@endocode.com> (raw)
In-Reply-To: <1458301994-5567-1-git-send-email-dragos@endocode.com>

[-- Attachment #1: Type: text/plain, Size: 2180 bytes --]

... by imlementing read_settings.
---
 drivers/ubloxmodem/gprs-context.c | 32 ++++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/drivers/ubloxmodem/gprs-context.c b/drivers/ubloxmodem/gprs-context.c
index 63f6ac2..23c27aa 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,21 @@ 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,
+					unsigned int cid,
+					ofono_gprs_context_cb_t cb, void *data)
+{
+	struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
+
+	DBG("cid %u", cid);
+
+	gcd->active_context = 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;
@@ -379,16 +395,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", &cid);
+	else if (g_str_has_prefix(event, "NW DEACT"))
+		sscanf(event, "%*s %*s %u", &cid);
+	else
 		return;
 
 	DBG("cid %d", cid);
@@ -440,6 +451,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


  parent reply	other threads:[~2016-03-18 11:53 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-18 11:53 [PATCH v3 0/9] allow automatic context activation Dragos Tatulea
2016-03-18 11:53 ` [PATCH 1/5] idmap: add api for finding a certain id in map Dragos Tatulea
2016-03-18 11:53 ` [PATCH 2/5] gprs-context.h: add op for reading context config Dragos Tatulea
2016-03-18 11:53 ` [PATCH 3/5] gprs: implement ofono_gprs_cid_activated Dragos Tatulea
2016-03-18 11:53 ` [PATCH 3/9] gprs.h: automatic context configuration notifier Dragos Tatulea
2016-03-18 11:53 ` [PATCH 4/5] atmodem: gprs: handle automatic context activation Dragos Tatulea
2016-03-18 11:53 ` [PATCH 4/9] gprs: pri_activate_callback: optional msg reply Dragos Tatulea
2016-03-18 11:53 ` [PATCH 5/9] gprs: pri_set_apn: make reply msg optional Dragos Tatulea
2016-03-18 11:53 ` Dragos Tatulea [this message]
2016-03-18 12:03 ` [PATCH v3 0/9] allow automatic context activation Dragos Tatulea
  -- strict thread matches above, loose matches on Subject: below --
2016-03-18 11:58 [PATCH v4 0/5] " Dragos Tatulea
2016-03-18 11:58 ` [PATCH 5/5] ubloxmodem: support automatic ctx activation Dragos Tatulea
2016-03-18 15:13   ` Denis Kenzior
2016-03-18 10:47 [PATCH v2 0/9] allow automatic context activation Dragos Tatulea
2016-03-18 10:47 ` [PATCH 5/5] ubloxmodem: support automatic ctx activation Dragos Tatulea

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=1458301994-5567-9-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