* [PATCH v2] ublox: network-registration: Handle UREG unsolicited during poll
@ 2020-02-14 9:06 richard.rojfors
2020-02-14 17:27 ` Denis Kenzior
0 siblings, 1 reply; 2+ messages in thread
From: richard.rojfors @ 2020-02-14 9:06 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2305 bytes --]
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 | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/drivers/ubloxmodem/network-registration.c b/drivers/ubloxmodem/network-registration.c
index 6a524f47..662453b4 100644
--- a/drivers/ubloxmodem/network-registration.c
+++ b/drivers/ubloxmodem/network-registration.c
@@ -279,7 +279,7 @@ static void ublox_ureg_cb(gboolean ok, GAtResult *result,
struct netreg_data *nd = ofono_netreg_get_data(tq->netreg);
GAtResultIter iter;
gint enabled, state;
- int tech = tq->tech;
+ int tech = -1;
nd->updating_status = false;
@@ -288,21 +288,22 @@ 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;
+ tech = ublox_ureg_state_to_tech(state);
+ break;
+ }
- tech = ublox_ureg_state_to_tech(state);
+error:
if (tech < 0)
/* No valid UREG status, we have to trust CREG... */
tech = tq->tech;
-
-error:
ofono_netreg_status_notify(tq->netreg,
tq->status, tq->lac, tq->ci, tech);
}
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH v2] ublox: network-registration: Handle UREG unsolicited during poll
2020-02-14 9:06 [PATCH v2] ublox: network-registration: Handle UREG unsolicited during poll richard.rojfors
@ 2020-02-14 17:27 ` Denis Kenzior
0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2020-02-14 17:27 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1081 bytes --]
Hi Richard,
On 2/14/20 3:06 AM, 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 | 21 +++++++++++----------
> 1 file changed, 11 insertions(+), 10 deletions(-)
>
Applied with a minor whitespace fix.
Regards,
-Denis
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-02-14 17:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-14 9:06 [PATCH v2] ublox: network-registration: Handle UREG unsolicited during poll richard.rojfors
2020-02-14 17:27 ` Denis Kenzior
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.