aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2012-11-26 13:25:18 -0600
committerDan Williams <dcbw@redhat.com>2012-11-26 13:25:18 -0600
commit5d854a32cf2d04cbdb3d16f019d277caaba69ab4 (patch)
treef4fcd5cdffa52ec6fce74a36690bf43b2c9c28d6
parentc5a463a175daff4257fc32e516069db8e7efe466 (diff)
gsm: always try +CSQ if +CIND fails; fix bugs
Two issues: 1) if there was a generic error with the +CIND response, the code set the callback error, scheduled the callback, but then continued with +CIND and possibly +CSQ. That could overwrite the original error (a memory leak) and trigger warning about an already-scheduled callback. Instead, just ignore the error and request +CSQ as a fallback. 2) If +CIND parsing failed, the parse error was set on the callback, but +CSQ was also requested. Thus if +CSQ was successful, the +CIND error would still be returned. Instead, just ignore the +CIND parsing error (but log it) and request +CSQ as a fallback.
-rw-r--r--src/mm-generic-gsm.c50
1 files changed, 28 insertions, 22 deletions
diff --git a/src/mm-generic-gsm.c b/src/mm-generic-gsm.c
index cfd31a9b..e15fac5b 100644
--- a/src/mm-generic-gsm.c
+++ b/src/mm-generic-gsm.c
@@ -4501,39 +4501,45 @@ get_cind_signal_done (MMAtSerialPort *port,
MMGenericGsmPrivate *priv;
GByteArray *indicators;
guint quality = 0;
+ GError *local = NULL;
/* If the modem has already been removed, return without
* scheduling callback */
if (mm_callback_info_check_modem_removed (info))
return;
- if (error) {
- info->error = g_error_copy (error);
- mm_callback_info_schedule (info);
- }
+ if (!error) {
+ indicators = mm_parse_cind_query_response (response->str, &local);
+ if (indicators) {
+ priv = MM_GENERIC_GSM_GET_PRIVATE (info->modem);
- priv = MM_GENERIC_GSM_GET_PRIVATE (info->modem);
+ if (indicators->len >= priv->signal_ind) {
+ quality = g_array_index (indicators, guint8, priv->signal_ind);
+ quality = CLAMP (quality, 0, 5) * 20;
+ } else {
+ mm_dbg ("(%s): +CIND respose didn't include signal",
+ mm_port_get_device (MM_PORT (port)));
+ }
+ g_byte_array_free (indicators, TRUE);
+ } else if (local) {
+ mm_dbg ("(%s): %s", mm_port_get_device (MM_PORT (port)), local->message);
+ g_error_free (local);
+ }
- indicators = mm_parse_cind_query_response (response->str, &info->error);
- if (indicators) {
- if (indicators->len >= priv->signal_ind) {
- quality = g_array_index (indicators, guint8, priv->signal_ind);
- quality = CLAMP (quality, 0, 5) * 20;
+ if (quality > 0) {
+ mm_generic_gsm_update_signal_quality (MM_GENERIC_GSM (info->modem), quality);
+ mm_callback_info_set_result (info, GUINT_TO_POINTER (quality), NULL);
+ mm_callback_info_schedule (info);
+ return;
}
- g_byte_array_free (indicators, TRUE);
}
- if (quality > 0) {
- mm_generic_gsm_update_signal_quality (MM_GENERIC_GSM (info->modem), quality);
- mm_callback_info_set_result (info, GUINT_TO_POINTER (quality), NULL);
- mm_callback_info_schedule (info);
- } else {
- /* Some QMI-based devices say they support signal via CIND,
- * but always report zero even though they have signal. So
- * if we get zero signal, try CSQ too. (bgo #636040)
- */
- mm_at_serial_port_queue_command (port, "+CSQ", 3, get_csq_done, info);
- }
+ /* Always fall back to +CSQ if for whatever reason +CIND failed. Also,
+ * some QMI-based devices say they support signal via CIND, but always
+ * report zero even though they have signal. So if we get zero signal
+ * from +CIND, try CSQ too. (bgo #636040)
+ */
+ mm_at_serial_port_queue_command (port, "+CSQ", 3, get_csq_done, info);
}
static void