aboutsummaryrefslogtreecommitdiff
path: root/plugins/cinterion/mm-modem-helpers-cinterion.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2014-02-26 16:23:27 +0100
committerAleksander Morgado <aleksander@aleksander.es>2014-02-28 16:35:18 +0100
commit87d867c8aedf59a55fdbed358e252592fc86fc35 (patch)
tree2b5803e56a8c65d9c4d23792770e28bbdea21150 /plugins/cinterion/mm-modem-helpers-cinterion.c
parente6430acaaaa56eae95206a564109e2a04c99e7c5 (diff)
cinterion: add helper to build Cinterion band mask
Diffstat (limited to 'plugins/cinterion/mm-modem-helpers-cinterion.c')
-rw-r--r--plugins/cinterion/mm-modem-helpers-cinterion.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/plugins/cinterion/mm-modem-helpers-cinterion.c b/plugins/cinterion/mm-modem-helpers-cinterion.c
index 8fe641b7..b1d8bebe 100644
--- a/plugins/cinterion/mm-modem-helpers-cinterion.c
+++ b/plugins/cinterion/mm-modem-helpers-cinterion.c
@@ -190,3 +190,49 @@ mm_cinterion_parse_scfg_3g_response (const gchar *response,
return TRUE;
}
+
+/*****************************************************************************/
+/* Build Cinterion-specific band value */
+
+gboolean
+mm_cinterion_build_band (GArray *bands,
+ guint supported,
+ guint *out_band,
+ GError **error)
+{
+ guint band = 0;
+
+ /* The special case of ANY should be treated separately. */
+ if (bands->len == 1 && g_array_index (bands, MMModemBand, 0) == MM_MODEM_BAND_ANY) {
+ band = supported;
+ } else {
+ guint i;
+
+ for (i = 0; i < G_N_ELEMENTS (bands_3g); i++) {
+ guint j;
+
+ for (j = 0; j < bands->len; j++) {
+ if (g_array_index (bands, MMModemBand, j) == bands_3g[i].mm_band) {
+ band |= bands_3g[i].cinterion_band_flag;
+ break;
+ }
+ }
+ }
+ }
+
+ if (band == 0) {
+ gchar *bands_string;
+
+ bands_string = mm_common_build_bands_string ((MMModemBand *)bands->data, bands->len);
+ g_set_error (error,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "The given band combination is not supported: '%s'",
+ bands_string);
+ g_free (bands_string);
+ return FALSE;
+ }
+
+ *out_band = band;
+ return TRUE;
+}