aboutsummaryrefslogtreecommitdiff
path: root/plugins/ublox/mm-modem-helpers-ublox.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2017-08-22 11:12:48 +0200
committerAleksander Morgado <aleksander@aleksander.es>2017-09-15 10:31:21 -0700
commita0768a13f66a33cbad3d03b4ff067ec4c2fd88a3 (patch)
tree74fdaa3d9dab9ff36e86b34d1a1a40fc5f2acc0d /plugins/ublox/mm-modem-helpers-ublox.c
parent826c5ad74a882dd8a74448c1ed8b5ea031713836 (diff)
ublox: new AT+UACT=X command builder
Diffstat (limited to 'plugins/ublox/mm-modem-helpers-ublox.c')
-rw-r--r--plugins/ublox/mm-modem-helpers-ublox.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/plugins/ublox/mm-modem-helpers-ublox.c b/plugins/ublox/mm-modem-helpers-ublox.c
index cf7a295f..34ec9b4e 100644
--- a/plugins/ublox/mm-modem-helpers-ublox.c
+++ b/plugins/ublox/mm-modem-helpers-ublox.c
@@ -920,6 +920,18 @@ uact_num_to_band (guint num)
return MM_MODEM_BAND_UNKNOWN;
}
+static guint
+uact_band_to_num (MMModemBand band)
+{
+ guint i;
+
+ for (i = 0; i < G_N_ELEMENTS (uact_band_config); i++) {
+ if (band == uact_band_config[i].band)
+ return uact_band_config[i].num;
+ }
+ return 0;
+}
+
/*****************************************************************************/
/* UACT? response parser */
@@ -1107,6 +1119,43 @@ out:
}
/*****************************************************************************/
+/* UACT=X command builder */
+
+gchar *
+mm_ublox_build_uact_set_command (GArray *bands,
+ GError **error)
+{
+ GString *command;
+
+ /* Build command */
+ command = g_string_new ("+UACT=,,,");
+
+ if (bands->len == 1 && g_array_index (bands, MMModemBand, 0) == MM_MODEM_BAND_ANY)
+ g_string_append (command, "0");
+ else {
+ guint i;
+
+ for (i = 0; i < bands->len; i++) {
+ MMModemBand band;
+ guint num;
+
+ band = g_array_index (bands, MMModemBand, i);
+ num = uact_band_to_num (band);
+ if (!num) {
+ g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_UNSUPPORTED,
+ "Band unsupported by this plugin: %s", mm_modem_band_get_string (band));
+ g_string_free (command, TRUE);
+ return NULL;
+ }
+
+ g_string_append_printf (command, "%s%u", i == 0 ? "" : ",", num);
+ }
+ }
+
+ return g_string_free (command, FALSE);
+}
+
+/*****************************************************************************/
/* URAT? response parser */
gboolean