aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2010-07-02 15:34:05 -0700
committerDan Williams <dcbw@redhat.com>2010-07-02 15:34:05 -0700
commitdbc7f3d2976cca680183aa4d6163b06445f07502 (patch)
treef03e2cea2c8093f6c0c5a68251a073aa388a9aea
parent88ee478bb659e6660b3bca1e8f2bd45b667a603b (diff)
novatel: fix S720 signal quality reporting
-rw-r--r--plugins/mm-modem-novatel-cdma.c29
1 files changed, 21 insertions, 8 deletions
diff --git a/plugins/mm-modem-novatel-cdma.c b/plugins/mm-modem-novatel-cdma.c
index 64ee15f2..8605a353 100644
--- a/plugins/mm-modem-novatel-cdma.c
+++ b/plugins/mm-modem-novatel-cdma.c
@@ -72,6 +72,8 @@ get_one_qual (const char *reply, const char *tag)
{
int qual = -1;
const char *p;
+ long int dbm;
+ gboolean success = FALSE;
p = strstr (reply, tag);
if (!p)
@@ -83,17 +85,26 @@ get_one_qual (const char *reply, const char *tag)
/* Skip spaces */
while (isspace (*p))
p++;
- if (*p == '-') {
- long int dbm;
-
- errno = 0;
- dbm = strtol (p, NULL, 10);
- if (dbm < 0 && errno == 0) {
- dbm = CLAMP (dbm, -113, -51);
- qual = 100 - ((dbm + 51) * 100 / (-113 + 51));
+
+ errno = 0;
+ dbm = strtol (p, NULL, 10);
+ if (errno == 0) {
+ if (*p == '-') {
+ /* Some cards appear to use RX0/RX1 and output RSSI in negative dBm */
+ if (dbm < 0)
+ success = TRUE;
+ } else if (isdigit (*p) && (dbm > 0) && (dbm < 115)) {
+ /* S720 appears to use "1x RSSI" and print RSSI in dBm without '-' */
+ dbm *= -1;
+ success = TRUE;
}
}
+ if (success) {
+ dbm = CLAMP (dbm, -113, -51);
+ qual = 100 - ((dbm + 51) * 100 / (-113 + 51));
+ }
+
return qual;
}
@@ -123,6 +134,8 @@ get_rssi_done (MMAtSerialPort *port,
/* Parse the signal quality */
qual = get_one_qual (response->str, "RX0=");
if (qual < 0)
+ qual = get_one_qual (response->str, "1x RSSI=");
+ if (qual < 0)
qual = get_one_qual (response->str, "RX1=");
if (qual >= 0) {