aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/cinterion/mm-modem-helpers-cinterion.c
diff options
context:
space:
mode:
authorLukas Voegl <lvoegl@tdt.de>2024-11-04 12:55:54 +0100
committerAleksander Morgado <aleksander@aleksander.es>2024-11-20 12:07:20 +0000
commit68e725d45e55e842e9a9df9ef47a0fe3a8199f2b (patch)
treee1dd6b1df241b63aa209a59e6f1e3872e0771d22 /src/plugins/cinterion/mm-modem-helpers-cinterion.c
parent32435b430f9803f348db37e455b4db5298db1d8f (diff)
broadband-modem-cinterion: implement load_current_modes
Signed-off-by: Lukas Voegl <lvoegl@tdt.de>
Diffstat (limited to 'src/plugins/cinterion/mm-modem-helpers-cinterion.c')
-rw-r--r--src/plugins/cinterion/mm-modem-helpers-cinterion.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/plugins/cinterion/mm-modem-helpers-cinterion.c b/src/plugins/cinterion/mm-modem-helpers-cinterion.c
index 52b2baf8..b2ef89a9 100644
--- a/src/plugins/cinterion/mm-modem-helpers-cinterion.c
+++ b/src/plugins/cinterion/mm-modem-helpers-cinterion.c
@@ -1993,6 +1993,7 @@ mm_cinterion_build_cops_set_command (MMModemMode mode,
if (mode != MM_MODEM_MODE_ANY) {
/* append <RaT> */
if (!modem_mode_to_cops_uint (mode, &cops_mode, error)) {
+ g_string_free (command, TRUE);
return FALSE;
}
g_string_append_printf (command, ",%u", cops_mode);
@@ -2002,3 +2003,63 @@ mm_cinterion_build_cops_set_command (MMModemMode mode,
*out = g_string_free (command, FALSE);
return TRUE;
}
+
+gboolean
+mm_cinterion_parse_ws46_response (const gchar *response,
+ MMModemMode *result,
+ GError **error)
+{
+ g_autoptr(GRegex) r = NULL;
+ g_autoptr(GMatchInfo) match_info = NULL;
+ guint mode_num;
+
+ r = g_regex_new ("\\+WS46:\\s*(\\d+)",
+ G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
+ g_assert (r != NULL);
+
+ if (!g_regex_match (r, response, 0, &match_info)) {
+ g_set_error (error,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Failed to parse WS46 response '%s'",
+ response);
+ return FALSE;
+ }
+
+ if (!mm_get_uint_from_match_info (match_info, 1, &mode_num)) {
+ g_set_error (error,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Failed to get mode from WS46 response '%s'",
+ response);
+ return FALSE;
+ }
+
+ switch (mode_num) {
+ case 12:
+ /* GSM digital cellular (GERAN only) */
+ *result = MM_MODEM_MODE_2G;
+ break;
+ case 22:
+ /* UTRAN only */
+ *result = MM_MODEM_MODE_3G;
+ break;
+ case 25:
+ /* GERAN, UTRAN and E-UTRAN */
+ *result = MM_MODEM_MODE_ANY;
+ break;
+ case 28:
+ /* E-UTRAN only */
+ *result = MM_MODEM_MODE_4G;
+ break;
+ default:
+ g_set_error (error,
+ MM_CORE_ERROR,
+ MM_CORE_ERROR_FAILED,
+ "Unknown WS46 mode '%u'",
+ mode_num);
+ return FALSE;
+ }
+
+ return TRUE;
+}