From 60fe68f6093a449253281cc76ab47061638cea52 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Sun, 28 Nov 2021 23:07:04 +0100 Subject: [PATCH] iface-modem-3gpp: implement loading 5GNR registration settings during init --- src/mm-iface-modem-3gpp.c | 39 +++++++++++++++++++++++++++++++++++++++ src/mm-iface-modem-3gpp.h | 8 ++++++++ 2 files changed, 47 insertions(+) diff --git a/src/mm-iface-modem-3gpp.c b/src/mm-iface-modem-3gpp.c index 1e18b5b7..e2ae6f42 100644 --- a/src/mm-iface-modem-3gpp.c +++ b/src/mm-iface-modem-3gpp.c @@ -2816,6 +2816,7 @@ typedef enum { INITIALIZATION_STEP_IMEI, INITIALIZATION_STEP_EPS_UE_MODE_OPERATION, INITIALIZATION_STEP_EPS_INITIAL_BEARER_SETTINGS, + INITIALIZATION_STEP_NR5G_REGISTRATION_SETTINGS, INITIALIZATION_STEP_CONNECT_SIGNALS, INITIALIZATION_STEP_LAST } InitializationStep; @@ -2848,6 +2849,32 @@ sim_pin_lock_enabled_cb (MMBaseSim *self, mm_gdbus_modem3gpp_set_enabled_facility_locks (skeleton, facilities); } +static void +load_nr5g_registration_settings_ready (MMIfaceModem3gpp *self, + GAsyncResult *res, + GTask *task) +{ + InitializationContext *ctx; + g_autoptr(GError) error = NULL; + g_autoptr(MMNr5gRegistrationSettings) settings = NULL; + + ctx = g_task_get_task_data (task); + + settings = MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->load_nr5g_registration_settings_finish (self, res, &error); + if (!settings) { + mm_obj_warn (self, "couldn't load 5GNR registration settings: %s", error->message); + } else { + g_autoptr(GVariant) dictionary = NULL; + + dictionary = mm_nr5g_registration_settings_get_dictionary (settings); + mm_gdbus_modem3gpp_set_nr5g_registration_settings (ctx->skeleton, dictionary); + } + + /* Go on to next step */ + ctx->step++; + interface_initialization_step (task); +} + static void load_initial_eps_bearer_settings_ready (MMIfaceModem3gpp *self, GAsyncResult *res, @@ -3053,6 +3080,18 @@ interface_initialization_step (GTask *task) ctx->step++; /* fall through */ + case INITIALIZATION_STEP_NR5G_REGISTRATION_SETTINGS: + if (MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->load_nr5g_registration_settings && + MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->load_nr5g_registration_settings_finish) { + MM_IFACE_MODEM_3GPP_GET_INTERFACE (self)->load_nr5g_registration_settings ( + self, + (GAsyncReadyCallback)load_nr5g_registration_settings_ready, + task); + return; + } + ctx->step++; + /* fall through */ + case INITIALIZATION_STEP_CONNECT_SIGNALS: /* We are done without errors! */ diff --git a/src/mm-iface-modem-3gpp.h b/src/mm-iface-modem-3gpp.h index b0403ea8..93e322f7 100644 --- a/src/mm-iface-modem-3gpp.h +++ b/src/mm-iface-modem-3gpp.h @@ -165,6 +165,14 @@ struct _MMIfaceModem3gpp { GAsyncResult *res, GError **error); + /* Asynchronous 5GNR registration settings loading */ + void (*load_nr5g_registration_settings) (MMIfaceModem3gpp *self, + GAsyncReadyCallback callback, + gpointer user_data); + MMModem3gppNr5gRegistrationSettings * (*load_nr5g_registration_settings_finish) (MMIfaceModem3gpp *self, + GAsyncResult *res, + GError **error); + /* Create initial default EPS bearer object */ MMBaseBearer * (*create_initial_eps_bearer) (MMIfaceModem3gpp *self, MMBearerProperties *properties);