aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2021-11-28 22:40:26 +0100
committerAleksander Morgado <aleksander@aleksander.es>2021-12-24 12:41:27 +0000
commitdcf9bb4ee8c0a60fcaac0efcaa4ee8c24841ec5b (patch)
tree1d1ee3c67ab9e35278d8ac049d11bb780a0447ac
parent5395a854432a5007d6363ea7f0f7bc9e547c1e7f (diff)
cli,modem-3gpp: new '--3gpp-set-nr5g-registration-settings' action
-rw-r--r--cli/mmcli-modem-3gpp.c71
1 files changed, 70 insertions, 1 deletions
diff --git a/cli/mmcli-modem-3gpp.c b/cli/mmcli-modem-3gpp.c
index 58bdcc83..957ad928 100644
--- a/cli/mmcli-modem-3gpp.c
+++ b/cli/mmcli-modem-3gpp.c
@@ -53,6 +53,7 @@ static gchar *set_eps_ue_mode_operation_str;
static gchar *set_initial_eps_bearer_settings_str;
static gchar *disable_facility_lock_str;
static gchar *set_packet_service_state_str;
+static gchar *set_nr5g_registration_settings_str;
static GOptionEntry entries[] = {
{ "3gpp-scan", 0, 0, G_OPTION_ARG_NONE, &scan_flag,
@@ -83,6 +84,10 @@ static GOptionEntry entries[] = {
"Set packet service state",
"[attached|detached]"
},
+ { "3gpp-set-nr5g-registration-settings", 0, 0, G_OPTION_ARG_STRING, &set_nr5g_registration_settings_str,
+ "Set 5GNR registration settings",
+ "[\"key=value,...\"]"
+ },
{ NULL }
};
@@ -116,7 +121,8 @@ mmcli_modem_3gpp_options_enabled (void)
!!set_eps_ue_mode_operation_str +
!!set_initial_eps_bearer_settings_str +
!!disable_facility_lock_str +
- !!set_packet_service_state_str);
+ !!set_packet_service_state_str +
+ !!set_nr5g_registration_settings_str);
if (n_actions > 1) {
g_printerr ("error: too many 3GPP actions requested\n");
@@ -388,6 +394,33 @@ set_packet_service_state_parse_input (const gchar *str,
}
static void
+set_nr5g_registration_settings_process_reply (gboolean result,
+ const GError *error)
+{
+ if (!result) {
+ g_printerr ("error: couldn't set 5GNR registration settings: '%s'\n",
+ error ? error->message : "unknown error");
+ exit (EXIT_FAILURE);
+ }
+
+ g_print ("successfully set 5GNR registration settings\n");
+}
+
+static void
+set_nr5g_registration_settings_ready (MMModem3gpp *modem_3gpp,
+ GAsyncResult *result,
+ gpointer nothing)
+{
+ gboolean operation_result;
+ GError *error = NULL;
+
+ operation_result = mm_modem_3gpp_set_nr5g_registration_settings_finish (modem_3gpp, result, &error);
+ set_nr5g_registration_settings_process_reply (operation_result, error);
+
+ mmcli_async_operation_done ();
+}
+
+static void
get_modem_ready (GObject *source,
GAsyncResult *result)
{
@@ -500,6 +533,26 @@ get_modem_ready (GObject *source,
return;
}
+ /* Request to set packet service state */
+ if (set_nr5g_registration_settings_str) {
+ g_autoptr(MMNr5gRegistrationSettings) settings = NULL;
+ GError *error = NULL;
+
+ settings = mm_nr5g_registration_settings_new_from_string (set_nr5g_registration_settings_str, &error);
+ if (!settings) {
+ g_printerr ("Error parsing 5GNR registration settings string: %s\n", error->message);
+ exit (EXIT_FAILURE);
+ }
+
+ g_debug ("Asynchronously setting 5GNR registration settings...");
+ mm_modem_3gpp_set_nr5g_registration_settings (ctx->modem_3gpp,
+ settings,
+ ctx->cancellable,
+ (GAsyncReadyCallback)set_nr5g_registration_settings_ready,
+ NULL);
+ return;
+ }
+
g_warn_if_reached ();
}
@@ -636,5 +689,21 @@ mmcli_modem_3gpp_run_synchronous (GDBusConnection *connection)
return;
}
+ if (set_nr5g_registration_settings_str) {
+ g_autoptr(MMNr5gRegistrationSettings) settings = NULL;
+ gboolean result;
+
+ settings = mm_nr5g_registration_settings_new_from_string (set_nr5g_registration_settings_str, &error);
+ if (!settings) {
+ g_printerr ("Error parsing 5GNR registration settings string: %s\n", error->message);
+ exit (EXIT_FAILURE);
+ }
+
+ g_debug ("Asynchronously setting 5GNR registration settings...");
+ result = mm_modem_3gpp_set_nr5g_registration_settings_sync (ctx->modem_3gpp, settings, NULL, &error);
+ set_nr5g_registration_settings_process_reply (result, error);
+ return;
+ }
+
g_warn_if_reached ();
}