aboutsummaryrefslogtreecommitdiff
path: root/src/mm-modem-helpers.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2013-05-29 12:41:49 +0200
committerAleksander Morgado <aleksander@lanedo.com>2013-06-05 19:15:14 +0200
commit45ceba76924f184ed9e12ba3d35e00a55ad3a197 (patch)
treec413d3e29a64eb86340e964ec48e67d8a66c6f76 /src/mm-modem-helpers.c
parent212d00c529ee07131bf3b71a8759dca49292c059 (diff)
api,introspection: 'SupportedModes' is now a list of possible combinations
Instead of just a mask of MMModemMode values, we now provide a list of the allowed and preferred mode combinations supported by the modem. E.g.: $> sudo mmcli -m 0 ------------------------- Modes | supported: 'allowed: 2g; preferred: none | allowed: 3g; preferred: none | allowed: 2g, 3g; preferred: none | allowed: 2g, 3g; preferred: 2g | allowed: 2g, 3g; preferred: 3g | allowed: 4g; preferred: none | allowed: 2g, 3g, 4g; preferred: none'
Diffstat (limited to 'src/mm-modem-helpers.c')
-rw-r--r--src/mm-modem-helpers.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c
index 46265d04..6d0acb20 100644
--- a/src/mm-modem-helpers.c
+++ b/src/mm-modem-helpers.c
@@ -248,6 +248,53 @@ mm_new_iso8601_time (guint year,
/*****************************************************************************/
+GArray *
+mm_filter_supported_modes (const GArray *all,
+ const GArray *supported_combinations)
+{
+ MMModemModeCombination all_item;
+ guint i;
+ GArray *filtered_combinations;
+ gboolean all_item_added = FALSE;
+
+ g_return_val_if_fail (all != NULL, NULL);
+ g_return_val_if_fail (all->len == 1, NULL);
+ g_return_val_if_fail (supported_combinations != NULL, NULL);
+
+ all_item = g_array_index (all, MMModemModeCombination, 0);
+ g_return_val_if_fail (all_item.allowed != MM_MODEM_MODE_NONE, NULL);
+
+ /* We will filter out all combinations which have modes not listed in 'all' */
+ filtered_combinations = g_array_sized_new (FALSE, FALSE, sizeof (MMModemModeCombination), supported_combinations->len);
+ for (i = 0; i < supported_combinations->len; i++) {
+ MMModemModeCombination *mode;
+
+ mode = &g_array_index (supported_combinations, MMModemModeCombination, i);
+ if (!(mode->allowed & ~all_item.allowed)) {
+ /* Compare only 'allowed', *not* preferred. If there is at least one item with allowed
+ * containing all supported modes, we're already good to go. This allows us to have a
+ * default with preferred != NONE (e.g. Wavecom 2G modem with allowed=CS+2G and
+ * preferred=2G */
+ if (all_item.allowed == mode->allowed)
+ all_item_added = TRUE;
+ g_array_append_val (filtered_combinations, *mode);
+ }
+ }
+
+ if (filtered_combinations->len == 0)
+ mm_warn ("All supported mode combinations were filtered out.");
+
+ /* Add default entry with the generic mask including all items */
+ if (!all_item_added) {
+ mm_dbg ("Adding an explicit item with all supported modes allowed");
+ g_array_append_val (filtered_combinations, all_item);
+ }
+
+ return filtered_combinations;
+}
+
+/*****************************************************************************/
+
/* +CREG: <stat> (GSM 07.07 CREG=1 unsolicited) */
#define CREG1 "\\+(CREG|CGREG|CEREG):\\s*0*([0-9])"