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.
This commit is contained in:
+11
-6
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user