mirror of git://git.sysmocom.de/ofono
Move report_signal_strength to atutil
The function is needed in two different places, better to move it to atutil.h.
This commit is contained in:
parent
6f4b3c31fd
commit
bf5b31e8a8
|
@ -55,6 +55,18 @@ static inline struct cb_data *cb_data_new(void *cb, void *data)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int at_util_convert_signal_strength(int strength)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
|
||||||
|
if (strength == 99)
|
||||||
|
result = -1;
|
||||||
|
else
|
||||||
|
result = (strength * 100) / 31;
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
#define DECLARE_FAILURE(e) \
|
#define DECLARE_FAILURE(e) \
|
||||||
struct ofono_error e; \
|
struct ofono_error e; \
|
||||||
e.type = OFONO_ERROR_TYPE_FAILURE; \
|
e.type = OFONO_ERROR_TYPE_FAILURE; \
|
||||||
|
|
|
@ -463,19 +463,6 @@ error:
|
||||||
CALLBACK_WITH_FAILURE(cb, data);
|
CALLBACK_WITH_FAILURE(cb, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void report_signal_strength(struct ofono_netreg *netreg,
|
|
||||||
int strength)
|
|
||||||
{
|
|
||||||
DBG("csq_notify: %d", strength);
|
|
||||||
|
|
||||||
if (strength == 99)
|
|
||||||
strength = -1;
|
|
||||||
else
|
|
||||||
strength = (strength * 100) / 31;
|
|
||||||
|
|
||||||
ofono_netreg_strength_notify(netreg, strength);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void csq_notify(GAtResult *result, gpointer user_data)
|
static void csq_notify(GAtResult *result, gpointer user_data)
|
||||||
{
|
{
|
||||||
struct ofono_netreg *netreg = user_data;
|
struct ofono_netreg *netreg = user_data;
|
||||||
|
@ -490,7 +477,8 @@ static void csq_notify(GAtResult *result, gpointer user_data)
|
||||||
if (!g_at_result_iter_next_number(&iter, &strength))
|
if (!g_at_result_iter_next_number(&iter, &strength))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
report_signal_strength(netreg, strength);
|
ofono_netreg_strength_notify(netreg,
|
||||||
|
at_util_convert_signal_strength(strength));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void calypso_csq_notify(GAtResult *result, gpointer user_data)
|
static void calypso_csq_notify(GAtResult *result, gpointer user_data)
|
||||||
|
@ -507,7 +495,8 @@ static void calypso_csq_notify(GAtResult *result, gpointer user_data)
|
||||||
if (!g_at_result_iter_next_number(&iter, &strength))
|
if (!g_at_result_iter_next_number(&iter, &strength))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
report_signal_strength(netreg, strength);
|
ofono_netreg_strength_notify(netreg,
|
||||||
|
at_util_convert_signal_strength(strength));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void option_osigq_notify(GAtResult *result, gpointer user_data)
|
static void option_osigq_notify(GAtResult *result, gpointer user_data)
|
||||||
|
@ -524,7 +513,8 @@ static void option_osigq_notify(GAtResult *result, gpointer user_data)
|
||||||
if (!g_at_result_iter_next_number(&iter, &strength))
|
if (!g_at_result_iter_next_number(&iter, &strength))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
report_signal_strength(netreg, strength);
|
ofono_netreg_strength_notify(netreg,
|
||||||
|
at_util_convert_signal_strength(strength));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void option_owcti_notify(GAtResult *result, gpointer user_data)
|
static void option_owcti_notify(GAtResult *result, gpointer user_data)
|
||||||
|
|
Loading…
Reference in New Issue