diff options
author | Dan Williams <dcbw@redhat.com> | 2009-10-30 17:11:31 -0700 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2009-10-30 17:11:31 -0700 |
commit | 107f950a9e93735fa3ef03f7a522f08f56570f19 (patch) | |
tree | 3dd6338c853298c6d763164a4b064dcc3101f988 /src | |
parent | 122aa62afabab2636691ba338508c9ab7da2ff2b (diff) |
gsm: tighter signal strength validation
The standard dictates CSQ response strength value to be [0 - 31]
inclusive, and 99 means "unknown" or "no service". Make that
apparent and don't treat 99 as 99% which it clearly isn't. Also,
allow spaces in the CSQ response.
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-generic-gsm.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/mm-generic-gsm.c b/src/mm-generic-gsm.c index 111804f5..f08097f6 100644 --- a/src/mm-generic-gsm.c +++ b/src/mm-generic-gsm.c @@ -1476,15 +1476,20 @@ get_signal_quality_done (MMSerialPort *port, reply += 6; - if (sscanf (reply, "%d,%d", &quality, &ber)) { + if (sscanf (reply, "%d, %d", &quality, &ber)) { /* 99 means unknown */ - if (quality != 99) + if (quality == 99) { + info->error = g_error_new_literal (MM_MOBILE_ERROR, + MM_MOBILE_ERROR_NO_NETWORK, + "No service"); + } else { /* Normalize the quality */ - quality = quality * 100 / 31; + quality = CLAMP (quality, 0, 31) * 100 / 31; - priv = MM_GENERIC_GSM_GET_PRIVATE (info->modem); - priv->signal_quality = quality; - mm_callback_info_set_result (info, GUINT_TO_POINTER (quality), NULL); + priv = MM_GENERIC_GSM_GET_PRIVATE (info->modem); + priv->signal_quality = quality; + mm_callback_info_set_result (info, GUINT_TO_POINTER (quality), NULL); + } } else info->error = g_error_new_literal (MM_MODEM_ERROR, MM_MODEM_ERROR_GENERAL, "Could not parse signal quality results"); |