From e50efac7cc1e545551903e0d1d75cc397991708c Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Mon, 7 Dec 2009 14:53:18 -0600 Subject: [PATCH] Fix: Sometimes Option modems don't return info When querying CGMI the Option modems sometimes just return OK, with no manufacturer information given. --- drivers/atmodem/devinfo.c | 40 +++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/drivers/atmodem/devinfo.c b/drivers/atmodem/devinfo.c index e03389e..0641712 100644 --- a/drivers/atmodem/devinfo.c +++ b/drivers/atmodem/devinfo.c @@ -54,31 +54,37 @@ static void attr_cb(gboolean ok, GAtResult *result, gpointer user_data) ofono_devinfo_query_cb_t cb = cbd->cb; const char *prefix = cbd->user; struct ofono_error error; + int numlines = g_at_result_num_response_lines(result); + GAtResultIter iter; + const char *line; + int i; decode_at_error(&error, g_at_result_final_response(result)); - dump_response("attr_cb", ok, result); - if (ok) { - GAtResultIter iter; - const char *line; - int i; + if (!ok) { + cb(&error, NULL, cbd->data); + return; + } + + if (numlines == 0) { + CALLBACK_WITH_FAILURE(cb, NULL, cbd->data); + return; + } - g_at_result_iter_init(&iter, result); + g_at_result_iter_init(&iter, result); - /* We have to be careful here, sometimes a stray unsolicited - * notification will appear as part of the response and we - * cannot rely on having a prefix to recognize the actual - * response line. So use the last line only as the response - */ - for (i = 0; i < g_at_result_num_response_lines(result); i++) - g_at_result_iter_next(&iter, NULL); + /* We have to be careful here, sometimes a stray unsolicited + * notification will appear as part of the response and we + * cannot rely on having a prefix to recognize the actual + * response line. So use the last line only as the response + */ + for (i = 0; i < numlines; i++) + g_at_result_iter_next(&iter, NULL); - line = g_at_result_iter_raw_line(&iter); + line = g_at_result_iter_raw_line(&iter); - cb(&error, fixup_return(line, prefix), cbd->data); - } else - cb(&error, "", cbd->data); + cb(&error, fixup_return(line, prefix), cbd->data); } static void at_query_manufacturer(struct ofono_devinfo *info, -- 2.7.4