modem-helpers: updated the string to access technology converter

We can now return a mask of flags specifying more than one access technology,
and therefore the order is not really important any more, unless for special
cases like looking for substrings of valid expected strings (e.g "HSPA" and
"HSPA+").

Also, add "LTE" in the list of expected strings.
This commit is contained in:
Aleksander Morgado
2012-02-19 10:49:36 +01:00
parent 4315208cfa
commit 1359c0a928
2 changed files with 33 additions and 24 deletions

View File

@@ -1350,34 +1350,43 @@ mm_gsm_parse_clck_response (const char *reply, gboolean *enabled)
/*************************************************************************/
MMModemGsmAccessTech
mm_gsm_string_to_access_tech (const char *string)
MMModemAccessTechnology
mm_3gpp_string_to_access_tech (const gchar *string)
{
g_return_val_if_fail (string != NULL, MM_MODEM_GSM_ACCESS_TECH_UNKNOWN);
MMModemAccessTechnology act = MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN;
g_return_val_if_fail (string != NULL, MM_MODEM_ACCESS_TECHNOLOGY_UNKNOWN);
/* We're returning a MASK of technologies found; so we can include more
* than one technology in the result */
if (strcasestr (string, "LTE"))
act |= MM_MODEM_ACCESS_TECHNOLOGY_LTE;
/* Better technologies are listed first since modems sometimes say
* stuff like "GPRS/EDGE" and that should be handled as EDGE.
*/
if (strcasestr (string, "HSPA+"))
return MM_MODEM_GSM_ACCESS_TECH_HSPA_PLUS;
act |= MM_MODEM_ACCESS_TECHNOLOGY_HSPA_PLUS;
else if (strcasestr (string, "HSPA"))
return MM_MODEM_GSM_ACCESS_TECH_HSPA;
else if (strcasestr (string, "HSDPA/HSUPA"))
return MM_MODEM_GSM_ACCESS_TECH_HSPA;
else if (strcasestr (string, "HSUPA"))
return MM_MODEM_GSM_ACCESS_TECH_HSUPA;
else if (strcasestr (string, "HSDPA"))
return MM_MODEM_GSM_ACCESS_TECH_HSDPA;
else if (strcasestr (string, "UMTS"))
return MM_MODEM_GSM_ACCESS_TECH_UMTS;
else if (strcasestr (string, "EDGE"))
return MM_MODEM_GSM_ACCESS_TECH_EDGE;
else if (strcasestr (string, "GPRS"))
return MM_MODEM_GSM_ACCESS_TECH_GPRS;
else if (strcasestr (string, "GSM"))
return MM_MODEM_GSM_ACCESS_TECH_GSM;
act |= MM_MODEM_ACCESS_TECHNOLOGY_HSPA;
return MM_MODEM_GSM_ACCESS_TECH_UNKNOWN;
if (strcasestr (string, "HSUPA"))
act |= MM_MODEM_ACCESS_TECHNOLOGY_HSUPA;
if (strcasestr (string, "HSDPA"))
act |= MM_MODEM_ACCESS_TECHNOLOGY_HSDPA;
if (strcasestr (string, "UMTS"))
act |= MM_MODEM_ACCESS_TECHNOLOGY_UMTS;
if (strcasestr (string, "EDGE"))
act |= MM_MODEM_ACCESS_TECHNOLOGY_EDGE;
if (strcasestr (string, "GPRS"))
act |= MM_MODEM_ACCESS_TECHNOLOGY_GPRS;
if (strcasestr (string, "GSM"))
act |= MM_MODEM_ACCESS_TECHNOLOGY_GSM;
return act;
}
/*************************************************************************/