From a0768a13f66a33cbad3d03b4ff067ec4c2fd88a3 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Tue, 22 Aug 2017 11:12:48 +0200 Subject: ublox: new AT+UACT=X command builder --- plugins/ublox/mm-modem-helpers-ublox.c | 49 ++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'plugins/ublox/mm-modem-helpers-ublox.c') 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 */ @@ -1106,6 +1118,43 @@ out: return TRUE; } +/*****************************************************************************/ +/* 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 */ -- cgit v1.2.3-70-g09d2