diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2017-12-28 18:41:51 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2018-01-20 15:41:07 +0100 |
commit | 22ffd3f3aa4d8c1fbc1f6ab765bcfaf83f3d1c7f (patch) | |
tree | e96e6ab4048fa77588e9e9f1e74fa2f14bd781fc /src/mm-modem-helpers.c | |
parent | d4aaa436d9679524f910b13176d4af35bd6b14f8 (diff) |
broadband-modem: implement support for the +CEMODE command
The +CEMODE command is defined in 3GPP TS 27.007 (e.g. in section
10.1.28 in v11.0.0). This command allows querying or updating the
current UE mode, as well as checking the supported modes.
We implement support for loading the current mode and updating it. It
is assumed that the device does any additional operation needed by the
setting update, e.g. un-registering from CS when selecting an EPS-only
mode.
Diffstat (limited to 'src/mm-modem-helpers.c')
-rw-r--r-- | src/mm-modem-helpers.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c index dce7e795..111cc38e 100644 --- a/src/mm-modem-helpers.c +++ b/src/mm-modem-helpers.c @@ -2485,6 +2485,51 @@ mm_3gpp_parse_cfun_query_generic_response (const gchar *response, } } +static MMModem3gppEpsUeModeOperation cemode_values[] = { + [0] = MM_MODEM_3GPP_EPS_UE_MODE_OPERATION_PS_2, + [1] = MM_MODEM_3GPP_EPS_UE_MODE_OPERATION_CSPS_1, + [2] = MM_MODEM_3GPP_EPS_UE_MODE_OPERATION_CSPS_2, + [3] = MM_MODEM_3GPP_EPS_UE_MODE_OPERATION_PS_1, +}; + +gchar * +mm_3gpp_build_cemode_set_request (MMModem3gppEpsUeModeOperation mode) +{ + guint i; + + g_return_val_if_fail (mode != MM_MODEM_3GPP_EPS_UE_MODE_OPERATION_UNKNOWN, NULL); + + for (i = 0; i < G_N_ELEMENTS (cemode_values); i++) { + if (mode == cemode_values[i]) + return g_strdup_printf ("+CEMODE=%u", i); + } + + g_assert_not_reached (); + return NULL; +} + +gboolean +mm_3gpp_parse_cemode_query_response (const gchar *response, + MMModem3gppEpsUeModeOperation *out_mode, + GError **error) +{ + guint value = 0; + + response = mm_strip_tag (response, "+CEMODE:"); + if (mm_get_uint_from_str (response, &value) && value < G_N_ELEMENTS (cemode_values)) { + if (out_mode) + *out_mode = cemode_values[value]; + return TRUE; + } + + g_set_error (error, + MM_CORE_ERROR, + MM_CORE_ERROR_FAILED, + "Couldn't parse UE mode of operation: '%s' (value %u)", + response, value); + return FALSE; +} + /*************************************************************************/ static MMSmsStorage |