From 0512a6b740a347b1142dba05e9eccb0fd345ce20 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Mon, 6 Dec 2010 21:36:54 -0600 Subject: atutil: Fix parsing of un-quoted CREG / CGREG On broken hardware like the Huawei, it is possible to receive both an unsolicited and a solicited version of the CREG / CGREG within within the same response set. Skipping of the unsolicited version was not handled correctly. This attempts to fix this issue. --- drivers/atmodem/atutil.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'drivers/atmodem') diff --git a/drivers/atmodem/atutil.c b/drivers/atmodem/atutil.c index b6f0d92a..427b0987 100644 --- a/drivers/atmodem/atutil.c +++ b/drivers/atmodem/atutil.c @@ -240,8 +240,23 @@ gboolean at_util_parse_reg(GAtResult *result, const char *prefix, g_at_result_iter_next_number(&iter, &m); /* Sometimes we get an unsolicited CREG/CGREG here, skip it */ - if (g_at_result_iter_next_number(&iter, &s) == FALSE) - continue; + switch (vendor) { + case OFONO_VENDOR_HUAWEI: + case OFONO_VENDOR_NOVATEL: + r = g_at_result_iter_next_unquoted_string(&iter, &str); + + if (r == FALSE || strlen(str) != 1) + continue; + + s = strtol(str, NULL, 10); + + break; + default: + if (g_at_result_iter_next_number(&iter, &s) == FALSE) + continue; + + break; + } /* Some firmware will report bogus lac/ci when unregistered */ if (s != 1 && s != 5) -- cgit v1.2.3