Open Source Telephony
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH 8/9] atmodem: gprs: handle automatic context activation
Date: Thu, 17 Mar 2016 12:56:33 -0500	[thread overview]
Message-ID: <56EAEFD1.4080304@gmail.com> (raw)
In-Reply-To: <1458234140-7936-9-git-send-email-dragos@endocode.com>

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

Hi Dragos,

On 03/17/2016 12:02 PM, Dragos Tatulea wrote:
> When the event comes, trigger CGCONT? to read the APN for the
> activated cid and then call ogono_gprs_cid_activated to handle
> the event.
> ---
>   drivers/atmodem/gprs.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 53 insertions(+)
>
> diff --git a/drivers/atmodem/gprs.c b/drivers/atmodem/gprs.c
> index 4505477..e85bbfb 100644
> --- a/drivers/atmodem/gprs.c
> +++ b/drivers/atmodem/gprs.c
> @@ -49,6 +49,7 @@ static const char *none_prefix[] = { NULL };
>   struct gprs_data {
>   	GAtChat *chat;
>   	unsigned int vendor;
> +	unsigned int last_auto_context_id;
>   };
>
>   static void at_cgatt_cb(gboolean ok, GAtResult *result, gpointer user_data)
> @@ -141,6 +142,49 @@ static void at_gprs_registration_status(struct ofono_gprs *gprs,
>   	CALLBACK_WITH_FAILURE(cb, -1, data);
>   }
>
> +static void at_cgdcont_read_cb(gboolean ok, GAtResult *result,
> +				gpointer user_data)
> +{
> +	struct ofono_gprs *gprs = user_data;
> +	struct gprs_data *gd = ofono_gprs_get_data(gprs);
> +	int activated_cid = gd->last_auto_context_id;
> +	const char *apn = NULL;
> +	GAtResultIter iter;
> +
> +	DBG("ok %d", ok);
> +
> +	if (!ok) {
> +		ofono_warn("Can't read CGDCONT contexts.");
> +		return;
> +	}
> +
> +	g_at_result_iter_init(&iter, result);
> +
> +	while (g_at_result_iter_next(&iter, "+CGDCONT:")) {
> +		int read_cid;
> +
> +		if (!g_at_result_iter_next_number(&iter, &read_cid))
> +			break;
> +
> +		if (read_cid != activated_cid)
> +			continue;
> +
> +		/* ignore protocol */
> +		g_at_result_iter_skip_next(&iter);
> +
> +		g_at_result_iter_next_string(&iter, &apn);
> +
> +		break;
> +	}
> +
> +	if (apn)
> +		ofono_gprs_cid_activated(gprs, activated_cid, apn);
> +	else
> +		ofono_warn("cid %u: Received activated but no apn present",
> +				activated_cid);
> +}
> +
> +
>   static void cgreg_notify(GAtResult *result, gpointer user_data)
>   {
>   	struct ofono_gprs *gprs = user_data;
> @@ -157,6 +201,7 @@ static void cgreg_notify(GAtResult *result, gpointer user_data)
>   static void cgev_notify(GAtResult *result, gpointer user_data)
>   {
>   	struct ofono_gprs *gprs = user_data;
> +	struct gprs_data *gd = ofono_gprs_get_data(gprs);
>   	GAtResultIter iter;
>   	const char *event;
>
> @@ -172,6 +217,14 @@ static void cgev_notify(GAtResult *result, gpointer user_data)
>   			g_str_equal(event, "ME DETACH")) {
>   		ofono_gprs_detached_notify(gprs);
>   		return;
> +	} else if (g_str_has_prefix(event, "ME PDN ACT")) {
> +		char tmp[16] = {0};

This is not our initialization style.

> +
> +		sscanf(event, "%s %s %s %u",

man sscanf.  You can use %*s to skip assignment to tmp completely.

> +				tmp, tmp, tmp, &gd->last_auto_context_id);
> +
> +		g_at_chat_send(gd->chat, "AT+CGDCONT?", cgdcont_prefix,
> +				at_cgdcont_read_cb, gprs, NULL);
>   	}
>   }
>
>

Regards,
-Denis

  reply	other threads:[~2016-03-17 17:56 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 [this message]
2016-03-17 17:02 ` [PATCH 9/9] 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=56EAEFD1.4080304@gmail.com \
    --to=denkenz@gmail.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