diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2016-08-03 11:10:04 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2016-10-12 11:29:52 +0200 |
commit | 467b3c57f01b37dbcec8d32a449654aac40f90d0 (patch) | |
tree | 30d92cccb0e081e0f6f4c2335e4b3cf6bed3cda5 /plugins | |
parent | b117321980c39c2dcc50789058017fa3201e7003 (diff) |
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.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/altair/mm-broadband-modem-altair-lte.c | 26 | ||||
-rw-r--r-- | plugins/huawei/mm-broadband-modem-huawei.c | 12 |
2 files changed, 29 insertions, 9 deletions
diff --git a/plugins/altair/mm-broadband-modem-altair-lte.c b/plugins/altair/mm-broadband-modem-altair-lte.c index 53d516f8..1155a7a1 100644 --- a/plugins/altair/mm-broadband-modem-altair-lte.c +++ b/plugins/altair/mm-broadband-modem-altair-lte.c @@ -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; } diff --git a/plugins/huawei/mm-broadband-modem-huawei.c b/plugins/huawei/mm-broadband-modem-huawei.c index ac6964ae..607e14ee 100644 --- a/plugins/huawei/mm-broadband-modem-huawei.c +++ b/plugins/huawei/mm-broadband-modem-huawei.c @@ -2179,18 +2179,26 @@ 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; + if (!mm_3gpp_parse_cops_read_response (result, + NULL, /* mode */ + NULL, /* format */ + &operator_name, + NULL, /* act */ + error)) + return NULL; + /* Despite +CSCS? may claim supporting UCS2, Huawei modems always report the * operator name in ASCII in a +COPS response. Thus, we ignore the current * charset claimed by the modem and assume the charset is IRA when parsing * the operator name. */ - operator_name = mm_3gpp_parse_operator (result, MM_MODEM_CHARSET_IRA); + mm_3gpp_normalize_operator_name (&operator_name, MM_MODEM_CHARSET_IRA); if (operator_name) mm_dbg ("loaded Operator Name: %s", operator_name); |