From edbf04cded873ca00a6f4aa41c01989b11deb65a Mon Sep 17 00:00:00 2001 From: Christopher Vogl Date: Thu, 6 Sep 2012 11:49:17 +0200 Subject: netreg: Add telit version for ciev notification --- drivers/atmodem/network-registration.c | 44 ++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'drivers/atmodem') 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); -- cgit v1.2.3