cli,modem-3gpp: new '--3gpp-set-nr5g-registration-settings' action
This commit is contained in:
@@ -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");
|
||||
@@ -387,6 +393,33 @@ set_packet_service_state_parse_input (const gchar *str,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
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 ();
|
||||
}
|
||||
|
Reference in New Issue
Block a user