huaweicdma: Add data strength notification support
authorGuillaume Zajac <guillaume.zajac@linux.intel.com>
Tue, 6 Dec 2011 09:33:43 +0000 (10:33 +0100)
committerDenis Kenzior <denkenz@gmail.com>
Wed, 7 Dec 2011 15:55:28 +0000 (09:55 -0600)
drivers/huaweicdmamodem/network-registration.c

index 25c6291..fc054d5 100644 (file)
@@ -141,6 +141,31 @@ error:
        ofono_error("Invalid RSSILVL value");
 }
 
+static void hrssilvl_notify(GAtResult *result, gpointer user_data)
+{
+       struct ofono_cdma_netreg *netreg = user_data;
+       int strength;
+       GAtResultIter iter;
+
+       g_at_result_iter_init(&iter, result);
+
+       if (!g_at_result_iter_next(&iter, "^HRSSILVL:"))
+               goto error;
+
+       if (!g_at_result_iter_next_number(&iter, &strength))
+               goto error;
+
+       if (strength == 99)
+               strength = 100;
+
+       ofono_cdma_netreg_data_strength_notify(netreg, strength);
+
+       return;
+
+error:
+       ofono_error("Invalid HRSSILVL value");
+}
+
 static void probe_cb(gboolean ok, GAtResult *result, gpointer user_data)
 {
        struct ofono_cdma_netreg *netreg = user_data;
@@ -157,6 +182,9 @@ static void probe_cb(gboolean ok, GAtResult *result, gpointer user_data)
        g_at_chat_register(chat, "^RSSILVL:",
                                rssilvl_notify, FALSE, netreg, NULL);
 
+       g_at_chat_register(chat, "^HRSSILVL:",
+                               hrssilvl_notify, FALSE, netreg, NULL);
+
        ofono_cdma_netreg_register(netreg);
 }