aboutsummaryrefslogtreecommitdiff
path: root/src/mm-modem-helpers.c
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2020-03-23 10:42:39 +0100
committerAleksander Morgado <aleksander@aleksander.es>2020-04-09 12:38:50 +0000
commit44ace9642cd8a2a80c65655a6d543c69169b2a06 (patch)
tree4b0b7c27bbd42523a3cfa9d3d9447bcbfa483d6f /src/mm-modem-helpers.c
parentf31182c08d3801489510cb40cca11f82868d1989 (diff)
modem-helpers: improved +WS46 mode '25' handling
The mode '25' means different things on LTE-capable and non-LTE-capable devices, so improve the logic to clarify that.
Diffstat (limited to 'src/mm-modem-helpers.c')
-rw-r--r--src/mm-modem-helpers.c43
1 files changed, 32 insertions, 11 deletions
diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c
index 940ca40a..5ecbfe12 100644
--- a/src/mm-modem-helpers.c
+++ b/src/mm-modem-helpers.c
@@ -1039,7 +1039,9 @@ mm_3gpp_cds_regex_get (void)
* NOTE: ignore WS46 prefix or it will break Cinterion handling.
*
* For the specific case of '25', we will check if any other mode supports
- * 4G, and if there is none, we'll remove 4G caps from it.
+ * 4G, and if there is none, we'll remove 4G caps from it. This is needed
+ * because pre-LTE modems used '25' to report GERAN+URAN instead of the
+ * new '29' value since LTE modems are around.
*/
typedef struct {
@@ -1054,7 +1056,7 @@ static const Ws46Mode ws46_modes[] = {
/* UTRAN only */
{ 22, MM_MODEM_MODE_3G },
/* 3GPP Systems (GERAN, UTRAN and E-UTRAN) */
- { 25, MM_MODEM_MODE_2G | MM_MODEM_MODE_3G | MM_MODEM_MODE_4G },
+ { 25, MM_MODEM_MODE_ANY },
/* E-UTRAN only */
{ 28, MM_MODEM_MODE_4G },
/* GERAN and UTRAN */
@@ -1098,6 +1100,8 @@ mm_3gpp_parse_ws46_test_response (const gchar *response,
gboolean supported_4g = FALSE;
gboolean supported_3g = FALSE;
gboolean supported_2g = FALSE;
+ gboolean supported_mode_25 = FALSE;
+ gboolean supported_mode_29 = FALSE;
r = g_regex_new ("(?:\\+WS46:)?\\s*\\((.*)\\)(?:\\r\\n)?", 0, 0, NULL);
g_assert (r != NULL);
@@ -1126,15 +1130,21 @@ mm_3gpp_parse_ws46_test_response (const gchar *response,
for (j = 0; j < G_N_ELEMENTS (ws46_modes); j++) {
if (ws46_modes[j].ws46 == val) {
- if (ws46_modes[j].mode & MM_MODEM_MODE_5G)
- supported_5g = TRUE;
- if (ws46_modes[j].mode & MM_MODEM_MODE_4G)
- supported_4g = TRUE;
- if (ws46_modes[j].mode & MM_MODEM_MODE_3G)
- supported_3g = TRUE;
- if (ws46_modes[j].mode & MM_MODEM_MODE_2G)
- supported_2g = TRUE;
- g_array_append_val (modes, ws46_modes[j].mode);
+ if (val == 25)
+ supported_mode_25 = TRUE;
+ else {
+ if (val == 29)
+ supported_mode_29 = TRUE;
+ if (ws46_modes[j].mode & MM_MODEM_MODE_5G)
+ supported_5g = TRUE;
+ if (ws46_modes[j].mode & MM_MODEM_MODE_4G)
+ supported_4g = TRUE;
+ if (ws46_modes[j].mode & MM_MODEM_MODE_3G)
+ supported_3g = TRUE;
+ if (ws46_modes[j].mode & MM_MODEM_MODE_2G)
+ supported_2g = TRUE;
+ g_array_append_val (modes, ws46_modes[j].mode);
+ }
break;
}
}
@@ -1143,6 +1153,17 @@ mm_3gpp_parse_ws46_test_response (const gchar *response,
g_warning ("Unknown +WS46 mode reported: %u", val);
}
+ if (supported_mode_25) {
+ MMModemMode mode_25;
+
+ mode_25 = MM_MODEM_MODE_2G | MM_MODEM_MODE_3G;
+ if (supported_4g) {
+ mode_25 |= MM_MODEM_MODE_4G;
+ g_array_append_val (modes, mode_25);
+ } else if (!supported_mode_29)
+ g_array_append_val (modes, mode_25);
+ }
+
if (modes->len == 0) {
inner_error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "No valid modes reported");
g_clear_pointer (&modes, g_array_unref);