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.
This commit is contained in:
Denis Kenzior 2010-12-06 21:36:54 -06:00
parent 5ca42255c5
commit 0512a6b740
1 changed files with 17 additions and 2 deletions

View File

@ -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)