xmm: new helper to get 'any' allowed mode combination
This commit is contained in:
committed by
Dan Williams
parent
d6b1c321ef
commit
6262e844f5
@@ -560,3 +560,34 @@ mm_xmm_build_xact_set_command (const MMModemModeCombination *mode,
|
||||
|
||||
return g_string_free (command, FALSE);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Get mode to apply when ANY */
|
||||
|
||||
MMModemMode
|
||||
mm_xmm_get_modem_mode_any (const GArray *combinations)
|
||||
{
|
||||
guint i;
|
||||
MMModemMode any = MM_MODEM_MODE_NONE;
|
||||
guint any_bits_set = 0;
|
||||
|
||||
for (i = 0; i < combinations->len; i++) {
|
||||
MMModemModeCombination *combination;
|
||||
guint bits_set;
|
||||
|
||||
combination = &g_array_index (combinations, MMModemModeCombination, i);
|
||||
if (combination->preferred != MM_MODEM_MODE_NONE)
|
||||
continue;
|
||||
bits_set = mm_count_bits_set (combination->allowed);
|
||||
if (bits_set > any_bits_set) {
|
||||
any_bits_set = bits_set;
|
||||
any = combination->allowed;
|
||||
}
|
||||
}
|
||||
|
||||
/* If combinations were processed via mm_xmm_parse_uact_test_response(),
|
||||
* we're sure that there will be at least one combination with preferred
|
||||
* 'none', so there must be some valid combination as result */
|
||||
g_assert (any != MM_MODEM_MODE_NONE);
|
||||
return any;
|
||||
}
|
||||
|
||||
@@ -36,4 +36,7 @@ gchar *mm_xmm_build_xact_set_command (const MMModemModeCombination *mode,
|
||||
const GArray *bands,
|
||||
GError **error);
|
||||
|
||||
/* Mode to apply when ANY */
|
||||
MMModemMode mm_xmm_get_modem_mode_any (const GArray *combinations);
|
||||
|
||||
#endif /* MM_MODEM_HELPERS_XMM_H */
|
||||
|
||||
Reference in New Issue
Block a user