modem-helpers: new COPS? response parser

Split into two different actions the actual COPS? response parsing and the
operator name normalization process.

Also, allow parsing not only the operator string, but also the format, mode
and the optional access technology value.
This commit is contained in:
Aleksander Morgado
2016-08-03 11:10:04 +02:00
parent b117321980
commit 467b3c57f0
6 changed files with 243 additions and 64 deletions

View File

@@ -1065,16 +1065,21 @@ modem_3gpp_load_operator_code_finish (MMIfaceModem3gpp *self,
GError **error)
{
const gchar *result;
gchar *operator_code;
gchar *operator_code = NULL;
result = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, error);
if (!result)
return NULL;
operator_code = mm_3gpp_parse_operator (result, MM_MODEM_CHARSET_UNKNOWN);
if (operator_code)
mm_dbg ("loaded Operator Code: %s", operator_code);
if (!mm_3gpp_parse_cops_read_response (result,
NULL, /* mode */
NULL, /* format */
&operator_code,
NULL, /* act */
error))
return NULL;
mm_dbg ("loaded Operator Code: %s", operator_code);
return operator_code;
}
@@ -1109,16 +1114,23 @@ modem_3gpp_load_operator_name_finish (MMIfaceModem3gpp *self,
GError **error)
{
const gchar *result;
gchar *operator_name;
gchar *operator_name = NULL;
result = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, error);
if (!result)
return NULL;
operator_name = mm_3gpp_parse_operator (result, MM_MODEM_CHARSET_UNKNOWN);
if (!mm_3gpp_parse_cops_read_response (result,
NULL, /* mode */
NULL, /* format */
&operator_name,
NULL, /* act */
error))
return NULL;
mm_3gpp_normalize_operator_name (&operator_name, MM_MODEM_CHARSET_UNKNOWN);
if (operator_name)
mm_dbg ("loaded Operator Name: %s", operator_name);
return operator_name;
}