netreg: Add telit version for ciev notification

This commit is contained in:
Christopher Vogl 2012-09-06 11:49:17 +02:00 committed by Denis Kenzior
parent b87619a43a
commit edbf04cded
1 changed files with 44 additions and 0 deletions

View File

@ -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);