broadband-modem: support 5G in +WS46 to capabilities conversion

This commit is contained in:
Aleksander Morgado
2020-04-09 12:38:50 +00:00
parent 5db3fa88e9
commit f912de3574
+25 -11
View File
@@ -501,6 +501,10 @@ current_capabilities_ws46_test_ready (MMBaseModem *self,
const gchar *response; const gchar *response;
GArray *modes; GArray *modes;
guint i; guint i;
gboolean is_2g = FALSE;
gboolean is_3g = FALSE;
gboolean is_4g = FALSE;
gboolean is_5g = FALSE;
ctx = g_task_get_task_data (task); ctx = g_task_get_task_data (task);
@@ -513,27 +517,37 @@ current_capabilities_ws46_test_ready (MMBaseModem *self,
if (!modes) if (!modes)
goto out; goto out;
/* Add LTE caps if any of the reported modes supports 4G */ /* Process list of modes to gather supported ones */
for (i = 0; i < modes->len; i++) { for (i = 0; i < modes->len; i++) {
if (g_array_index (modes, MMModemMode, i) & MM_MODEM_MODE_4G) { if (g_array_index (modes, MMModemMode, i) & MM_MODEM_MODE_2G)
ctx->caps |= MM_MODEM_CAPABILITY_LTE; is_2g = TRUE;
break; if (g_array_index (modes, MMModemMode, i) & MM_MODEM_MODE_3G)
} is_3g = TRUE;
if (g_array_index (modes, MMModemMode, i) & MM_MODEM_MODE_4G)
is_4g = TRUE;
if (g_array_index (modes, MMModemMode, i) & MM_MODEM_MODE_5G)
is_5g = TRUE;
} }
/* Add capabilities from modes */
if (is_2g || is_3g)
ctx->caps |= MM_MODEM_CAPABILITY_GSM_UMTS;
if (is_4g)
ctx->caps |= MM_MODEM_CAPABILITY_LTE;
if (is_5g)
ctx->caps |= MM_MODEM_CAPABILITY_5GNR;
/* The +CGSM capability is saying that the modem is a 3GPP modem, but that /* The +CGSM capability is saying that the modem is a 3GPP modem, but that
* doesn't necessarily mean it's a GSM/UMTS modem, it could be a LTE-only * doesn't necessarily mean it's a GSM/UMTS modem, it could be a LTE-only
* device. We did add the GSM_UMTS capability when +CGSM was found, so now * or 5GNR-only device. We did add the GSM_UMTS capability when +CGSM was
* we'll check if the device only reports 4G-only mode, and remove the * found, so now we'll check if the device only reports 4G or 5G modes, and
* capability if so. * remove the capability if so.
* *
* Note that we don't change the default +CGSM -> GSM/UMTS logic, we just * Note that we don't change the default +CGSM -> GSM/UMTS logic, we just
* fix it up. * fix it up.
*/ */
if ((modes->len == 1) && (g_array_index (modes, MMModemMode, 0) == MM_MODEM_MODE_4G)) { if ((is_4g || is_5g) && !is_2g && !is_3g)
g_assert (ctx->caps & MM_MODEM_CAPABILITY_LTE);
ctx->caps &= ~MM_MODEM_CAPABILITY_GSM_UMTS; ctx->caps &= ~MM_MODEM_CAPABILITY_GSM_UMTS;
}
g_array_unref (modes); g_array_unref (modes);