summaryrefslogtreecommitdiffstats
path: root/drivers/atmodem
diff options
context:
space:
mode:
authorChristopher Vogl <christopher.vogl@hale.at>2012-09-06 11:49:17 +0200
committerDenis Kenzior <denkenz@gmail.com>2012-09-11 23:16:32 -0500
commitedbf04cded873ca00a6f4aa41c01989b11deb65a (patch)
treeec1fed91cdf3d604aea080f480f2121f6803150e /drivers/atmodem
parentb87619a43a565b75d4ecbefa88a312a360a4e3c9 (diff)
downloadofono-edbf04cded873ca00a6f4aa41c01989b11deb65a.tar.bz2
netreg: Add telit version for ciev notification
Diffstat (limited to 'drivers/atmodem')
-rw-r--r--drivers/atmodem/network-registration.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/drivers/atmodem/network-registration.c b/drivers/atmodem/network-registration.c
index 71606794..509a47aa 100644
--- a/drivers/atmodem/network-registration.c
+++ b/drivers/atmodem/network-registration.c
@@ -759,6 +759,37 @@ static void ciev_notify(GAtResult *result, gpointer user_data)
ofono_netreg_strength_notify(netreg, strength);
}
+static void telit_ciev_notify(GAtResult *result, gpointer user_data)
+{
+ struct ofono_netreg *netreg = user_data;
+ struct netreg_data *nd = ofono_netreg_get_data(netreg);
+ const char *signal_identifier = "rssi";
+ const char *ind_str;
+ int strength;
+ GAtResultIter iter;
+
+ g_at_result_iter_init(&iter, result);
+
+ if (!g_at_result_iter_next(&iter, "+CIEV:"))
+ return;
+
+ if (!g_at_result_iter_next_unquoted_string(&iter, &ind_str))
+ return;
+
+ if (!g_str_equal(signal_identifier, ind_str))
+ return;
+
+ if (!g_at_result_iter_next_number(&iter, &strength))
+ return;
+
+ if (strength == nd->signal_invalid)
+ strength = -1;
+ else
+ strength = (strength * 100) / (nd->signal_max - nd->signal_min);
+
+ ofono_netreg_strength_notify(netreg, strength);
+}
+
static void ctzv_notify(GAtResult *result, gpointer user_data)
{
struct ofono_netreg *netreg = user_data;
@@ -1618,6 +1649,19 @@ static void cind_support_cb(gboolean ok, GAtResult *result, gpointer user_data)
at_cmer_query_cb, netreg, NULL);
g_at_chat_register(nd->chat, "+CIEV:",
ciev_notify, FALSE, netreg, NULL);
+
+ /*
+ * Telit uses strings instead of numbers to identify indicators
+ * in a +CIEV URC.
+ * Handle them in a separate function to keep the code clean.
+ */
+ if (nd->vendor == OFONO_VENDOR_TELIT)
+ g_at_chat_register(nd->chat, "+CIEV:",
+ telit_ciev_notify, FALSE, netreg, NULL);
+ else
+ g_at_chat_register(nd->chat, "+CIEV:",
+ ciev_notify, FALSE, netreg, NULL);
+
g_at_chat_register(nd->chat, "+CREG:",
creg_notify, FALSE, netreg, NULL);