diff options
-rw-r--r-- | plugins/cinterion/77-mm-cinterion-port-types.rules | 2 | ||||
-rw-r--r-- | plugins/cinterion/mm-broadband-modem-cinterion.c | 171 | ||||
-rw-r--r-- | plugins/cinterion/mm-modem-helpers-cinterion.c | 520 | ||||
-rw-r--r-- | plugins/cinterion/mm-modem-helpers-cinterion.h | 67 | ||||
-rw-r--r-- | plugins/cinterion/tests/test-modem-helpers-cinterion.c | 588 | ||||
-rw-r--r-- | src/mm-charsets.c | 24 | ||||
-rw-r--r-- | src/tests/test-charsets.c | 20 |
7 files changed, 209 insertions, 1183 deletions
diff --git a/plugins/cinterion/77-mm-cinterion-port-types.rules b/plugins/cinterion/77-mm-cinterion-port-types.rules index 4883f764..a3bab858 100644 --- a/plugins/cinterion/77-mm-cinterion-port-types.rules +++ b/plugins/cinterion/77-mm-cinterion-port-types.rules @@ -20,8 +20,6 @@ ATTRS{idVendor}=="1e2d", ATTRS{idProduct}=="0061", ENV{.MM_USBIFNUM}=="04", ENV{ ATTRS{idVendor}=="1e2d", ATTRS{idProduct}=="0061", ENV{.MM_USBIFNUM}=="06", ENV{ID_MM_PORT_IGNORE}="1" ATTRS{idVendor}=="1e2d", ATTRS{idProduct}=="0061", ENV{.MM_USBIFNUM}=="08", ENV{ID_MM_PORT_IGNORE}="1" -# PLS62 family non-mbim enumeration uses alternate settings for 2G band management -ATTRS{idVendor}=="1e2d", ATTRS{idProduct}=="005b", ENV{ID_MM_CINTERION_MODEM_FAMILY}="imt" # PLS62 family non-mbim enumeration # ttyACM0 (if #0): AT port # ttyACM1 (if #2): AT port diff --git a/plugins/cinterion/mm-broadband-modem-cinterion.c b/plugins/cinterion/mm-broadband-modem-cinterion.c index f931dc58..6e526ad3 100644 --- a/plugins/cinterion/mm-broadband-modem-cinterion.c +++ b/plugins/cinterion/mm-broadband-modem-cinterion.c @@ -79,7 +79,7 @@ struct _MMBroadbandModemCinterionPrivate { gchar *sleep_mode_cmd; /* Cached supported bands in Cinterion format */ - guint supported_bands[MM_CINTERION_RB_BLOCK_N]; + guint supported_bands; /* Cached supported modes for SMS setup */ GArray *cnmi_supported_mode; @@ -95,13 +95,6 @@ struct _MMBroadbandModemCinterionPrivate { FeatureSupport swwan_support; FeatureSupport sind_psinfo_support; FeatureSupport smoni_support; - - /* Flags for model-based behaviors */ - MMCinterionModemFamily modem_family; - MMCinterionRadioBandFormat rb_format; - - /* Command sequence */ - MMBaseModemAtCommandAlloc *cmds; }; /*****************************************************************************/ @@ -1157,61 +1150,27 @@ scfg_test_ready (MMBaseModem *_self, response = mm_base_modem_at_command_finish (_self, res, &error); if (!response || !mm_cinterion_parse_scfg_test (response, - self->priv->modem_family, mm_broadband_modem_get_current_charset (MM_BROADBAND_MODEM (self)), &bands, - &self->priv->rb_format, &error)) g_task_return_error (task, error); else { - if (!mm_cinterion_build_band (bands, - NULL, - FALSE, - self->priv->rb_format, - self->priv->modem_family, - self->priv->supported_bands, - &error)) - g_task_return_error (task, error); - else - g_task_return_pointer (task, bands, (GDestroyNotify)g_array_unref); + mm_cinterion_build_band (bands, 0, FALSE, &self->priv->supported_bands, NULL); + g_assert (self->priv->supported_bands != 0); + g_task_return_pointer (task, bands, (GDestroyNotify)g_array_unref); } g_object_unref (task); } static void -load_supported_bands (MMIfaceModem *_self, +load_supported_bands (MMIfaceModem *self, GAsyncReadyCallback callback, gpointer user_data) { - MMBroadbandModemCinterion *self = MM_BROADBAND_MODEM_CINTERION (_self); - GTask *task; - MMPort *primary; - MMKernelDevice *port; - const gchar *family = NULL; - - /* Lookup for the tag specifying which modem family the current device belongs */ - primary = MM_PORT (mm_base_modem_peek_port_primary (MM_BASE_MODEM (self))); - port = mm_port_peek_kernel_device (primary); - family = mm_kernel_device_get_global_property (port, "ID_MM_CINTERION_MODEM_FAMILY"); - - /* if the property is not set, default family */ - self->priv->modem_family = MM_CINTERION_MODEM_FAMILY_DEFAULT; - - /* set used family also in the string for mm_obj_dbg */ - if (!family) - family = "default"; - - if (g_ascii_strcasecmp (family, "imt") == 0) - self->priv->modem_family = MM_CINTERION_MODEM_FAMILY_IMT; - else if (g_ascii_strcasecmp (family, "default") != 0) { - mm_obj_dbg (self, "cinterion modem family '%s' unknown", family); - family = "default"; - } - - mm_obj_dbg (self, "Using cinterion %s modem family", family); + GTask *task; - task = g_task_new (_self, NULL, callback, user_data); - mm_base_modem_at_command (MM_BASE_MODEM (_self), + task = g_task_new (self, NULL, callback, user_data); + mm_base_modem_at_command (MM_BASE_MODEM (self), "AT^SCFG=?", 3, FALSE, @@ -1231,22 +1190,19 @@ load_current_bands_finish (MMIfaceModem *self, } static void -get_band_ready (MMBaseModem *_self, +get_band_ready (MMBaseModem *self, GAsyncResult *res, GTask *task) { - MMBroadbandModemCinterion *self = MM_BROADBAND_MODEM_CINTERION (_self); const gchar *response; GError *error = NULL; GArray *bands = NULL; - response = mm_base_modem_at_command_finish (_self, res, &error); + response = mm_base_modem_at_command_finish (self, res, &error); if (!response || !mm_cinterion_parse_scfg_response (response, - self->priv->modem_family, mm_broadband_modem_get_current_charset (MM_BROADBAND_MODEM (self)), &bands, - self->priv->rb_format, &error)) g_task_return_error (task, error); else @@ -1264,7 +1220,7 @@ load_current_bands (MMIfaceModem *self, task = g_task_new (self, NULL, callback, user_data); mm_base_modem_at_command (MM_BASE_MODEM (self), - "AT^SCFG?", + "AT^SCFG=\"Radio/Band\"", 3, FALSE, (GAsyncReadyCallback)get_band_ready, @@ -1297,100 +1253,43 @@ scfg_set_ready (MMBaseModem *self, } static void -scfg_set_ready_sequence (MMBaseModem *_self, - GAsyncResult *res, - GTask *task) -{ - GError *error = NULL; - gpointer ctx = NULL; - guint i; - MMBroadbandModemCinterion *self; - - self = g_task_get_source_object (task); - for (i = 0; self->priv->cmds[i].command; i++) - mm_base_modem_at_command_alloc_clear (&self->priv->cmds[i]); - g_free(self->priv->cmds); - self->priv->cmds = NULL; - - mm_base_modem_at_sequence_finish (_self, res, &ctx, &error); - g_task_return_boolean (task, TRUE); - g_object_unref (task); -} - -static void set_bands_3g (GTask *task, GArray *bands_array) { MMBroadbandModemCinterion *self; GError *error = NULL; - guint band[MM_CINTERION_RB_BLOCK_N] = { 0 }; + guint band = 0; + gchar *cmd; self = g_task_get_source_object (task); if (!mm_cinterion_build_band (bands_array, self->priv->supported_bands, FALSE, /* 2G and 3G */ - self->priv->rb_format, - self->priv->modem_family, - band, + &band, &error)) { g_task_return_error (task, error); g_object_unref (task); return; } - if (self->priv->rb_format == MM_CINTERION_RADIO_BAND_FORMAT_SINGLE) { - g_autofree gchar *cmd = NULL; - - /* Following the setup: - * AT^SCFG="Radion/Band",<rba> - * We will set the preferred band equal to the allowed band, so that we force - * the modem to connect at that specific frequency only. Note that we will be - * passing a number here! - * - * The optional <rbe> field is set to 1, so that changes take effect - * immediately. - */ - cmd = g_strdup_printf ("^SCFG=\"Radio/Band\",%u,1", band[MM_CINTERION_RB_BLOCK_LEGACY]); - mm_base_modem_at_command (MM_BASE_MODEM (self), - cmd, - 15, - FALSE, - (GAsyncReadyCallback)scfg_set_ready, - task); - } else { /* self->priv->rb_format == MM_CINTERION_RADIO_BAND_FORMAT_MULTIPLE */ - if (self->priv->modem_family == MM_CINTERION_MODEM_FAMILY_IMT) { - g_autofree gchar *bandstr2G = NULL; - g_autofree gchar *bandstr3G = NULL; - g_autofree gchar *bandstr4G = NULL; - - bandstr2G = g_strdup_printf ("0x%08X", band[MM_CINTERION_RB_BLOCK_GSM]); - bandstr3G = g_strdup_printf ("0x%08X", band[MM_CINTERION_RB_BLOCK_UMTS]); - bandstr4G = g_strdup_printf ("0x%08X", band[MM_CINTERION_RB_BLOCK_LTE_LOW]); - bandstr2G = mm_broadband_modem_take_and_convert_to_current_charset (MM_BROADBAND_MODEM (self), bandstr2G); - bandstr3G = mm_broadband_modem_take_and_convert_to_current_charset (MM_BROADBAND_MODEM (self), bandstr3G); - bandstr4G = mm_broadband_modem_take_and_convert_to_current_charset (MM_BROADBAND_MODEM (self), bandstr4G); - self->priv->cmds = g_new0 (MMBaseModemAtCommandAlloc, 3 + 1); - self->priv->cmds[0].command = g_strdup_printf ("^SCFG=\"Radio/Band/2G\",\"%s\"", bandstr2G); - self->priv->cmds[1].command = g_strdup_printf ("^SCFG=\"Radio/Band/3G\",\"%s\"", bandstr3G); - self->priv->cmds[2].command = g_strdup_printf ("^SCFG=\"Radio/Band/4G\",\"%s\"", bandstr4G); - self->priv->cmds[0].timeout = self->priv->cmds[1].timeout = self->priv->cmds[2].timeout = 60; - } else { - self->priv->cmds = g_new0 (MMBaseModemAtCommandAlloc, 3 + 1); - self->priv->cmds[0].command = g_strdup_printf ("^SCFG=\"Radio/Band/2G\",\"%08x\",1", band[MM_CINTERION_RB_BLOCK_GSM]); - self->priv->cmds[1].command = g_strdup_printf ("^SCFG=\"Radio/Band/3G\",\"%08x\",1", band[MM_CINTERION_RB_BLOCK_UMTS]); - self->priv->cmds[2].command = g_strdup_printf ("^SCFG=\"Radio/Band/4G\",\"%08x\",\"%08x\",1", band[MM_CINTERION_RB_BLOCK_LTE_LOW], band[MM_CINTERION_RB_BLOCK_LTE_HIGH]); - self->priv->cmds[0].timeout = self->priv->cmds[1].timeout = self->priv->cmds[2].timeout = 15; - } - - mm_base_modem_at_sequence (MM_BASE_MODEM (self), - (const MMBaseModemAtCommand *)self->priv->cmds, - NULL, - NULL, - (GAsyncReadyCallback)scfg_set_ready_sequence, - task); - } - + /* Following the setup: + * AT^SCFG="Radion/Band",<rba> + * We will set the preferred band equal to the allowed band, so that we force + * the modem to connect at that specific frequency only. Note that we will be + * passing a number here! + * + * The optional <rbe> field is set to 1, so that changes take effect + * immediately. + */ + cmd = g_strdup_printf ("^SCFG=\"Radio/Band\",%u,1", band); + mm_base_modem_at_command (MM_BASE_MODEM (self), + cmd, + 15, + FALSE, + (GAsyncReadyCallback)scfg_set_ready, + task); + g_free (cmd); } static void @@ -1399,7 +1298,7 @@ set_bands_2g (GTask *task, { MMBroadbandModemCinterion *self; GError *error = NULL; - guint band[MM_CINTERION_RB_BLOCK_N] = { 0 }; + guint band = 0; gchar *cmd; gchar *bandstr; @@ -1408,9 +1307,7 @@ set_bands_2g (GTask *task, if (!mm_cinterion_build_band (bands_array, self->priv->supported_bands, TRUE, /* 2G only */ - MM_CINTERION_RADIO_BAND_FORMAT_SINGLE, - 0, - band, + &band, &error)) { g_task_return_error (task, error); g_object_unref (task); @@ -1418,7 +1315,7 @@ set_bands_2g (GTask *task, } /* Build string with the value, in the proper charset */ - bandstr = g_strdup_printf ("%u", band[MM_CINTERION_RB_BLOCK_LEGACY]); + bandstr = g_strdup_printf ("%u", band); bandstr = mm_broadband_modem_take_and_convert_to_current_charset (MM_BROADBAND_MODEM (self), bandstr); if (!bandstr) { g_task_return_new_error (task, diff --git a/plugins/cinterion/mm-modem-helpers-cinterion.c b/plugins/cinterion/mm-modem-helpers-cinterion.c index 1d4f9901..1bc43c61 100644 --- a/plugins/cinterion/mm-modem-helpers-cinterion.c +++ b/plugins/cinterion/mm-modem-helpers-cinterion.c @@ -33,16 +33,10 @@ /* Setup relationship between the 3G band bitmask in the modem and the bitmask * in ModemManager. */ typedef struct { - guint32 cinterion_band_flag; + guint32 cinterion_band_flag; MMModemBand mm_band; } CinterionBand; -typedef struct { - MMCinterionRbBlock cinterion_band_block; - guint32 cinterion_band_flag; - MMModemBand mm_band; -} CinterionBandEx; - /* Table checked in PLS8-X/E/J/V/US, HC25 & PHS8 references. The table includes 2/3/4G * frequencies. Depending on which one is configured, one access technology or * the other will be used. This may conflict with the allowed mode configuration @@ -74,68 +68,6 @@ static const CinterionBand cinterion_bands[] = { { (1 << 24), MM_MODEM_BAND_EUTRAN_19 } }; -static const CinterionBandEx cinterion_bands_ex[] = { - { MM_CINTERION_RB_BLOCK_GSM, 0x00000001, MM_MODEM_BAND_EGSM }, - { MM_CINTERION_RB_BLOCK_GSM, 0x00000002, MM_MODEM_BAND_DCS }, - { MM_CINTERION_RB_BLOCK_GSM, 0x00000004, MM_MODEM_BAND_G850 }, - { MM_CINTERION_RB_BLOCK_GSM, 0x00000008, MM_MODEM_BAND_PCS }, - { MM_CINTERION_RB_BLOCK_UMTS, 0x00000001, MM_MODEM_BAND_UTRAN_1 }, - { MM_CINTERION_RB_BLOCK_UMTS, 0x00000002, MM_MODEM_BAND_UTRAN_2 }, - { MM_CINTERION_RB_BLOCK_UMTS, 0x00000004, MM_MODEM_BAND_UTRAN_3 }, - { MM_CINTERION_RB_BLOCK_UMTS, 0x00000008, MM_MODEM_BAND_UTRAN_4 }, - { MM_CINTERION_RB_BLOCK_UMTS, 0x00000010, MM_MODEM_BAND_UTRAN_5 }, - { MM_CINTERION_RB_BLOCK_UMTS, 0x00000020, MM_MODEM_BAND_UTRAN_6 }, - { MM_CINTERION_RB_BLOCK_UMTS, 0x00000080, MM_MODEM_BAND_UTRAN_8 }, - { MM_CINTERION_RB_BLOCK_UMTS, 0x00000100, MM_MODEM_BAND_UTRAN_9 }, - { MM_CINTERION_RB_BLOCK_UMTS, 0x00040000, MM_MODEM_BAND_UTRAN_19 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x00000001, MM_MODEM_BAND_EUTRAN_1 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x00000002, MM_MODEM_BAND_EUTRAN_2 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x00000004, MM_MODEM_BAND_EUTRAN_3 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x00000008, MM_MODEM_BAND_EUTRAN_4 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x00000010, MM_MODEM_BAND_EUTRAN_5 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x00000040, MM_MODEM_BAND_EUTRAN_7 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x00000080, MM_MODEM_BAND_EUTRAN_8 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x00000800, MM_MODEM_BAND_EUTRAN_12 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x00001000, MM_MODEM_BAND_EUTRAN_13 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x00010000, MM_MODEM_BAND_EUTRAN_17 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x00020000, MM_MODEM_BAND_EUTRAN_18 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x00040000, MM_MODEM_BAND_EUTRAN_19 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x00080000, MM_MODEM_BAND_EUTRAN_20 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x02000000, MM_MODEM_BAND_EUTRAN_26 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x08000000, MM_MODEM_BAND_EUTRAN_28 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x10000000, MM_MODEM_BAND_EUTRAN_29 }, - { MM_CINTERION_RB_BLOCK_LTE_HIGH, 0x00000020, MM_MODEM_BAND_EUTRAN_38 }, - { MM_CINTERION_RB_BLOCK_LTE_HIGH, 0x00000040, MM_MODEM_BAND_EUTRAN_39 }, - { MM_CINTERION_RB_BLOCK_LTE_HIGH, 0x00000080, MM_MODEM_BAND_EUTRAN_40 }, - { MM_CINTERION_RB_BLOCK_LTE_HIGH, 0x00000100, MM_MODEM_BAND_EUTRAN_41 } -}; - -static const CinterionBandEx cinterion_bands_imt[] = { - { MM_CINTERION_RB_BLOCK_GSM, 0x00000004, MM_MODEM_BAND_EGSM }, - { MM_CINTERION_RB_BLOCK_GSM, 0x00000010, MM_MODEM_BAND_DCS }, - { MM_CINTERION_RB_BLOCK_GSM, 0x00000020, MM_MODEM_BAND_PCS }, - { MM_CINTERION_RB_BLOCK_GSM, 0x00000040, MM_MODEM_BAND_G850 }, - { MM_CINTERION_RB_BLOCK_UMTS, 0x00000001, MM_MODEM_BAND_UTRAN_1 }, - { MM_CINTERION_RB_BLOCK_UMTS, 0x00000002, MM_MODEM_BAND_UTRAN_2 }, - { MM_CINTERION_RB_BLOCK_UMTS, 0x00000008, MM_MODEM_BAND_UTRAN_4 }, - { MM_CINTERION_RB_BLOCK_UMTS, 0x00000010, MM_MODEM_BAND_UTRAN_5 }, - { MM_CINTERION_RB_BLOCK_UMTS, 0x00000080, MM_MODEM_BAND_UTRAN_8 }, - { MM_CINTERION_RB_BLOCK_UMTS, 0x00000100, MM_MODEM_BAND_UTRAN_9 }, - { MM_CINTERION_RB_BLOCK_UMTS, 0x00040000, MM_MODEM_BAND_UTRAN_19 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x00000001, MM_MODEM_BAND_EUTRAN_1 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x00000002, MM_MODEM_BAND_EUTRAN_2 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x00000004, MM_MODEM_BAND_EUTRAN_3 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x00000008, MM_MODEM_BAND_EUTRAN_4 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x00000010, MM_MODEM_BAND_EUTRAN_5 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x00000040, MM_MODEM_BAND_EUTRAN_7 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x00000080, MM_MODEM_BAND_EUTRAN_8 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x00000800, MM_MODEM_BAND_EUTRAN_12 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x00020000, MM_MODEM_BAND_EUTRAN_18 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x00040000, MM_MODEM_BAND_EUTRAN_19 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x00080000, MM_MODEM_BAND_EUTRAN_20 }, - { MM_CINTERION_RB_BLOCK_LTE_LOW, 0x08000000, MM_MODEM_BAND_EUTRAN_28 } -}; - /* Check valid combinations in 2G-only devices */ #define VALIDATE_2G_BAND(cinterion_mask) \ (cinterion_mask == 1 || \ @@ -149,127 +81,46 @@ static const CinterionBandEx cinterion_bands_imt[] = { cinterion_mask == 15) /*****************************************************************************/ -/* ^SCFG (3G+LTE) test parser +/* ^SCFG (3G) test parser * - * Example 3G: + * Example: * AT^SCFG=? * ... * ^SCFG: "MEShutdown/OnIgnition",("on","off") * ^SCFG: "Radio/Band",("1-511","0-1") * ^SCFG: "Radio/NWSM",("0","1","2") * ... - * ^SCFG: "Radio/Band\",("1"-"147") - * - * Example LTE1 (GSM charset): - * AT^SCFG=? - * ... - * ^SCFG: "Radio/Band/2G",("0x00000004"-"0x00000074") - * ^SCFG: "Radio/Band/3G",("0x00000001"-"0x0004019B") - * ^SCFG: "Radio/Band/4G",("0x00000001"-"0x080E08DF") - * ... - * - * Example LTE1 (UCS2 charset): - * AT^SCFG=? - * ... - * ^SCFG: "Radio/Band/2G",("0030007800300030003000300030003000300034"-"0030007800300030003000300030003000370034") - * ^SCFG: "Radio/Band/3G",("0030007800300030003000300030003000300031"-"0030007800300030003000340030003100390042") - * ^SCFG: "Radio/Band/4G",("0030007800300030003000300030003000300031"-"0030007800300038003000450030003800440046") - * ... * - * Example LTE2 (all charsets): - * AT^SCFG=? - * ... - * ^SCFG: "Radio/Band/2G",("00000001-0000000f"),,("0","1") - * ^SCFG: "Radio/Band/3G",("00000001-000400b5"),,("0","1") - * ^SCFG: "Radio/Band/4G",("00000001-8a0e00d5"),("00000002-000001e2"),("0","1") - * ... + * ^SCFG: "Radio/Band\",("1"-"147") */ -static void -parse_bands (guint bandlist, - GArray **bands, - MMCinterionRbBlock block, - MMCinterionModemFamily modem_family) -{ - guint i; - const CinterionBandEx *ref_bands; - guint nb_ref_bands; - - if (!bandlist) - return; - - if (modem_family == MM_CINTERION_MODEM_FAMILY_IMT) { - ref_bands = cinterion_bands_imt; - nb_ref_bands = G_N_ELEMENTS (cinterion_bands_imt); - } else { - ref_bands = cinterion_bands_ex; - nb_ref_bands = G_N_ELEMENTS (cinterion_bands_ex); - } - - for (i = 0; i < nb_ref_bands; i++) { - if (block == ref_bands[i].cinterion_band_block && (bandlist & ref_bands[i].cinterion_band_flag)) { - if (G_UNLIKELY (!*bands)) - *bands = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 23); - g_array_append_val (*bands, ref_bands[i].mm_band); - } - } -} - -static guint -take_and_convert_from_matched_string (gchar *str, - MMModemCharset charset, - MMCinterionModemFamily modem_family) -{ - guint val = 0; - - if (!str) - return 0; - - if (modem_family == MM_CINTERION_MODEM_FAMILY_IMT && charset == MM_MODEM_CHARSET_UCS2) - str = mm_charset_take_and_convert_to_utf8 (str, charset); - - mm_get_uint_from_hex_str (str, &val); - g_free (str); - - return val; -} - gboolean -mm_cinterion_parse_scfg_test (const gchar *response, - MMCinterionModemFamily modem_family, - MMModemCharset charset, - GArray **supported_bands, - MMCinterionRadioBandFormat *format, - GError **error) +mm_cinterion_parse_scfg_test (const gchar *response, + MMModemCharset charset, + GArray **supported_bands, + GError **error) { - g_autoptr(GRegex) r1 = NULL; - g_autoptr(GMatchInfo) match_info1 = NULL; - g_autoptr(GRegex) r2 = NULL; - g_autoptr(GMatchInfo) match_info2 = NULL; - GError *inner_error = NULL; - GArray *bands = NULL; - - g_assert (format); + GRegex *r; + GMatchInfo *match_info; + GError *inner_error = NULL; + GArray *bands = NULL; if (!response) { g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "Missing response"); return FALSE; } - r1 = g_regex_new ("\\^SCFG:\\s*\"Radio/Band\",\\((?:\")?([0-9]*)(?:\")?-(?:\")?([0-9]*)(?:\")?.*\\)", - G_REGEX_DOLLAR_ENDONLY | G_REGEX_RAW, 0, NULL); - g_assert (r1 != NULL); - - g_regex_match_full (r1, response, strlen (response), 0, 0, &match_info1, &inner_error); - if (inner_error) - goto finish; - if (g_match_info_matches (match_info1)) { - g_autofree gchar *maxbandstr = NULL; - guint maxband = 0; + r = g_regex_new ("\\^SCFG:\\s*\"Radio/Band\",\\((?:\")?([0-9]*)(?:\")?-(?:\")?([0-9]*)(?:\")?.*\\)", + G_REGEX_DOLLAR_ENDONLY | G_REGEX_RAW, + 0, NULL); + g_assert (r != NULL); - *format = MM_CINTERION_RADIO_BAND_FORMAT_SINGLE; + g_regex_match_full (r, response, strlen (response), 0, 0, &match_info, &inner_error); + if (!inner_error && g_match_info_matches (match_info)) { + gchar *maxbandstr; + guint maxband = 0; - maxbandstr = mm_get_string_unquoted_from_match_info (match_info1, 2); + maxbandstr = mm_get_string_unquoted_from_match_info (match_info, 2); if (maxbandstr) { /* Handle charset conversion if the number is given in UCS2 */ if (charset != MM_MODEM_CHARSET_UNKNOWN) @@ -293,48 +144,14 @@ mm_cinterion_parse_scfg_test (const gchar *response, } } } - goto finish; - } - r2 = g_regex_new ("\\^SCFG:\\s*\"Radio/Band/([234]G)\",\\(\"?([0-9A-Fa-fx]*)\"?-\"?([0-9A-Fa-fx]*)\"?\\)(,*\\(\"?([0-9A-Fa-fx]*)\"?-\"?([0-9A-Fa-fx]*)\"?\\))?", - 0, 0, NULL); - g_assert (r2 != NULL); - g_regex_match_full (r2, response, strlen (response), 0, 0, &match_info2, &inner_error); - if (inner_error) - goto finish; - while (g_match_info_matches (match_info2)) { - g_autofree gchar *techstr = NULL; - guint maxband; - - *format = MM_CINTERION_RADIO_BAND_FORMAT_MULTIPLE; - - techstr = mm_get_string_unquoted_from_match_info (match_info2, 1); - if (g_strcmp0 (techstr, "2G") == 0) { - maxband = take_and_convert_from_matched_string (mm_get_string_unquoted_from_match_info (match_info2, 3), charset, modem_family); - parse_bands (maxband, &bands, MM_CINTERION_RB_BLOCK_GSM, modem_family); - } else if (g_strcmp0 (techstr, "3G") == 0) { - maxband = take_and_convert_from_matched_string (mm_get_string_unquoted_from_match_info (match_info2, 3), charset, modem_family); - parse_bands (maxband, &bands, MM_CINTERION_RB_BLOCK_UMTS, modem_family); - } else if (g_strcmp0 (techstr, "4G") == 0) { - maxband = take_and_convert_from_matched_string (mm_get_string_unquoted_from_match_info (match_info2, 3), charset, modem_family); - parse_bands (maxband, &bands, MM_CINTERION_RB_BLOCK_LTE_LOW, modem_family); - if (modem_family == MM_CINTERION_MODEM_FAMILY_DEFAULT) { - maxband = take_and_convert_from_matched_string (mm_get_string_unquoted_from_match_info (match_info2, 6), charset, modem_family); - parse_bands (maxband, &bands, MM_CINTERION_RB_BLOCK_LTE_HIGH, modem_family); - } - } else { - inner_error = g_error_new (MM_CORE_ERROR, - MM_CORE_ERROR_FAILED, - "Couldn't parse ^SCFG=? response"); - break; - } - - g_match_info_next (match_info2, NULL); + g_free (maxbandstr); } -finish: - /* set error only if not already given */ - if (!bands && !inner_error) + g_match_info_free (match_info); + g_regex_unref (r); + + if (!bands) inner_error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "No valid bands found in ^SCFG=? response"); @@ -351,7 +168,7 @@ finish: } /*****************************************************************************/ -/* ^SCFG response parser (2 types: 2G/3G and LTE) +/* ^SCFG response parser * * Example (3G): * AT^SCFG="Radio/Band" @@ -364,125 +181,63 @@ finish: * Example (2G): * AT+SCFG="Radio/Band" * ^SCFG: "Radio/Band","3","3" - * - * Example LTE1 (GSM charset): - * AT^SCFG=? - * ... - * ^SCFG: "Radio/Band/2G","0x00000074" - * ^SCFG: "Radio/Band/3G","0x0004019B" - * ^SCFG: "Radio/Band/4G","0x080E08DF" - * ... - * AT^SCFG=? - * ... - * Example LTE1 (UCS2 charset): - * AT^SCFG=? - * ... - * ^SCFG: "Radio/Band/2G","0030007800300030003000300030003000370034" - * ^SCFG: "Radio/Band/3G","0030007800300030003000340030003100390042" - * ^SCFG: "Radio/Band/4G","0030007800300038003000450030003800440046" - * ... - * Example LTE2 (all charsets): - * AT^SCFG=? - * ... - * ^SCFG: "Radio/Band/2G","0000000f" - * ^SCFG: "Radio/Band/3G","000400b5" - * ^SCFG: "Radio/Band/4G","8a0e00d5","000000e2" - * ... */ gboolean -mm_cinterion_parse_scfg_response (const gchar *response, - MMCinterionModemFamily modem_family, - MMModemCharset charset, - GArray **current_bands, - MMCinterionRadioBandFormat format, - GError **error) +mm_cinterion_parse_scfg_response (const gchar *response, + MMModemCharset charset, + GArray **current_bands, + GError **error) { - g_autoptr(GRegex) r = NULL; - g_autoptr(GMatchInfo) match_info = NULL; - GError *inner_error = NULL; - GArray *bands = NULL; + GRegex *r; + GMatchInfo *match_info; + GError *inner_error = NULL; + GArray *bands = NULL; if (!response) { g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "Missing response"); return FALSE; } - if (format == MM_CINTERION_RADIO_BAND_FORMAT_SINGLE) { - r = g_regex_new ("\\^SCFG:\\s*\"Radio/Band\",\\s*\"?([0-9a-fA-F]*)\"?", 0, 0, NULL); - g_assert (r != NULL); - g_regex_match_full (r, response, strlen (response), 0, 0, &match_info, &inner_error); - if (inner_error) - goto finish; - if (g_match_info_matches (match_info)) { - g_autofree gchar *currentstr = NULL; - guint current = 0; - - currentstr = mm_get_string_unquoted_from_match_info (match_info, 1); - if (currentstr) { - /* Handle charset conversion if the number is given in UCS2 */ - if (charset != MM_MODEM_CHARSET_UNKNOWN) - currentstr = mm_charset_take_and_convert_to_utf8 (currentstr, charset); - mm_get_uint_from_str (currentstr, ¤t); - } + r = g_regex_new ("\\^SCFG:\\s*\"Radio/Band\",\\s*\"?([0-9a-fA-F]*)\"?", 0, 0, NULL); + g_assert (r != NULL); - if (current == 0) { - inner_error = g_error_new (MM_CORE_ERROR, - MM_CORE_ERROR_FAILED, - "Couldn't parse ^SCFG? response"); - } else { - guint i; - - for (i = 0; i < G_N_ELEMENTS (cinterion_bands); i++) { - if (current & cinterion_bands[i].cinterion_band_flag) { - if (G_UNLIKELY (!bands)) - bands = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 9); - g_array_append_val (bands, cinterion_bands[i].mm_band); - } - } - } + if (g_regex_match (r, response, 0, &match_info)) { + gchar *currentstr; + guint current = 0; + + currentstr = mm_get_string_unquoted_from_match_info (match_info, 1); + if (currentstr) { + /* Handle charset conversion if the number is given in UCS2 */ + if (charset != MM_MODEM_CHARSET_UNKNOWN) + currentstr = mm_charset_take_and_convert_to_utf8 (currentstr, charset); + + mm_get_uint_from_str (currentstr, ¤t); } - } else if (format == MM_CINTERION_RADIO_BAND_FORMAT_MULTIPLE) { - r = g_regex_new ("\\^SCFG:\\s*\"Radio/Band/([234]G)\",\"?([0-9A-Fa-fx]*)\"?,?\"?([0-9A-Fa-fx]*)?\"?", - 0, 0, NULL); - g_assert (r != NULL); - g_regex_match_full (r, response, strlen (response), 0, 0, &match_info, &inner_error); - if (inner_error) - goto finish; - while (g_match_info_matches (match_info)) { - g_autofree gchar *techstr = NULL; - guint current; - - techstr = mm_get_string_unquoted_from_match_info (match_info, 1); - if (g_strcmp0(techstr, "2G") == 0) { - current = take_and_convert_from_matched_string (mm_get_string_unquoted_from_match_info (match_info, 2), charset, modem_family); - parse_bands (current, &bands, MM_CINTERION_RB_BLOCK_GSM, modem_family); - - } else if (g_strcmp0(techstr, "3G") == 0) { - current = take_and_convert_from_matched_string (mm_get_string_unquoted_from_match_info (match_info, 2), charset, modem_family); - parse_bands (current, &bands, MM_CINTERION_RB_BLOCK_UMTS, modem_family); - } else if (g_strcmp0(techstr, "4G") == 0) { - current = take_and_convert_from_matched_string (mm_get_string_unquoted_from_match_info (match_info, 2), charset, modem_family); - parse_bands (current, &bands, MM_CINTERION_RB_BLOCK_LTE_LOW, modem_family); - if (modem_family == MM_CINTERION_MODEM_FAMILY_DEFAULT) { - current = take_and_convert_from_matched_string (mm_get_string_unquoted_from_match_info (match_info, 3), charset, modem_family); - parse_bands (current, &bands, MM_CINTERION_RB_BLOCK_LTE_HIGH, modem_family); + + if (current == 0) { + inner_error = g_error_new (MM_CORE_ERROR, + MM_CORE_ERROR_FAILED, + "Couldn't parse ^SCFG response"); + } else { + guint i; + + for (i = 0; i < G_N_ELEMENTS (cinterion_bands); i++) { + if (current & cinterion_bands[i].cinterion_band_flag) { + if (G_UNLIKELY (!bands)) + bands = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 9); + g_array_append_val (bands, cinterion_bands[i].mm_band); } - } else { - inner_error = g_error_new (MM_CORE_ERROR, - MM_CORE_ERROR_FAILED, - "Couldn't parse ^SCFG? response"); - break; } - - g_match_info_next (match_info, NULL); } - } else - g_assert_not_reached (); -finish: - /* set error only if not already given */ - if (!bands && !inner_error) + g_free (currentstr); + } + + g_match_info_free (match_info); + g_regex_unref (r); + + if (!bands) inner_error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "No valid bands found in ^SCFG response"); @@ -616,101 +371,52 @@ out: /* Build Cinterion-specific band value */ gboolean -mm_cinterion_build_band (GArray *bands, - guint *supported, - gboolean only_2g, - MMCinterionRadioBandFormat format, - MMCinterionModemFamily modem_family, - guint *out_band, - GError **error) +mm_cinterion_build_band (GArray *bands, + guint supported, + gboolean only_2g, + guint *out_band, + GError **error) { - guint band[MM_CINTERION_RB_BLOCK_N] = { 0 }; + guint band = 0; - if (format == MM_CINTERION_RADIO_BAND_FORMAT_SINGLE) { - /* The special case of ANY should be treated separately. */ - if (bands->len == 1 && g_array_index (bands, MMModemBand, 0) == MM_MODEM_BAND_ANY) { - if (supported) - band[MM_CINTERION_RB_BLOCK_LEGACY] = supported[MM_CINTERION_RB_BLOCK_LEGACY]; - } else { - guint i; + /* 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 (cinterion_bands); i++) { - guint j; + for (i = 0; i < G_N_ELEMENTS (cinterion_bands); i++) { + guint j; - for (j = 0; j < bands->len; j++) { - if (g_array_index (bands, MMModemBand, j) == cinterion_bands[i].mm_band) { - band[MM_CINTERION_RB_BLOCK_LEGACY] |= cinterion_bands[i].cinterion_band_flag; - break; - } + for (j = 0; j < bands->len; j++) { + if (g_array_index (bands, MMModemBand, j) == cinterion_bands[i].mm_band) { + band |= cinterion_bands[i].cinterion_band_flag; + break; } } - - /* 2G-only modems only support a subset of the possible band - * combinations. Detect it early and error out. - */ - if (only_2g && !VALIDATE_2G_BAND (band[MM_CINTERION_RB_BLOCK_LEGACY])) - band[MM_CINTERION_RB_BLOCK_LEGACY] = 0; - } - - if (band[MM_CINTERION_RB_BLOCK_LEGACY] == 0) { - g_autofree gchar *bands_string = NULL; - - bands_string = mm_common_build_bands_string ((MMModemBand *)(gpointer)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); - return FALSE; } - } else { /* format == MM_CINTERION_RADIO_BAND_FORMAT_MULTIPLE */ - if (bands->len == 1 && g_array_index (bands, MMModemBand, 0) == MM_MODEM_BAND_ANY) { - if (supported) - memcpy (band, supported, sizeof (guint) * MM_CINTERION_RB_BLOCK_N); - } else { - guint i; - const CinterionBandEx *ref_bands; - guint nb_ref_bands; - - if (modem_family == MM_CINTERION_MODEM_FAMILY_IMT) { - ref_bands = cinterion_bands_imt; - nb_ref_bands = G_N_ELEMENTS (cinterion_bands_imt); - } else { - ref_bands = cinterion_bands_ex; - nb_ref_bands = G_N_ELEMENTS (cinterion_bands_ex); - } + /* 2G-only modems only support a subset of the possible band + * combinations. Detect it early and error out. + */ + if (only_2g && !VALIDATE_2G_BAND (band)) + band = 0; + } - for (i = 0; i < nb_ref_bands; i++) { - guint j; + if (band == 0) { + gchar *bands_string; - for (j = 0; j < bands->len; j++) { - if (g_array_index (bands, MMModemBand, j) == ref_bands[i].mm_band) { - band[ref_bands[i].cinterion_band_block] |= ref_bands[i].cinterion_band_flag; - break; - } - } - } - } - - /* this modem family does not allow disabling all bands in a given technology through this command */ - if (modem_family == MM_CINTERION_MODEM_FAMILY_IMT && - (!band[MM_CINTERION_RB_BLOCK_GSM] || - !band[MM_CINTERION_RB_BLOCK_UMTS] || - !band[MM_CINTERION_RB_BLOCK_LTE_LOW])) { - g_autofree gchar *bands_string = NULL; - - bands_string = mm_common_build_bands_string ((MMModemBand *)(gpointer)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); - return FALSE; - } + bands_string = mm_common_build_bands_string ((MMModemBand *)(gpointer)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; } - memcpy (out_band, band, sizeof (guint) * MM_CINTERION_RB_BLOCK_N); + *out_band = band; return TRUE; } @@ -1169,7 +875,7 @@ mm_cinterion_parse_ctzu_urc (GMatchInfo *match_info, gboolean mm_cinterion_parse_smoni_query_response (const gchar *response, - MMCinterionRadioGen *out_tech, + MMCinterionSmoniTech *out_tech, gdouble *out_rssi, gdouble *out_ecn0, gdouble *out_rscp, @@ -1182,7 +888,7 @@ mm_cinterion_parse_smoni_query_response (const gchar *response, g_autoptr(GMatchInfo) match_info = NULL; g_autoptr(GMatchInfo) match_info_pre = NULL; GError *inner_error = NULL; - MMCinterionRadioGen tech = MM_CINTERION_RADIO_GEN_NONE; + MMCinterionSmoniTech tech = MM_CINTERION_SMONI_NO_TECH; gdouble rssi = -G_MAXDOUBLE; gdouble ecn0 = -G_MAXDOUBLE; gdouble rscp = -G_MAXDOUBLE; @@ -1264,7 +970,7 @@ mm_cinterion_parse_smoni_query_response (const gchar *response, } #define FLOAT "([-+]?[0-9]+\\.?[0-9]*)" switch (tech) { - case MM_CINTERION_RADIO_GEN_2G: + case MM_CINTERION_SMONI_2G: r = g_regex_new ("\\^SMONI:\\s*2G,(\\d+),"FLOAT, 0, 0, NULL); g_assert (r != NULL); g_regex_match_full (r, response, strlen (response), 0, 0, &match_info, &inner_error); @@ -1276,7 +982,7 @@ mm_cinterion_parse_smoni_query_response (const gchar *response, } } break; - case MM_CINTERION_RADIO_GEN_3G: + case MM_CINTERION_SMONI_3G: r = g_regex_new ("\\^SMONI:\\s*3G,(\\d+),(\\d+),"FLOAT","FLOAT, 0, 0, NULL); g_assert (r != NULL); g_regex_match_full (r, response, strlen (response), 0, 0, &match_info, &inner_error); @@ -1293,7 +999,7 @@ mm_cinterion_parse_smoni_query_response (const gchar *response, } } break; - case MM_CINTERION_RADIO_GEN_4G: + case MM_CINTERION_SMONI_4G: r = g_regex_new ("\\^SMONI:\\s*4G,(\\d+),(\\d+),(\\d+),(\\d+),(\\w+),(\\d+),(\\d+),(\\w+),(\\w+),(\\d+),([^,]*),"FLOAT","FLOAT, 0, 0, NULL); g_assert (r != NULL); g_regex_match_full (r, response, strlen (response), 0, 0, &match_info, &inner_error); @@ -1319,7 +1025,7 @@ mm_cinterion_parse_smoni_query_response (const gchar *response, } } break; - case MM_CINTERION_RADIO_GEN_NONE: + case MM_CINTERION_SMONI_NO_TECH: default: goto out; } @@ -1358,7 +1064,7 @@ mm_cinterion_smoni_response_to_signal_info (const gchar *response, MMSignal **out_lte, GError **error) { - MMCinterionRadioGen tech = MM_CINTERION_RADIO_GEN_NONE; + MMCinterionSmoniTech tech = MM_CINTERION_SMONI_NO_TECH; gdouble rssi = MM_SIGNAL_UNKNOWN; gdouble ecn0 = MM_SIGNAL_UNKNOWN; gdouble rscp = MM_SIGNAL_UNKNOWN; @@ -1376,21 +1082,21 @@ mm_cinterion_smoni_response_to_signal_info (const gchar *response, return FALSE; switch (tech) { - case MM_CINTERION_RADIO_GEN_2G: + case MM_CINTERION_SMONI_2G: gsm = mm_signal_new (); mm_signal_set_rssi (gsm, rssi); break; - case MM_CINTERION_RADIO_GEN_3G: + case MM_CINTERION_SMONI_3G: umts = mm_signal_new (); mm_signal_set_rscp (umts, rscp); mm_signal_set_ecio (umts, ecn0); /* UMTS EcIo (assumed EcN0) */ break; - case MM_CINTERION_RADIO_GEN_4G: + case MM_CINTERION_SMONI_4G: lte = mm_signal_new (); mm_signal_set_rsrp (lte, rsrp); mm_signal_set_rsrq (lte, rsrq); break; - case MM_CINTERION_RADIO_GEN_NONE: /* not registered, searching */ + case MM_CINTERION_SMONI_NO_TECH: /* not registered, searching */ break; /* no error case */ default: /* should not happen, so if it does, error */ g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, diff --git a/plugins/cinterion/mm-modem-helpers-cinterion.h b/plugins/cinterion/mm-modem-helpers-cinterion.h index c35c5b3c..a939e499 100644 --- a/plugins/cinterion/mm-modem-helpers-cinterion.h +++ b/plugins/cinterion/mm-modem-helpers-cinterion.h @@ -26,51 +26,21 @@ #define _LIBMM_INSIDE_MM #include <libmm-glib.h> -typedef enum { - MM_CINTERION_MODEM_FAMILY_DEFAULT = 0, - MM_CINTERION_MODEM_FAMILY_IMT = 1, -} MMCinterionModemFamily; - -typedef enum { - MM_CINTERION_RADIO_BAND_FORMAT_SINGLE = 0, - MM_CINTERION_RADIO_BAND_FORMAT_MULTIPLE = 1, -} MMCinterionRadioBandFormat; - -typedef enum { - MM_CINTERION_RB_BLOCK_LEGACY = 0, - MM_CINTERION_RB_BLOCK_GSM = 0, - MM_CINTERION_RB_BLOCK_UMTS = 1, - MM_CINTERION_RB_BLOCK_LTE_LOW = 2, - MM_CINTERION_RB_BLOCK_LTE_HIGH = 3, - MM_CINTERION_RB_BLOCK_N = 4 -} MMCinterionRbBlock; - -typedef enum { - MM_CINTERION_RADIO_GEN_NONE = 0, - MM_CINTERION_RADIO_GEN_2G = 2, - MM_CINTERION_RADIO_GEN_3G = 3, - MM_CINTERION_RADIO_GEN_4G = 4, -} MMCinterionRadioGen; - /*****************************************************************************/ /* ^SCFG test parser */ -gboolean mm_cinterion_parse_scfg_test (const gchar *response, - MMCinterionModemFamily modem_family, - MMModemCharset charset, - GArray **supported_bands, - MMCinterionRadioBandFormat *format, - GError **error); +gboolean mm_cinterion_parse_scfg_test (const gchar *response, + MMModemCharset charset, + GArray **supported_bands, + GError **error); /*****************************************************************************/ /* ^SCFG response parser */ -gboolean mm_cinterion_parse_scfg_response (const gchar *response, - MMCinterionModemFamily modem_family, - MMModemCharset charset, - GArray **bands, - MMCinterionRadioBandFormat format, - GError **error); +gboolean mm_cinterion_parse_scfg_response (const gchar *response, + MMModemCharset charset, + GArray **bands, + GError **error); /*****************************************************************************/ /* +CNMI test parser */ @@ -86,13 +56,11 @@ gboolean mm_cinterion_parse_cnmi_test (const gchar *response, /*****************************************************************************/ /* Build Cinterion-specific band value */ -gboolean mm_cinterion_build_band (GArray *bands, - guint *supported, - gboolean only_2g, - MMCinterionRadioBandFormat format, - MMCinterionModemFamily modem_family, - guint *out_band, - GError **error); +gboolean mm_cinterion_build_band (GArray *bands, + guint supported, + gboolean only_2g, + guint *out_band, + GError **error); /*****************************************************************************/ /* Single ^SIND response parser */ @@ -148,8 +116,15 @@ gboolean mm_cinterion_parse_ctzu_urc (GMatchInfo *match_info, /*****************************************************************************/ /* ^SMONI helper */ +typedef enum { /*< underscore_name=mm_modem_port_type >*/ + MM_CINTERION_SMONI_NO_TECH = 0, + MM_CINTERION_SMONI_2G = 2, + MM_CINTERION_SMONI_3G = 3, + MM_CINTERION_SMONI_4G = 4, +} MMCinterionSmoniTech; + gboolean mm_cinterion_parse_smoni_query_response (const gchar *response, - MMCinterionRadioGen *out_tech, + MMCinterionSmoniTech *out_tech, gdouble *out_rssi, gdouble *out_ecn0, gdouble *out_rscp, diff --git a/plugins/cinterion/tests/test-modem-helpers-cinterion.c b/plugins/cinterion/tests/test-modem-helpers-cinterion.c index b23a356e..ff21a921 100644 --- a/plugins/cinterion/tests/test-modem-helpers-cinterion.c +++ b/plugins/cinterion/tests/test-modem-helpers-cinterion.c @@ -34,22 +34,17 @@ static void common_test_scfg (const gchar *response, - GArray *expected_bands, - MMModemCharset charset, - MMCinterionModemFamily modem_family) + GArray *expected_bands) { GArray *bands = NULL; gchar *expected_bands_str; gchar *bands_str; GError *error = NULL; gboolean res; - MMCinterionRadioBandFormat format; res = mm_cinterion_parse_scfg_test (response, - modem_family, - charset, + MM_MODEM_CHARSET_UNKNOWN, &bands, - &format, &error); g_assert_no_error (error); g_assert (res == TRUE); @@ -116,7 +111,7 @@ test_scfg (void) single = MM_MODEM_BAND_UTRAN_8, g_array_append_val (expected_bands, single); single = MM_MODEM_BAND_UTRAN_6, g_array_append_val (expected_bands, single); - common_test_scfg (response, expected_bands, MM_MODEM_CHARSET_UNKNOWN, MM_CINTERION_MODEM_FAMILY_DEFAULT); + common_test_scfg (response, expected_bands); g_array_unref (expected_bands); } @@ -184,271 +179,7 @@ test_scfg_ehs5 (void) single = MM_MODEM_BAND_UTRAN_1, g_array_append_val (expected_bands, single); single = MM_MODEM_BAND_UTRAN_8, g_array_append_val (expected_bands, single); - common_test_scfg (response, expected_bands, MM_MODEM_CHARSET_UNKNOWN, MM_CINTERION_MODEM_FAMILY_DEFAULT); - - g_array_unref (expected_bands); -} - -static void -test_scfg_pls62_gsm (void) -{ - GArray *expected_bands; - MMModemBand single; - const gchar *response = - "^SCFG: \"MEopMode/Prov/AutoSelect\",(\"off\",\"on\")\r\n" - "^SCFG: \"MEopMode/Prov/Cfg\",(\"fallback\",\"attus\")\r\n" - "^SCFG: \"Serial/Ifc\",(\"Current\",\"ASC0\",\"USB0\",\"USB1\",\"USB2\",\"MUX1\",\"MUX2\",\"MUX3\",\"0\"),(\"0\",\"3\"),(\"1200\",\"2400\",\"4800\",\"9600\",\"19200\",\"38400\",\"57600\",\"115200\",\"230400\",\"460800\",\"500000\",\"750000\",\"921600\"),(\"0)\r\n" - "^SCFG: \"RemoteWakeUp/Ports\",(\"current\",\"powerup\"),(\"asc0\",\"acm1\",\"acm2\",\"acm3\",\"rmnet0\",\"rmnet1\")\r\n" - "^SCFG: \"Gpio/mode/ASC1\",(\"std\",\"gpio\",\"rsv\")\r\n" - "^SCFG: \"Gpio/mode/DCD0\",(\"std\",\"gpio\",\"rsv\")\r\n" - "^SCFG: \"Gpio/mode/DSR0\",(\"std\",\"gpio\",\"rsv\")\r\n" - "^SCFG: \"Gpio/mode/DTR0\",(\"std\",\"gpio\",\"rsv\")\r\n" - "^SCFG: \"Gpio/mode/FSR\",(\"std\",\"gpio\",\"rsv\")\r\n" - "^SCFG: \"Gpio/mode/PULSE\",(\"std\",\"gpio\",\"rsv\")\r\n" - "^SCFG: \"Gpio/mode/PWM\",(\"std\",\"gpio\",\"rsv\")\r\n" - "^SCFG: \"Gpio/mode/HWAKEUP\",(\"std\",\"gpio\",\"rsv\")\r\n" - "^SCFG: \"Gpio/mode/RING0\",(\"std\",\"gpio\",\"rsv\")\r\n" - "^SCFG: \"Gpio/mode/SPI\",(\"std\",\"gpio\",\"rsv\")\r\n" - "^SCFG: \"Gpio/mode/SYNC\",(\"std\",\"gpio\",\"rsv\")\r\n" - "^SCFG: \"GPRS/AutoAttach\",(\"disabled\",\"enabled\")\r\n" - "^SCFG: \"Ident/Manufacturer\",(25)\r\n" - "^SCFG: \"Ident/Product\",(25)\r\n" - "^SCFG: \"MEopMode/SoR\",(\"off\",\"on\")\r\n" - "^SCFG: \"MEopMode/CregRoam\",(\"0\",\"1\")\r\n" - "^SCFG: \"MeOpMode/SRPOM\",(\"0\",\"1\")\r\n" - "^SCFG: \"MEopMode/RingOnData\",(\"off\",\"on\")\r\n" - "^SCFG: \"MEShutdown/Fso\",(\"0\",\"1\")\r\n" - "^SCFG: \"MEShutdown/sVsup/threshold\",(\"-4\",\"-3\",\"-2\",\"-1\",\"0\",\"1\",\"2\",\"3\",\"4\"),(\"0\")\r\n" - "^SCFG: \"Radio/Band/2G\",(\"0x00000004\"-\"0x00000074\")\r\n" - "^SCFG: \"Radio/Band/3G\",(\"0x00000001\"-\"0x0004019B\")\r\n" - "^SCFG: \"Radio/Band/4G\",(\"0x00000001\"-\"0x080E08DF\")\r\n" - "^SCFG: \"Radio/Mtpl/2G\",(\"0\"-\"3\"),(\"1\"-\"8\"),(\"0x00000004\",\"0x00000010\",\"0x00000020\",\"0x00000040\"),,(\"18\"-\"33\"),(\"18\"-\"27\")\r\n" - "^SCFG: \"Radio/Mtpl/3G\",(\"0\"-\"3\"),(\"1\"-\"8\"),(\"0x00000001\",\"0x00000002\",\"0x00000008\",\"0x00000010\",\"0x00000080\",\"0x00000100\",\"0x00040000\"),,(\"18\"-\"24\")\r\n" - "^SCFG: \"Radio/Mtpl/4G\",(\"0\"-\"3\"),(\"1\"-\"8\"),(\"0x00000001\",\"0x00000002\",\"0x00000004\",\"0x00000008\",\"0x00000010\",\"0x00000040\",\"0x00000080\",\"0x00000800\",\"0x00020000\",\"0x00040000\",\"0x00080000\",\"0x08000000\"),,(\"18)\r\n" - "^SCFG: \"Radio/OutputPowerReduction\",(\"0\",\"1\",\"2\",\"3\",\"4\")\r\n" - "^SCFG: \"Serial/Interface/Allocation\",(\"0\",\"1\"),(\"0\",\"1\")\r\n" - "^SCFG: \"Serial/USB/DDD\",(\"0\",\"1\"),(\"0\"),(4),(4),(4),(63),(63),(4)\r\n" - "^SCFG: \"Tcp/IRT\",(\"1\"-\"60\")\r\n" - "^SCFG: \"Tcp/MR\",(\"2\"-\"30\")\r\n" - "^SCFG: \"Tcp/OT\",(\"1\"-\"6000\")\r\n" - "^SCFG: \"Tcp/WithURCs\",(\"on\",\"off\")\r\n" - "^SCFG: \"Trace/Syslog/OTAP\",(\"0\",\"1\"),(\"null\",\"asc0\",\"asc1\",\"usb\",\"usb1\",\"usb2\",\"file\",\"system\"),(\"1\"-\"65535\"),(125),(\"buffered\",\"secure\"),(\"off\",\"on\")\r\n" - "^SCFG: \"Urc/Ringline\",(\"off\",\"local\",\"asc0\",\"wakeup\")\r\n" - "^SCFG: \"Urc/Ringline/ActiveTime\",(\"0\",\"1\",\"2\")\r\n" - "^SCFG: \"Userware/Autostart\",(\"0\",\"1\")\r\n" - "^SCFG: \"Userware/Autostart/Delay\",(\"0\"-\"10000\")\r\n" - "^SCFG: \"Userware/DebugInterface\",(\"0\"-\"255\")|(\"FE80::\"-\"FE80::FFFFFFFFFFFFFFFF\"),(\"0\"-\"255\")|(\"FE80::\"-\"FE80::FFFFFFFFFFFFFFFF\"),(\"0\",\"1\")\r\n" - "^SCFG: \"Userware/DebugMode\",(\"off\",\"on\")\r\n" - "^SCFG: \"Userware/Passwd\",(\"0\"-\"8\")\r\n" - "^SCFG: \"Userware/Stdout\",(\"null\",\"asc0\",\"asc1\",\"usb\",\"usb1\",\"usb2\",\"file\",\"system\"),(\"1\"-\"65535\"),(\"0\"-\"125\"),(\"buffered\",\"secure\"),(\"off\",\"on\")\r\n" - "^SCFG: \"Userware/Watchdog\",(\"0\",\"1\",\"2\")\r\n" - "^SCFG: \"MEopMode/ExpectDTR\",(\"current\",\"powerup\"),(\"asc0\",\"acm1\",\"acm2\",\"acm3\")\r\n"; - - expected_bands = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 23); - single = MM_MODEM_BAND_EGSM, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_DCS, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_PCS, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_G850, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_1, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_2, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_4, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_5, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_8, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_9, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_19, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_1, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_2, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_3, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_4, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_5, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_7, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_8, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_12, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_18, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_19, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_20, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_28, g_array_append_val (expected_bands, single); - - common_test_scfg (response, expected_bands, MM_MODEM_CHARSET_GSM, MM_CINTERION_MODEM_FAMILY_IMT); - - g_array_unref (expected_bands); -} - -static void -test_scfg_pls62_ucs2 (void) -{ - GArray *expected_bands; - MMModemBand single; - const gchar *response = - "^SCFG: \"MEopMode/Prov/AutoSelect\",(\"006F00660066\",\"006F006E\")\r\n" - "^SCFG: \"MEopMode/Prov/Cfg\",(\"fallback\",\"attus\")\r\n" - "^SCFG: \"Serial/Ifc\",(\"00430075007200720065006E0074\",\"0041005300430030\",\"0055005300420030\",\"0055005300420031\",\"0055005300420032\",\"004D005500580031\",\"004D005500580032\",\"004D005500580033\",\"0030\"),(\"0030\",\"0033)\r\n" - "^SCFG: \"RemoteWakeUp/Ports\",(\"00630075007200720065006E0074\",\"0070006F00770065007200750070\"),(\"0061007300630030\",\"00610063006D0031\",\"00610063006D0032\",\"00610063006D0033\",\"0072006D006E006500740030\",\"0072006D0)\r\n" - "^SCFG: \"Gpio/mode/ASC1\",(\"007300740064\",\"006700700069006F\",\"007200730076\")\r\n" - "^SCFG: \"Gpio/mode/DCD0\",(\"007300740064\",\"006700700069006F\",\"007200730076\")\r\n" - "^SCFG: \"Gpio/mode/DSR0\",(\"007300740064\",\"006700700069006F\",\"007200730076\")\r\n" - "^SCFG: \"Gpio/mode/DTR0\",(\"007300740064\",\"006700700069006F\",\"007200730076\")\r\n" - "^SCFG: \"Gpio/mode/FSR\",(\"007300740064\",\"006700700069006F\",\"007200730076\")\r\n" - "^SCFG: \"Gpio/mode/PULSE\",(\"007300740064\",\"006700700069006F\",\"007200730076\")\r\n" - "^SCFG: \"Gpio/mode/PWM\",(\"007300740064\",\"006700700069006F\",\"007200730076\")\r\n" - "^SCFG: \"Gpio/mode/HWAKEUP\",(\"007300740064\",\"006700700069006F\",\"007200730076\")\r\n" - "^SCFG: \"Gpio/mode/RING0\",(\"007300740064\",\"006700700069006F\",\"007200730076\")\r\n" - "^SCFG: \"Gpio/mode/SPI\",(\"007300740064\",\"006700700069006F\",\"007200730076\")\r\n" - "^SCFG: \"Gpio/mode/SYNC\",(\"007300740064\",\"006700700069006F\",\"007200730076\")\r\n" - "^SCFG: \"GPRS/AutoAttach\",(\"00640069007300610062006C00650064\",\"0065006E00610062006C00650064\")\r\n" - "^SCFG: \"Ident/Manufacturer\",(25)\r\n" - "^SCFG: \"Ident/Product\",(25)\r\n" - "^SCFG: \"MEopMode/SoR\",(\"006F00660066\",\"006F006E\")\r\n" - "^SCFG: \"MEopMode/CregRoam\",(\"0030\",\"0031\")\r\n" - "^SCFG: \"MeOpMode/SRPOM\",(\"0030\",\"0031\")\r\n" - "^SCFG: \"MEopMode/RingOnData\",(\"006F00660066\",\"006F006E\")\r\n" - "^SCFG: \"MEShutdown/Fso\",(\"0030\",\"0031\")\r\n" - "^SCFG: \"MEShutdown/sVsup/threshold\",(\"002D0034\",\"002D0033\",\"002D0032\",\"002D0031\",\"0030\",\"0031\",\"0032\",\"0033\",\"0034\"),(\"0030\")\r\n" - "^SCFG: \"Radio/Band/2G\",(\"0030007800300030003000300030003000300034\"-\"0030007800300030003000300030003000370034\")\r\n" - "^SCFG: \"Radio/Band/3G\",(\"0030007800300030003000300030003000300031\"-\"0030007800300030003000340030003100390042\")\r\n" - "^SCFG: \"Radio/Band/4G\",(\"0030007800300030003000300030003000300031\"-\"0030007800300038003000450030003800440046\")\r\n" - "^SCFG: \"Radio/Mtpl/2G\",(\"00300022002D00220033\"),(\"00310022002D00220038\"),(\"00300078003000300030003000300030003000340022002C002200300078003000300030003000300030003100300022002C0022003000780030003000300030003)\r\n" - "^SCFG: \"Radio/Mtpl/3G\",(\"00300022002D00220033\"),(\"00310022002D00220038\"),(\"00300078003000300030003000300030003000310022002C002200300078003000300030003000300030003000320022002C0022003000780030003000300030003)\r\n" - "^SCFG: \"Radio/Mtpl/4G\",(\"00300022002D00220033\"),(\"00310022002D00220038\"),(\"00310022002D00220038\"),,(\"003100380022002D002200320033\")\r\n" - "^SCFG: \"Radio/OutputPowerReduction\",(\"0030\",\"0031\",\"0032\",\"0033\",\"0034\")\r\n" - "^SCFG: \"Serial/Interface/Allocation\",(\"0030\",\"0031\"),(\"0030\",\"0031\")\r\n" - "^SCFG: \"Serial/USB/DDD\",(\"0030\",\"0031\"),(\"0030\"),(4),(4),(4),(63),(63),(4)\r\n" - "^SCFG: \"Tcp/IRT\",(\"0031\"-\"00360030\")\r\n" - "^SCFG: \"Tcp/MR\",(\"0032\"-\"00330030\")\r\n" - "^SCFG: \"Tcp/OT\",(\"0031\"-\"0036003000300030\")\r\n" - "^SCFG: \"Tcp/WithURCs\",(\"006F006E\",\"006F00660066\")\r\n" - "^SCFG: \"Trace/Syslog/OTAP\",(\"0030\",\"0031\"),(\"006E0075006C006C\",\"0061007300630030\",\"0061007300630031\",\"007500730062\",\"0075007300620031\",\"0075007300620032\",\"00660069006C0065\",\"00730079007300740065006D\"),(\"003)\r\n" - "^SCFG: \"Urc/Ringline\",(\"006F00660066\",\"006C006F00630061006C\",\"0061007300630030\",\"00770061006B006500750070\")\r\n" - "^SCFG: \"Urc/Ringline/ActiveTime\",(\"0030\",\"0031\",\"0032\")\r\n" - "^SCFG: \"Userware/Autostart\",(\"0030\",\"0031\")\r\n" - "^SCFG: \"Userware/Autostart/Delay\",(\"00300022002D002200310030003000300030\")\r\n" - "^SCFG: \"Userware/DebugInterface\",(\"0030\"-\"003200350035\")|(\"0046004500380030003A003A\"-\"0046004500380030003A003A0046004600460046004600460046004600460046004600460046004600460046\"),(\"0030\"-\"003200350035\")|(\"004)\r\n" - "^SCFG: \"Userware/DebugMode\",(\"006F00660066\",\"006F006E\")\r\n" - "^SCFG: \"Userware/Passwd\",(\"0030\"-\"0038\")\r\n" - "^SCFG: \"Userware/Stdout\",(\"006E0075006C006C\",\"0061007300630030\",\"0061007300630031\",\"007500730062\",\"0075007300620031\",\"0075007300620032\",\"00660069006C0065\",\"00730079007300740065006D\"),(\"0031\"-\"00360035003500)\r\n" - "^SCFG: \"Userware/Watchdog\",(\"0030\",\"0031\",\"0032\")\r\n" - "^SCFG: \"MEopMode/ExpectDTR\",(\"00630075007200720065006E0074\",\"0070006F00770065007200750070\"),(\"0061007300630030\",\"00610063006D0031\",\"00610063006D0032\",\"00610063006D0033\")\r\n"; - - expected_bands = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 23); - single = MM_MODEM_BAND_EGSM, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_DCS, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_PCS, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_G850, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_1, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_2, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_4, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_5, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_8, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_9, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_19, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_1, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_2, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_3, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_4, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_5, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_7, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_8, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_12, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_18, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_19, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_20, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_28, g_array_append_val (expected_bands, single); - - common_test_scfg (response, expected_bands, MM_MODEM_CHARSET_UCS2, MM_CINTERION_MODEM_FAMILY_IMT); - - g_array_unref (expected_bands); -} - -static void -test_scfg_alas5 (void) -{ - GArray *expected_bands; - MMModemBand single; - const gchar *response = - "^SCFG: \"Audio/Loop\",(\"0\",\"1\")\r\n" - "^SCFG: \"Audio/SvTone\",(\"0-2047\")\r\n" - "^SCFG: \"Call/Ecall/AckTimeout\",(\"0-60000\")\r\n" - "^SCFG: \"Call/Ecall/BlockSMSPP\",(\"0\",\"1\")\r\n" - "^SCFG: \"Call/Ecall/Callback\",(\"0\",\"1\")\r\n" - "^SCFG: \"Call/Ecall/CallbackTimeout\",(\"0-86400000\")\r\n" - "^SCFG: \"Call/Ecall/Force\",(\"0\",\"1\",\"2\")\r\n" - "^SCFG: \"Call/Ecall/Msd\",(280)\r\n" - "^SCFG: \"Call/Ecall/Pullmode\",(\"0\",\"1\")\r\n" - "^SCFG: \"Call/Ecall/SessionTimeout\",(\"0-300000\")\r\n" - "^SCFG: \"Call/Ecall/StartTimeout\",(\"0-600000\")\r\n" - "^SCFG: \"Call/ECC\",(\"0\"-\"255\")\r\n" - "^SCFG: \"Call/Speech/Codec\",(\"0\",\"2\")\r\n" - "^SCFG: \"GPRS/Auth\",(\"0\",\"1\",\"2\")\r\n" - "^SCFG: \"GPRS/AutoAttach\",(\"disabled\",\"enabled\")\r\n" - "^SCFG: \"GPRS/MTU/Mode\",(\"0-1\")\r\n" - "^SCFG: \"GPRS/MTU/Size\",(\"1280-4096\")\r\n" - "^SCFG: \"MEopMode/CFUN\",(\"0\",\"1\")\r\n" - "^SCFG: \"MEopMode/CregRoam\",(\"0\",\"1\")\r\n" - "^SCFG: \"MEopMode/Dormancy\",(\"0\",\"1\",\"9\")\r\n" - "^SCFG: \"MEopMode/DTM/Mode\",(\"0\",\"1\",\"2\")\r\n" - "^SCFG: \"MEopMode/ExpectDTR\",(\"current\",\"powerup\"),(\"acm0\",\"acm1\",\"acm2\",\"acm3\",\"diag\",\"mbim\",\"asc0\")\r\n" - "^SCFG: \"MEopMode/FGI/Split\",(\"0\",\"1\")\r\n" - "^SCFG: \"MEopMode/IMS\",(\"0\",\"1\")\r\n" - "^SCFG: \"MEopMode/NonBlock/Cops\",(\"0\",\"1\")\r\n" - "^SCFG: \"MEopMode/PowerMgmt/LCI\",(\"disabled\",\"enabled\"),(\"GPIO1\",\"GPIO3\",\"GPIO4\",\"GPIO5\",\"GPIO6\",\"GPIO7\",\"GPIO8\",\"GPIO11\",\"GPIO12\",\"GPIO13\",\"GPIO14\",\"GPIO15\",\"GPIO16\",\"GPIO17\",\"GPIO22\")\r\n" - "^SCFG: \"MEopMode/Prov/AutoFallback\",(\"on\",\"off\")\r\n" - "^SCFG: \"MEopMode/Prov/AutoSelect\",(\"on\",\"off\")\r\n" - "^SCFG: \"MEopMode/Prov/Cfg\",(\"vdfde\",\"tmode\",\"clarobr\",\"telenorno\",\"telenorse\",\"vdfpt\",\"fallb3gpp*\",\"vdfww\",\"vdfes\",\"swisscomch\",\"eeuk\",\"orangero\",\"orangees\",\"tefde\",\"telenordk\",\"timit\",\"tn1de\",\"tefes\",\"tels)\r\n" - "^SCFG: \"MEopMode/PwrSave\",(\"disabled\",\"enabled\"),(\"0-36000\"),(\"0-36000\"),(\"CPU-A\",\"CPU-M\"),(\"powerup\",\"current\")\r\n" - "^SCFG: \"MEopMode/SRPOM\",(\"0\",\"1\")\r\n" - "^SCFG: \"MEopMode/USB/KeepData\",(\"current\",\"powerup\"),(\"acm0\",\"acm1\",\"acm2\",\"acm3\",\"diag\",\"mbim\",\"asc0\")\r\n" - "^SCFG: \"MEShutdown/OnIgnition\",(\"on\",\"off\")\r\n" - "^SCFG: \"MEShutdown/Timer\",(\"off\",\"0\"-\"525600\")\r\n" - "^SCFG: \"Misc/CId\",(290)\r\n" - "^SCFG: \"Radio/Band/2G\",(\"00000001-0000000f\"),,(\"0\",\"1\")\r\n" - "^SCFG: \"Radio/Band/3G\",(\"00000001-000400b5\"),,(\"0\",\"1\")\r\n" - "^SCFG: \"Radio/Band/4G\",(\"00000001-8a0e00d5\"),(\"00000002-000001e2\"),(\"0\",\"1\")\r\n" - "^SCFG: \"Radio/CNS\",(\"0\",\"1\")\r\n" - "^SCFG: \"Radio/Mtpl\",(\"0-1\"),(\"1-8\")\r\n" - "^SCFG: \"Radio/Mtpl/2G\",(\"2-3\"),(\"1-8\"),(\"00000001-0000000f\"),,(\"18-33\"),(\"18-27\")\r\n" - "^SCFG: \"Radio/Mtpl/3G\",(\"2-3\"),(\"1-8\"),(\"00000001-000000b5\"),,(\"18-24\")\r\n" - "^SCFG: \"Radio/Mtpl/4G\",(\"2-3\"),(\"1-8\"),(\"00000001-8a0e00d5\"),(\"00000002-000000e2\"),(\"18-24\")\r\n" - "^SCFG: \"Radio/OutputPowerReduction\",(\"4\"-\"8\")\r\n" - "^SCFG: \"RemoteWakeUp/Event/ASC\",(\"none\",\"GPIO1\",\"GPIO3\",\"GPIO4\",\"GPIO5\",\"GPIO6\",\"GPIO7\",\"GPIO8\",\"GPIO11\",\"GPIO12\",\"GPIO13\",\"GPIO14\",\"GPIO15\",\"GPIO16\",\"GPIO17\",\"GPIO22\")\r\n" - "^SCFG: \"RemoteWakeUp/Event/URC\",(\"none\",\"GPIO1\",\"GPIO3\",\"GPIO4\",\"GPIO5\",\"GPIO6\",\"GPIO7\",\"GPIO8\",\"GPIO11\",\"GPIO12\",\"GPIO13\",\"GPIO14\",\"GPIO15\",\"GPIO16\",\"GPIO17\",\"GPIO22\")\r\n" - "^SCFG: \"RemoteWakeUp/Event/USB\",(\"none\",\"GPIO1\",\"GPIO3\",\"GPIO4\",\"GPIO5\",\"GPIO6\",\"GPIO7\",\"GPIO8\",\"GPIO11\",\"GPIO12\",\"GPIO13\",\"GPIO14\",\"GPIO15\",\"GPIO16\",\"GPIO17\",\"GPIO22\")\r\n" - "^SCFG: \"RemoteWakeUp/Ports\",(\"current\",\"powerup\"),(\"acm0\",\"acm1\",\"acm2\",\"acm3\",\"diag\",\"mbim\",\"asc0\")\r\n" - "^SCFG: \"RemoteWakeUp/Pulse\",(\"1\"-\"100\")\r\n" - "^SCFG: \"Serial/USB/DDD\",(\"0-1\"),(\"0\"),(\"0001-ffff\"),(\"0000-ffff\"),(\"0000-ffff\"),(63),(63),(4)\r\n" - "^SCFG: \"SIM/CS\",(\"NOSIM\",\"SIM1\",\"SIM2\")\r\n" - "^SCFG: \"SMS/4GPREF\",(\"IMS\",\"CSPS\")\r\n" - "^SCFG: \"SMS/AutoAck\",(\"0\",\"1\")\r\n" - "^SCFG: \"SMS/RETRM\",(\"1-45\")\r\n" - "^SCFG: \"URC/Ringline\",(\"off\",\"local\",\"asc0\")\r\n" - "^SCFG: \"URC/Ringline/ActiveTime\",(\"2\",\"on\",\"off\")\r\n"; - - expected_bands = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 23); - single = MM_MODEM_BAND_EGSM, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_DCS, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_PCS, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_G850, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_1, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_3, g_array_append_val (expected_bands, single); // - single = MM_MODEM_BAND_UTRAN_5, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_6, g_array_append_val (expected_bands, single); // - single = MM_MODEM_BAND_UTRAN_8, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_19, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_1, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_3, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_5, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_7, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_8, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_18, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_19, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_20, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_26, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_28, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_38, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_39, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_40, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_41, g_array_append_val (expected_bands, single); - - common_test_scfg (response, expected_bands, MM_MODEM_CHARSET_GSM, MM_CINTERION_MODEM_FAMILY_DEFAULT); + common_test_scfg (response, expected_bands); g_array_unref (expected_bands); } @@ -459,9 +190,7 @@ test_scfg_alas5 (void) static void common_test_scfg_response (const gchar *response, MMModemCharset charset, - GArray *expected_bands, - MMCinterionModemFamily modem_family, - MMCinterionRadioBandFormat rbf) + GArray *expected_bands) { GArray *bands = NULL; gchar *expected_bands_str; @@ -469,7 +198,7 @@ common_test_scfg_response (const gchar *response, GError *error = NULL; gboolean res; - res = mm_cinterion_parse_scfg_response (response, modem_family, charset, &bands, rbf, &error); + res = mm_cinterion_parse_scfg_response (response, charset, &bands, &error); g_assert_no_error (error); g_assert (res == TRUE); g_assert (bands != NULL); @@ -504,7 +233,7 @@ test_scfg_response_2g (void) single = MM_MODEM_BAND_EGSM, g_array_append_val (expected_bands, single); single = MM_MODEM_BAND_DCS, g_array_append_val (expected_bands, single); - common_test_scfg_response (response, MM_MODEM_CHARSET_UNKNOWN, expected_bands, MM_CINTERION_MODEM_FAMILY_DEFAULT, MM_CINTERION_RADIO_BAND_FORMAT_SINGLE); + common_test_scfg_response (response, MM_MODEM_CHARSET_UNKNOWN, expected_bands); g_array_unref (expected_bands); } @@ -521,7 +250,7 @@ test_scfg_response_2g_ucs2 (void) expected_bands = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 9); single = MM_MODEM_BAND_EGSM, g_array_append_val (expected_bands, single); - common_test_scfg_response (response, MM_MODEM_CHARSET_UCS2, expected_bands, MM_CINTERION_MODEM_FAMILY_DEFAULT, MM_CINTERION_RADIO_BAND_FORMAT_SINGLE); + common_test_scfg_response (response, MM_MODEM_CHARSET_UCS2, expected_bands); g_array_unref (expected_bands); } @@ -544,252 +273,7 @@ test_scfg_response_3g (void) single = MM_MODEM_BAND_UTRAN_2, g_array_append_val (expected_bands, single); single = MM_MODEM_BAND_UTRAN_5, g_array_append_val (expected_bands, single); - common_test_scfg_response (response, MM_MODEM_CHARSET_UNKNOWN, expected_bands, MM_CINTERION_MODEM_FAMILY_DEFAULT, MM_CINTERION_RADIO_BAND_FORMAT_SINGLE); - - g_array_unref (expected_bands); -} - -static void -test_scfg_response_pls62_gsm (void) -{ - GArray *expected_bands; - MMModemBand single; - const gchar *response = - "^SCFG: \"MEopMode/Prov/AutoSelect\",\"off\"\r\n" - "^SCFG: \"MEopMode/Prov/Cfg\",\"attus\"\r\n" - "^SCFG: \"Serial/Ifc\",\"0\"\r\n" - "^SCFG: \"RemoteWakeUp/Ports\",\"current\"\r\n" - "^SCFG: \"RemoteWakeUp/Ports\",\"powerup\"\r\n" - "^SCFG: \"Gpio/mode/ASC1\",\"gpio\"\r\n" - "^SCFG: \"Gpio/mode/DCD0\",\"gpio\"\r\n" - "^SCFG: \"Gpio/mode/DSR0\",\"gpio\"\r\n" - "^SCFG: \"Gpio/mode/DTR0\",\"gpio\"\r\n" - "^SCFG: \"Gpio/mode/FSR\",\"gpio\"\r\n" - "^SCFG: \"Gpio/mode/PULSE\",\"gpio\"\r\n" - "^SCFG: \"Gpio/mode/PWM\",\"gpio\"\r\n" - "^SCFG: \"Gpio/mode/HWAKEUP\",\"gpio\"\r\n" - "^SCFG: \"Gpio/mode/RING0\",\"gpio\"\r\n" - "^SCFG: \"Gpio/mode/SPI\",\"gpio\"\r\n" - "^SCFG: \"Gpio/mode/SYNC\",\"gpio\"\r\n" - "^SCFG: \"GPRS/AutoAttach\",\"enabled\"\r\n" - "^SCFG: \"Ident/Manufacturer\",\"Cinterion\"\r\n" - "^SCFG: \"Ident/Product\",\"PLS62-W\"\r\n" - "^SCFG: \"MEopMode/SoR\",\"off\"\r\n" - "^SCFG: \"MEopMode/CregRoam\",\"0\"\r\n" - "^SCFG: \"MeOpMode/SRPOM\",\"0\"\r\n" - "^SCFG: \"MEopMode/RingOnData\",\"off\"\r\n" - "^SCFG: \"MEShutdown/Fso\",\"0\"\r\n" - "^SCFG: \"MEShutdown/sVsup/threshold\",\"0\",\"0\"\r\n" - "^SCFG: \"Radio/Band/2G\",\"0x00000014\"\r\n" - "^SCFG: \"Radio/Band/3G\",\"0x00000182\"\r\n" - "^SCFG: \"Radio/Band/4G\",\"0x080E0000\"\r\n" - "^SCFG: \"Radio/Mtpl/2G\",\"0\"\r\n" - "^SCFG: \"Radio/Mtpl/3G\",\"0\"\r\n" - "^SCFG: \"Radio/Mtpl/4G\",\"0\"\r\n" - "^SCFG: \"Radio/OutputPowerReduction\",\"4\"\r\n" - "^SCFG: \"Serial/Interface/Allocation\",\"0\",\"0\"\r\n" - "^SCFG: \"Serial/USB/DDD\",\"0\",\"0\",\"0409\",\"1E2D\",\"005B\",\"Cinterion Wireless Modules\",\"PLSx\",\"\"\r\n" - "^SCFG: \"Tcp/IRT\",\"3\"\r\n" - "^SCFG: \"Tcp/MR\",\"10\"\r\n" - "^SCFG: \"Tcp/OT\",\"6000\"\r\n" - "^SCFG: \"Tcp/WithURCs\",\"on\"\r\n" - "^SCFG: \"Trace/Syslog/OTAP\",\"0\"\r\n" - "^SCFG: \"Urc/Ringline\",\"local\"\r\n" - "^SCFG: \"Urc/Ringline/ActiveTime\",\"2\"\r\n" - "^SCFG: \"Userware/Autostart\",\"0\"\r\n" - "^SCFG: \"Userware/Autostart/Delay\",\"0\"\r\n" - "^SCFG: \"Userware/DebugInterface\",\"0.0.0.0\",\"0.0.0.0\",\"0\"\r\n" - "^SCFG: \"Userware/DebugMode\",\"off\"\r\n" - "^SCFG: \"Userware/Passwd\",\r\n" - "^SCFG: \"Userware/Stdout\",\"null\",,,,\"off\"\r\n" - "^SCFG: \"Userware/Watchdog\",\"0\"\r\n" - "^SCFG: \"MEopMode/ExpectDTR\",\"current\"\r\n" - "^SCFG: \"MEopMode/ExpectDTR\",\"powerup\"\r\n"; - - expected_bands = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 9); - single = MM_MODEM_BAND_EGSM, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_DCS, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_2, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_8, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_9, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_18, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_19, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_20, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_28, g_array_append_val (expected_bands, single); - - common_test_scfg_response (response, MM_MODEM_CHARSET_GSM, expected_bands, MM_CINTERION_MODEM_FAMILY_IMT, MM_CINTERION_RADIO_BAND_FORMAT_MULTIPLE); - - g_array_unref (expected_bands); -} - -static void -test_scfg_response_pls62_ucs2 (void) -{ - GArray *expected_bands; - MMModemBand single; - const gchar *response = - "^SCFG: \"MEopMode/Prov/AutoSelect\",\"006F00660066\"\r\n" - "^SCFG: \"MEopMode/Prov/Cfg\",\"00610074007400750073\"\r\n" - "^SCFG: \"Serial/Ifc\",\"0\"\r\n" - "^SCFG: \"RemoteWakeUp/Ports\",\"00630075007200720065006E0074\"\r\n" - "^SCFG: \"RemoteWakeUp/Ports\",\"0070006F00770065007200750070\"\r\n" - "^SCFG: \"Gpio/mode/ASC1\",\"006700700069006F\"\r\n" - "^SCFG: \"Gpio/mode/DCD0\",\"006700700069006F\"\r\n" - "^SCFG: \"Gpio/mode/DSR0\",\"006700700069006F\"\r\n" - "^SCFG: \"Gpio/mode/DTR0\",\"006700700069006F\"\r\n" - "^SCFG: \"Gpio/mode/FSR\",\"006700700069006F\"\r\n" - "^SCFG: \"Gpio/mode/PULSE\",\"006700700069006F\"\r\n" - "^SCFG: \"Gpio/mode/PWM\",\"006700700069006F\"\r\n" - "^SCFG: \"Gpio/mode/HWAKEUP\",\"006700700069006F\"\r\n" - "^SCFG: \"Gpio/mode/RING0\",\"006700700069006F\"\r\n" - "^SCFG: \"Gpio/mode/SPI\",\"006700700069006F\"\r\n" - "^SCFG: \"Gpio/mode/SYNC\",\"006700700069006F\"\r\n" - "^SCFG: \"GPRS/AutoAttach\",\"0065006E00610062006C00650064\"\r\n" - "^SCFG: \"Ident/Manufacturer\",\"Cinterion\"\r\n" - "^SCFG: \"Ident/Product\",\"PLS62-W\"\r\n" - "^SCFG: \"MEopMode/SoR\",\"006F00660066\"\r\n" - "^SCFG: \"MEopMode/CregRoam\",\"0030\"\r\n" - "^SCFG: \"MeOpMode/SRPOM\",\"0030\"\r\n" - "^SCFG: \"MEopMode/RingOnData\",\"006F00660066\"\r\n" - "^SCFG: \"MEShutdown/Fso\",\"0030\"\r\n" - "^SCFG: \"MEShutdown/sVsup/threshold\",\"0030\",\"0030\"\r\n" - "^SCFG: \"Radio/Band/2G\",\"0030007800300030003000300030003000310034\"\r\n" - "^SCFG: \"Radio/Band/3G\",\"0030007800300030003000300030003100380032\"\r\n" - "^SCFG: \"Radio/Band/4G\",\"0030007800300038003000450030003000300030\"\r\n" - "^SCFG: \"Radio/Mtpl/2G\",\"0030\"\r\n" - "^SCFG: \"Radio/Mtpl/3G\",\"0030\"\r\n" - "^SCFG: \"Radio/Mtpl/4G\",\"0030\"\r\n" - "^SCFG: \"Radio/OutputPowerReduction\",\"0034\"\r\n" - "^SCFG: \"Serial/Interface/Allocation\",\"0030\",\"0030\"\r\n" - "^SCFG: \"Serial/USB/DDD\",\"0030\",\"0030\",\"0030003400300039\",\"0031004500320044\",\"0030003000350042\",\"00430069006E0074006500720069006F006E00200057006900720065006C0065007300730020004D006F00640075006C00650073\",\"005\"\r\n" - "^SCFG: \"Tcp/IRT\",\"0033\"\r\n" - "^SCFG: \"Tcp/MR\",\"00310030\"\r\n" - "^SCFG: \"Tcp/OT\",\"0036003000300030\"\r\n" - "^SCFG: \"Tcp/WithURCs\",\"006F006E\"\r\n" - "^SCFG: \"Trace/Syslog/OTAP\",\"0030\"\r\n" - "^SCFG: \"Urc/Ringline\",\"006C006F00630061006C\"\r\n" - "^SCFG: \"Urc/Ringline/ActiveTime\",\"0032\"\r\n" - "^SCFG: \"Userware/Autostart\",\"0030\"\r\n" - "^SCFG: \"Userware/Autostart/Delay\",\"0030\"\r\n" - "^SCFG: \"Userware/DebugInterface\",\"0030002E0030002E0030002E0030\",\"0030002E0030002E0030002E0030\",\"0030\"\r\n" - "^SCFG: \"Userware/DebugMode\",\"006F00660066\"\r\n" - "^SCFG: \"Userware/Passwd\",\r\n" - "^SCFG: \"Userware/Stdout\",\"006E0075006C006C\",,,,\"006F00660066\"\r\n" - "^SCFG: \"Userware/Watchdog\",\"0030\"\r\n" - "^SCFG: \"MEopMode/ExpectDTR\",\"00630075007200720065006E0074\"\r\n" - "^SCFG: \"MEopMode/ExpectDTR\",\"0070006F00770065007200750070\"\r\n"; - - expected_bands = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 9); - single = MM_MODEM_BAND_EGSM, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_DCS, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_2, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_8, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_9, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_18, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_19, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_20, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_28, g_array_append_val (expected_bands, single); - - common_test_scfg_response (response, MM_MODEM_CHARSET_UCS2, expected_bands, MM_CINTERION_MODEM_FAMILY_IMT, MM_CINTERION_RADIO_BAND_FORMAT_MULTIPLE); - - g_array_unref (expected_bands); -} - -static void -test_scfg_response_alas5 (void) -{ - GArray *expected_bands; - MMModemBand single; - const gchar *response = - "^SCFG: \"Audio/Loop\",\"0\"\r\n" - "^SCFG: \"Audio/SvTone\",\"0\"\r\n" - "^SCFG: \"Call/Ecall/AckTimeout\",\"5000\"\r\n" - "^SCFG: \"Call/Ecall/BlockSMSPP\",\"0\"\r\n" - "^SCFG: \"Call/Ecall/Callback\",\"0\"\r\n" - "^SCFG: \"Call/Ecall/CallbackTimeout\",\"43200000\"\r\n" - "^SCFG: \"Call/Ecall/Force\",\"1\"\r\n" - "^SCFG: \"Call/Ecall/Msd\",\"\"\r\n" - "^SCFG: \"Call/Ecall/Pullmode\",\"0\"\r\n" - "^SCFG: \"Call/Ecall/SessionTimeout\",\"20000\"\r\n" - "^SCFG: \"Call/Ecall/StartTimeout\",\"5000\"\r\n" - "^SCFG: \"Call/ECC\",\"0\"\r\n" - "^SCFG: \"Call/Speech/Codec\",\"0\"\r\n" - "^SCFG: \"GPRS/Auth\",\"2\"\r\n" - "^SCFG: \"GPRS/AutoAttach\",\"enabled\"\r\n" - "^SCFG: \"GPRS/MTU/Mode\",\"0\"\r\n" - "^SCFG: \"GPRS/MTU/Size\",1500\r\n" - "^SCFG: \"MEopMode/CFUN\",\"1\",\"1\"\r\n" - "^SCFG: \"MEopMode/CregRoam\",\"0\"\r\n" - "^SCFG: \"MEopMode/Dormancy\",\"0\",\"0\"\r\n" - "^SCFG: \"MEopMode/DTM/Mode\",\"2\"\r\n" - "^SCFG: \"MEopMode/ExpectDTR\",\"current\",\"acm0\",\"acm1\",\"acm2\",\"acm3\",\"mbim\",\"asc0\"\r\n" - "^SCFG: \"MEopMode/ExpectDTR\",\"powerup\",\"acm0\",\"acm1\",\"acm2\",\"acm3\",\"mbim\",\"asc0\"\r\n" - "^SCFG: \"MEopMode/FGI/Split\",\"1\"\r\n" - "^SCFG: \"MEopMode/IMS\",\"1\"\r\n" - "^SCFG: \"MEopMode/NonBlock/Cops\",\"0\"\r\n" - "^SCFG: \"MEopMode/PowerMgmt/LCI\",\"disabled\"\r\n" - "^SCFG: \"MEopMode/Prov/AutoFallback\",\"off\"\r\n" - "^SCFG: \"MEopMode/Prov/AutoSelect\",\"on\"\r\n" - "^SCFG: \"MEopMode/Prov/Cfg\",\"vdfde\"\r\n" - "^SCFG: \"MEopMode/PwrSave\",\"enabled\",\"52\",\"50\",\"CPU-A\",\"powerup\"\r\n" - "^SCFG: \"MEopMode/PwrSave\",\"enabled\",\"52\",\"50\",\"CPU-A\",\"current\"\r\n" - "^SCFG: \"MEopMode/PwrSave\",\"enabled\",\"0\",\"0\",\"CPU-M\",\"powerup\"\r\n" - "^SCFG: \"MEopMode/PwrSave\",\"enabled\",\"0\",\"0\",\"CPU-M\",\"current\"\r\n" - "^SCFG: \"MEopMode/SRPOM\",\"0\"\r\n" - "^SCFG: \"MEopMode/USB/KeepData\",\"current\",\"acm0\",\"acm1\",\"acm2\",\"acm3\",\"diag\",\"mbim\",\"asc0\"\r\n" - "^SCFG: \"MEopMode/USB/KeepData\",\"powerup\",\"acm0\",\"acm1\",\"acm2\",\"acm3\",\"diag\",\"mbim\",\"asc0\"\r\n" - "^SCFG: \"MEShutdown/OnIgnition\",\"off\"\r\n" - "^SCFG: \"MEShutdown/Timer\",\"off\"\r\n" - "^SCFG: \"Misc/CId\",\"\"\r\n" - "^SCFG: \"Radio/Band/2G\",\"0000000f\"\r\n" - "^SCFG: \"Radio/Band/3G\",\"000400b5\"\r\n" - "^SCFG: \"Radio/Band/4G\",\"8a0e00d5\",\"000000e2\"\r\n" - "^SCFG: \"Radio/CNS\",\"0\"\r\n" - "^SCFG: \"Radio/Mtpl\",\"0\"\r\n" - "^SCFG: \"Radio/Mtpl/2G\",\"0\"\r\n" - "^SCFG: \"Radio/Mtpl/3G\",\"0\"\r\n" - "^SCFG: \"Radio/Mtpl/4G\",\"0\"\r\n" - "^SCFG: \"Radio/OutputPowerReduction\",\"4\"\r\n" - "^SCFG: \"RemoteWakeUp/Event/ASC\",\"none\"\r\n" - "^SCFG: \"RemoteWakeUp/Event/URC\",\"none\"\r\n" - "^SCFG: \"RemoteWakeUp/Event/USB\",\"GPIO4\"\r\n" - "^SCFG: \"RemoteWakeUp/Ports\",\"current\",\"acm0\",\"acm1\",\"acm2\",\"acm3\",\"diag\",\"mbim\",\"asc0\"\r\n" - "^SCFG: \"RemoteWakeUp/Ports\",\"powerup\",\"acm0\",\"acm1\",\"acm2\",\"acm3\",\"diag\",\"mbim\",\"asc0\"\r\n" - "^SCFG: \"RemoteWakeUp/Pulse\",\"10\"\r\n" - "^SCFG: \"Serial/USB/DDD\",\"0\",\"0\",\"0409\",\"1e2d\",\"0065\",\"Cinterion\",\"LTE Modem\",\"8d8f\"\r\n" - "^SCFG: \"SIM/CS\",\"SIM1\"\r\n" - "^SCFG: \"SMS/4GPREF\",\"IMS\"\r\n" - "^SCFG: \"SMS/AutoAck\",\"0\"\r\n" - "^SCFG: \"SMS/RETRM\",\"30\"\r\n" - "^SCFG: \"URC/Ringline\",\"local\"\r\n" - "^SCFG: \"URC/Ringline/ActiveTime\",\"2\"\r\n"; - - expected_bands = g_array_sized_new (FALSE, FALSE, sizeof (MMModemBand), 25); - single = MM_MODEM_BAND_EGSM, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_DCS, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_PCS, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_G850, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_1, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_3, g_array_append_val (expected_bands, single); // - single = MM_MODEM_BAND_UTRAN_5, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_6, g_array_append_val (expected_bands, single); // - single = MM_MODEM_BAND_UTRAN_8, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_UTRAN_19, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_1, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_3, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_5, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_7, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_8, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_18, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_19, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_20, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_26, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_28, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_38, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_39, g_array_append_val (expected_bands, single); - single = MM_MODEM_BAND_EUTRAN_40, g_array_append_val (expected_bands, single); - - common_test_scfg_response (response, MM_MODEM_CHARSET_GSM, expected_bands, MM_CINTERION_MODEM_FAMILY_DEFAULT, MM_CINTERION_RADIO_BAND_FORMAT_MULTIPLE); + common_test_scfg_response (response, MM_MODEM_CHARSET_UNKNOWN, expected_bands); g_array_unref (expected_bands); } @@ -1381,7 +865,7 @@ test_ctzu_urc_full (void) typedef struct { const gchar *str; - MMCinterionRadioGen tech; + MMCinterionSmoniTech tech; gdouble rssi; gdouble ecn0; gdouble rscp; @@ -1392,7 +876,7 @@ typedef struct { static const SMoniResponseTest smoni_response_tests[] = { { .str = "^SMONI: 2G,71,-61,262,02,0143,83BA,33,33,3,6,G,NOCONN", - .tech = MM_CINTERION_RADIO_GEN_2G, + .tech = MM_CINTERION_SMONI_2G, .rssi = -61.0, .ecn0 = 0.0, .rscp = 0.0, @@ -1401,7 +885,7 @@ static const SMoniResponseTest smoni_response_tests[] = { }, { .str = "^SMONI: 2G,SEARCH,SEARCH", - .tech = MM_CINTERION_RADIO_GEN_NONE, + .tech = MM_CINTERION_SMONI_NO_TECH, .rssi = 0.0, .ecn0 = 0.0, .rscp = 0.0, @@ -1410,7 +894,7 @@ static const SMoniResponseTest smoni_response_tests[] = { }, { .str = "^SMONI: 2G,673,-89,262,07,4EED,A500,16,16,7,4,G,5,-107,LIMSRV", - .tech = MM_CINTERION_RADIO_GEN_2G, + .tech = MM_CINTERION_SMONI_2G, .rssi = -89.0, .ecn0 = 0.0, .rscp = 0.0, @@ -1419,7 +903,7 @@ static const SMoniResponseTest smoni_response_tests[] = { }, { .str = "^SMONI: 2G,673,-80,262,07,4EED,A500,35,35,7,4,G,643,4,0,-80,0,S_FR", - .tech = MM_CINTERION_RADIO_GEN_2G, + .tech = MM_CINTERION_SMONI_2G, .rssi = -80.0, .ecn0 = 0.0, .rscp = 0.0, @@ -1428,7 +912,7 @@ static const SMoniResponseTest smoni_response_tests[] = { }, { .str = "^SMONI: 3G,10564,296,-7.5,-79,262,02,0143,00228FF,-92,-78,NOCONN", - .tech = MM_CINTERION_RADIO_GEN_3G, + .tech = MM_CINTERION_SMONI_3G, .rssi = 0.0, .ecn0 = -7.5, .rscp = -79.0, @@ -1437,7 +921,7 @@ static const SMoniResponseTest smoni_response_tests[] = { }, { .str = "^SMONI: 3G,SEARCH,SEARCH", - .tech = MM_CINTERION_RADIO_GEN_NONE, + .tech = MM_CINTERION_SMONI_NO_TECH, .rssi = 0.0, .ecn0 = 0, .rscp = 0, @@ -1446,7 +930,7 @@ static const SMoniResponseTest smoni_response_tests[] = { }, { .str = "^SMONI: 3G,10564,96,-6.5,-77,262,02,0143,00228FF,-92,-78,LIMSRV", - .tech = MM_CINTERION_RADIO_GEN_3G, + .tech = MM_CINTERION_SMONI_3G, .rssi = 0.0, .ecn0 = -6.5, .rscp = -77.0, @@ -1455,7 +939,7 @@ static const SMoniResponseTest smoni_response_tests[] = { }, { .str = "^SMONI: 3G,10737,131,-5,-93,260,01,7D3D,C80BC9A,--,--,----,---,-,-5,-93,0,01,06", - .tech = MM_CINTERION_RADIO_GEN_3G, + .tech = MM_CINTERION_SMONI_3G, .rssi = 0.0, .ecn0 = -5.0, .rscp = -93.0, @@ -1464,7 +948,7 @@ static const SMoniResponseTest smoni_response_tests[] = { }, { .str = "^SMONI: 4G,6300,20,10,10,FDD,262,02,BF75,0345103,350,33,-94,-7,NOCONN", - .tech = MM_CINTERION_RADIO_GEN_4G, + .tech = MM_CINTERION_SMONI_4G, .rssi = 0.0, .ecn0 = 0.0, .rscp = 0.0, @@ -1473,7 +957,7 @@ static const SMoniResponseTest smoni_response_tests[] = { }, { .str = "^SMONI: 4G,SEARCH", - .tech = MM_CINTERION_RADIO_GEN_NONE, + .tech = MM_CINTERION_SMONI_NO_TECH, .rssi = 0.0, .ecn0 = 0.0, .rscp = 0.0, @@ -1482,7 +966,7 @@ static const SMoniResponseTest smoni_response_tests[] = { }, { .str = "^SMONI: 4G,6300,20,10,10,FDD,262,02,BF75,0345103,350,33,-90,-6,LIMSRV", - .tech = MM_CINTERION_RADIO_GEN_4G, + .tech = MM_CINTERION_SMONI_4G, .rssi = 0.0, .ecn0 = 0.0, .rscp = 0.0, @@ -1491,7 +975,7 @@ static const SMoniResponseTest smoni_response_tests[] = { }, { .str = "^SMONI: 4G,6300,20,10,10,FDD,262,02,BF75,0345103,350,90,-101,-7,CONN", - .tech = MM_CINTERION_RADIO_GEN_4G, + .tech = MM_CINTERION_SMONI_4G, .rssi = 0.0, .ecn0 = 0.0, .rscp = 0.0, @@ -1500,7 +984,7 @@ static const SMoniResponseTest smoni_response_tests[] = { }, { .str = "^SMONI: 4G,2850,7,20,20,FDD,262,02,C096,027430F,275,11,-114,-9,NOCONN", - .tech = MM_CINTERION_RADIO_GEN_4G, + .tech = MM_CINTERION_SMONI_4G, .rssi = 0.0, .ecn0 = 0.0, .rscp = 0.0, @@ -1509,7 +993,7 @@ static const SMoniResponseTest smoni_response_tests[] = { }, { .str = "^SMONI: 4G,2850,7,20,20,FDD,262,02,C096,027430F,275,-,-113,-8,CONN", - .tech = MM_CINTERION_RADIO_GEN_4G, + .tech = MM_CINTERION_SMONI_4G, .rssi = 0.0, .ecn0 = 0.0, .rscp = 0.0, @@ -1526,7 +1010,7 @@ test_smoni_response (void) for (i = 0; i < G_N_ELEMENTS (smoni_response_tests); i++) { GError *error = NULL; gboolean success; - MMCinterionRadioGen tech = MM_CINTERION_RADIO_GEN_NONE; + MMCinterionSmoniTech tech = MM_CINTERION_SMONI_NO_TECH; gdouble rssi = MM_SIGNAL_UNKNOWN; gdouble ecn0 = MM_SIGNAL_UNKNOWN; gdouble rscp = MM_SIGNAL_UNKNOWN; @@ -1543,18 +1027,18 @@ test_smoni_response (void) g_assert_cmpuint (smoni_response_tests[i].tech, ==, tech); switch (smoni_response_tests[i].tech) { - case MM_CINTERION_RADIO_GEN_2G: + case MM_CINTERION_SMONI_2G: g_assert_cmpfloat_tolerance (rssi, smoni_response_tests[i].rssi, 0.1); break; - case MM_CINTERION_RADIO_GEN_3G: + case MM_CINTERION_SMONI_3G: g_assert_cmpfloat_tolerance (ecn0, smoni_response_tests[i].ecn0, 0.1); g_assert_cmpfloat_tolerance (rscp, smoni_response_tests[i].rscp, 0.1); break; - case MM_CINTERION_RADIO_GEN_4G: + case MM_CINTERION_SMONI_4G: g_assert_cmpfloat_tolerance (rsrp, smoni_response_tests[i].rsrp, 0.1); g_assert_cmpfloat_tolerance (rsrq, smoni_response_tests[i].rsrq, 0.1); break; - case MM_CINTERION_RADIO_GEN_NONE: + case MM_CINTERION_SMONI_NO_TECH: default: break; } @@ -1580,14 +1064,14 @@ test_smoni_response_to_signal (void) g_assert (success); switch (smoni_response_tests[i].tech) { - case MM_CINTERION_RADIO_GEN_2G: + case MM_CINTERION_SMONI_2G: g_assert (gsm); g_assert_cmpfloat_tolerance (mm_signal_get_rssi (gsm), smoni_response_tests[i].rssi, 0.1); g_object_unref (gsm); g_assert (!umts); g_assert (!lte); break; - case MM_CINTERION_RADIO_GEN_3G: + case MM_CINTERION_SMONI_3G: g_assert (umts); g_assert_cmpfloat_tolerance (mm_signal_get_rscp (umts), smoni_response_tests[i].rscp, 0.1); g_assert_cmpfloat_tolerance (mm_signal_get_ecio (umts), smoni_response_tests[i].ecn0, 0.1); @@ -1595,7 +1079,7 @@ test_smoni_response_to_signal (void) g_assert (!gsm); g_assert (!lte); break; - case MM_CINTERION_RADIO_GEN_4G: + case MM_CINTERION_SMONI_4G: g_assert (lte); g_assert_cmpfloat_tolerance (mm_signal_get_rsrp (lte), smoni_response_tests[i].rsrp, 0.1); g_assert_cmpfloat_tolerance (mm_signal_get_rsrq (lte), smoni_response_tests[i].rsrq, 0.1); @@ -1603,7 +1087,7 @@ test_smoni_response_to_signal (void) g_assert (!gsm); g_assert (!umts); break; - case MM_CINTERION_RADIO_GEN_NONE: + case MM_CINTERION_SMONI_NO_TECH: default: g_assert (!gsm); g_assert (!umts); @@ -1624,15 +1108,9 @@ int main (int argc, char **argv) g_test_add_func ("/MM/cinterion/scfg", test_scfg); g_test_add_func ("/MM/cinterion/scfg/ehs5", test_scfg_ehs5); - g_test_add_func ("/MM/cinterion/scfg/pls62/gsm", test_scfg_pls62_gsm); - g_test_add_func ("/MM/cinterion/scfg/pls62/ucs2", test_scfg_pls62_ucs2); - g_test_add_func ("/MM/cinterion/scfg/alas5", test_scfg_alas5); g_test_add_func ("/MM/cinterion/scfg/response/3g", test_scfg_response_3g); g_test_add_func ("/MM/cinterion/scfg/response/2g", test_scfg_response_2g); g_test_add_func ("/MM/cinterion/scfg/response/2g/ucs2", test_scfg_response_2g_ucs2); - g_test_add_func ("/MM/cinterion/scfg/response/pls62/gsm", test_scfg_response_pls62_gsm); - g_test_add_func ("/MM/cinterion/scfg/response/pls62/ucs2",test_scfg_response_pls62_ucs2); - g_test_add_func ("/MM/cinterion/scfg/response/alas5", test_scfg_response_alas5); g_test_add_func ("/MM/cinterion/cnmi/phs8", test_cnmi_phs8); g_test_add_func ("/MM/cinterion/cnmi/other", test_cnmi_other); g_test_add_func ("/MM/cinterion/swwan/pls8", test_swwan_pls8); diff --git a/src/mm-charsets.c b/src/mm-charsets.c index e48cec3e..bf0de2b2 100644 --- a/src/mm-charsets.c +++ b/src/mm-charsets.c @@ -458,8 +458,7 @@ mm_charset_gsm_unpacked_to_utf8 (const guint8 *gsm, guint32 len) g_byte_array_append (utf8, (guint8 *) "?", 1); } - /* Always make sure returned string is NUL terminated */ - g_byte_array_append (utf8, (guint8 *) "\0", 1); + g_byte_array_append (utf8, (guint8 *) "\0", 1); /* NULL terminator */ return g_byte_array_free (utf8, FALSE); } @@ -472,6 +471,7 @@ mm_charset_utf8_to_unpacked_gsm (const char *utf8, guint32 *out_len) int i = 0; g_return_val_if_fail (utf8 != NULL, NULL); + g_return_val_if_fail (out_len != NULL, NULL); g_return_val_if_fail (g_utf8_validate (utf8, -1, NULL), NULL); /* worst case initial length */ @@ -480,8 +480,7 @@ mm_charset_utf8_to_unpacked_gsm (const char *utf8, guint32 *out_len) if (*utf8 == 0x00) { /* Zero-length string */ g_byte_array_append (gsm, (guint8 *) "\0", 1); - if (out_len) - *out_len = 0; + *out_len = 0; return g_byte_array_free (gsm, FALSE); } @@ -502,12 +501,7 @@ mm_charset_utf8_to_unpacked_gsm (const char *utf8, guint32 *out_len) i++; } - /* Output length doesn't consider terminating NUL byte */ - if (out_len) - *out_len = gsm->len; - - /* Always make sure returned string is NUL terminated */ - g_byte_array_append (gsm, (guint8 *) "\0", 1); + *out_len = gsm->len; return g_byte_array_free (gsm, FALSE); } @@ -763,10 +757,6 @@ mm_charset_take_and_convert_to_utf8 (gchar *str, MMModemCharset charset) break; case MM_MODEM_CHARSET_GSM: - utf8 = (gchar *) mm_charset_gsm_unpacked_to_utf8 ((const guint8 *) str, strlen (str)); - g_free (str); - break; - case MM_MODEM_CHARSET_8859_1: case MM_MODEM_CHARSET_PCCP437: case MM_MODEM_CHARSET_PCDN: { @@ -887,14 +877,12 @@ mm_utf8_take_and_convert_to_charset (gchar *str, break; case MM_MODEM_CHARSET_HEX: + /* FIXME: What encoding is this? */ + g_warn_if_reached (); encoded = str; break; case MM_MODEM_CHARSET_GSM: - encoded = (gchar *) mm_charset_utf8_to_unpacked_gsm (str, NULL); - g_free (str); - break; - case MM_MODEM_CHARSET_8859_1: case MM_MODEM_CHARSET_PCCP437: case MM_MODEM_CHARSET_PCDN: { diff --git a/src/tests/test-charsets.c b/src/tests/test-charsets.c index 0931d7e8..5c9e1875 100644 --- a/src/tests/test-charsets.c +++ b/src/tests/test-charsets.c @@ -316,15 +316,13 @@ test_gsm7_pack_7_chars_offset (void) static void test_take_convert_ucs2_hex_utf8 (void) { - gchar *src, *converted, *utf8; + gchar *src, *converted; /* Ensure hex-encoded UCS-2 works */ src = g_strdup ("0054002d004d006f00620069006c0065"); converted = mm_charset_take_and_convert_to_utf8 (src, MM_MODEM_CHARSET_UCS2); g_assert_cmpstr (converted, ==, "T-Mobile"); - utf8 = mm_utf8_take_and_convert_to_charset (converted, MM_MODEM_CHARSET_UCS2); - g_assert_cmpstr (utf8, ==, "0054002D004D006F00620069006C0065"); - g_free (utf8); + g_free (converted); } static void @@ -350,19 +348,6 @@ test_take_convert_ucs2_bad_ascii2 (void) g_assert (converted == NULL); } -static void -test_take_convert_gsm_utf8 (void) -{ - gchar *src, *converted, *utf8; - - src = g_strdup ("T-Mobile"); - converted = mm_charset_take_and_convert_to_utf8 (src, MM_MODEM_CHARSET_GSM); - g_assert_cmpstr (converted, ==, "T-Mobile"); - utf8 = mm_utf8_take_and_convert_to_charset (converted, MM_MODEM_CHARSET_GSM); - g_assert_cmpstr (utf8, ==, "T-Mobile"); - g_free (utf8); -} - struct charset_can_convert_to_test_s { const char *utf8; gboolean to_gsm; @@ -445,7 +430,6 @@ int main (int argc, char **argv) g_test_add_func ("/MM/charsets/take-convert/ucs2/hex", test_take_convert_ucs2_hex_utf8); g_test_add_func ("/MM/charsets/take-convert/ucs2/bad-ascii", test_take_convert_ucs2_bad_ascii); g_test_add_func ("/MM/charsets/take-convert/ucs2/bad-ascii-2", test_take_convert_ucs2_bad_ascii2); - g_test_add_func ("/MM/charsets/take-convert/gsm", test_take_convert_gsm_utf8); g_test_add_func ("/MM/charsets/can-convert-to", test_charset_can_covert_to); |