xmm: new helper to get 'any' allowed mode combination

This commit is contained in:
Aleksander Morgado
2018-08-21 17:02:39 +00:00
committed by Dan Williams
parent d6b1c321ef
commit 6262e844f5
2 changed files with 34 additions and 0 deletions
+31
View File
@@ -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;
}
+3
View File
@@ -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 */