Open Source Telephony
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: ofono@ofono.org
Subject: Re: [PATCH] ublox: network-registration: Handle UREG unsolicited during poll
Date: Thu, 13 Feb 2020 10:44:49 -0600	[thread overview]
Message-ID: <340f70ab-cd3e-242c-ed1c-d09f32b41dc0@gmail.com> (raw)
In-Reply-To: <20200209215928.25656-1-richard.rojfors@gmail.com>

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

Hi Richard,

On 2/9/20 3:59 PM, richard.rojfors(a)gmail.com wrote:
> From: Richard Röjfors <richard@puffinpack.se>
> 
> In the case a unsolicited indication for UREG was received
> while the status was polled. The poll response failed to parse.
> This since the unsolicited indication only carries one
> parameter, while the poll response is expected to carry two.
> 
> Update the code to loop until the response is found.
> 
> The log below shows a case where this happened.
> 
> 10:07:55 ofonod[520]: Aux: > AT+UREG?\r
> 10:07:55 ofonod[520]: Aux: < \r\n+CGREG: 4\r\n\r\n+UREG: 0\r\n\r\n+CIEV: 9,1\r\n
> 10:07:55 ofonod[520]: src/gprs.c:ofono_gprs_status_notify() /ublox_0 status unknown (4)
> 10:07:55 ofonod[520]: src/gprs.c:ofono_gprs_detached_notify() /ublox_0
> 10:07:55 ofonod[520]: Aux: < \r\n+UREG: 1,0\r\n
> 10:07:55 ofonod[520]: Aux: < \r\nOK\r\n
> ---
>   drivers/ubloxmodem/network-registration.c | 18 ++++++++++++------
>   1 file changed, 12 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/ubloxmodem/network-registration.c b/drivers/ubloxmodem/network-registration.c
> index 6a524f47..2c6358e3 100644
> --- a/drivers/ubloxmodem/network-registration.c
> +++ b/drivers/ubloxmodem/network-registration.c
> @@ -288,15 +288,21 @@ static void ublox_ureg_cb(gboolean ok, GAtResult *result,
>   
>   	g_at_result_iter_init(&iter, result);
>   
> -	if (!g_at_result_iter_next(&iter, "+UREG:"))
> -		return;
> +	while (g_at_result_iter_next(&iter, "+UREG:")) {
> +		if (!g_at_result_iter_next_number(&iter, &enabled))
> +			return;
>   
> -	if (!g_at_result_iter_next_number(&iter, &enabled))
> -		return;
> +		/* Sometimes we get an unsolicited UREG here, skip it */
> +		if (!g_at_result_iter_next_number(&iter, &state))
> +			continue;
>   
> -	if (!g_at_result_iter_next_number(&iter, &state))
> -		return;
> +		goto parsed_state;

Wouldn't it look nicer to just perform the ublox_ureg_state_to_tech 
steps here (i.e within the loop) without the goto?

> +	}
> +
> +	/* In case we get here, the response was not parsed */
> +	goto error;

Then this also becomes unnecessary.

>   
> +parsed_state:
>   	tech = ublox_ureg_state_to_tech(state);
>   	if (tech < 0)
>   		/* No valid UREG status, we have to trust CREG... */
> 

Regards,
-Denis

  reply	other threads:[~2020-02-13 16:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-09 21:59 [PATCH] ublox: network-registration: Handle UREG unsolicited during poll richard.rojfors
2020-02-13 16:44 ` Denis Kenzior [this message]
2020-02-14  9:07   ` Richard =?unknown-8bit?q?R=C3=B6jfors?=

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=340f70ab-cd3e-242c-ed1c-d09f32b41dc0@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