atmodem: Fix CPUC parser

Apparently some modems are extra stupid:

AT+CPUC?\r
\r\n+CPUC: \r\nOK\r\n

So if we fail to parse the response, return an error
This commit is contained in:
Denis Kenzior 2010-06-07 20:36:40 -05:00
parent 719842ea39
commit 1d8bb1bab6
1 changed files with 12 additions and 6 deletions

View File

@ -247,18 +247,24 @@ static void cpuc_query_cb(gboolean ok,
g_at_result_iter_init(&iter, result);
if (!g_at_result_iter_next(&iter, cbd->user)) {
CALLBACK_WITH_FAILURE(cb, 0, 0, cbd->data);
return;
}
if (g_at_result_iter_next(&iter, cbd->user) != TRUE)
goto error;
if (g_at_result_iter_next_string(&iter, &currency) != TRUE)
goto error;
g_at_result_iter_next_string(&iter, &currency);
strncpy(currency_buf, currency, sizeof(currency_buf));
g_at_result_iter_next_string(&iter, &ppu);
if (g_at_result_iter_next_string(&iter, &ppu) != TRUE)
goto error;
ppuval = strtod(ppu, NULL);
cb(&error, currency_buf, ppuval, cbd->data);
return;
error:
CALLBACK_WITH_FAILURE(cb, 0, 0, cbd->data);
}
static void at_cpuc_query(struct ofono_call_meter *cm,