diff options
author | Denis Kenzior <denkenz@gmail.com> | 2010-12-06 21:36:54 -0600 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2010-12-11 11:39:07 -0600 |
commit | 0512a6b740a347b1142dba05e9eccb0fd345ce20 (patch) | |
tree | 33043153188e8e8bdd555ba1065be2d42ce09dd1 | |
parent | 5ca42255c5acebae7fe05d155d09673e10d0fb6a (diff) | |
download | ofono-0512a6b740a347b1142dba05e9eccb0fd345ce20.tar.bz2 |
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.
-rw-r--r-- | drivers/atmodem/atutil.c | 19 |
1 files changed, 17 insertions, 2 deletions
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) |