broadband-modem-qmi,mm-shared-qmi: implement support for 'SetPacketServiceState()'
This commit is contained in:

committed by
Aleksander Morgado

parent
6761fc0099
commit
d008e437c3
@@ -13128,6 +13128,8 @@ iface_modem_3gpp_init (MMIfaceModem3gpp *iface)
|
||||
iface->set_initial_eps_bearer_settings_finish = modem_3gpp_set_initial_eps_bearer_settings_finish;
|
||||
iface->disable_facility_lock = modem_3gpp_disable_facility_lock;
|
||||
iface->disable_facility_lock_finish = modem_3gpp_disable_facility_lock_finish;
|
||||
iface->set_packet_service_state = mm_shared_qmi_set_packet_service_state;
|
||||
iface->set_packet_service_state_finish = mm_shared_qmi_set_packet_service_state_finish;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -4254,6 +4254,194 @@ mm_shared_qmi_setup_sim_hot_swap (MMIfaceModem *self,
|
||||
setup_sim_hot_swap_step (task);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Set packet service state (3GPP interface) */
|
||||
|
||||
typedef struct {
|
||||
QmiClientNas *client;
|
||||
MMModem3gppPacketServiceState packet_service_state;
|
||||
} SetPacketServiceStateContext;
|
||||
|
||||
static void
|
||||
set_packet_service_state_context_free (SetPacketServiceStateContext *ctx)
|
||||
{
|
||||
if (ctx->client)
|
||||
g_object_unref (ctx->client);
|
||||
g_slice_free (SetPacketServiceStateContext, ctx);
|
||||
}
|
||||
|
||||
gboolean
|
||||
mm_shared_qmi_set_packet_service_state_finish (MMIfaceModem3gpp *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
return g_task_propagate_boolean (G_TASK (res), error);
|
||||
}
|
||||
|
||||
static void
|
||||
set_packet_service_state_ia_ready (QmiClientNas *client,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
GError *error = NULL;
|
||||
QmiMessageNasAttachDetachOutput *output;
|
||||
|
||||
output = qmi_client_nas_attach_detach_finish (client, res, &error);
|
||||
if (!output || !qmi_message_nas_attach_detach_output_get_result (output, &error)) {
|
||||
if (!g_error_matches (error, QMI_PROTOCOL_ERROR, QMI_PROTOCOL_ERROR_NO_EFFECT)) {
|
||||
g_prefix_error (&error, "Couldn't set packet service state: ");
|
||||
g_task_return_error (task, error);
|
||||
goto out;
|
||||
}
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
g_task_return_boolean (task, TRUE);
|
||||
|
||||
out:
|
||||
g_object_unref (task);
|
||||
|
||||
if (output)
|
||||
qmi_message_nas_attach_detach_output_unref (output);
|
||||
}
|
||||
|
||||
static void
|
||||
set_packet_service_state_ia (GTask *task)
|
||||
{
|
||||
QmiMessageNasAttachDetachInput *input;
|
||||
SetPacketServiceStateContext *ctx;
|
||||
|
||||
input = qmi_message_nas_attach_detach_input_new ();
|
||||
ctx = g_task_get_task_data (task);
|
||||
|
||||
switch (ctx->packet_service_state) {
|
||||
case MM_MODEM_3GPP_PACKET_SERVICE_STATE_ATTACHED:
|
||||
qmi_message_nas_attach_detach_input_set_action (
|
||||
input,
|
||||
QMI_NAS_PS_ATTACH_ACTION_ATTACH,
|
||||
NULL);
|
||||
break;
|
||||
case MM_MODEM_3GPP_PACKET_SERVICE_STATE_DETACHED:
|
||||
qmi_message_nas_attach_detach_input_set_action (
|
||||
input,
|
||||
QMI_NAS_PS_ATTACH_ACTION_DETACH,
|
||||
NULL);
|
||||
break;
|
||||
case MM_MODEM_3GPP_PACKET_SERVICE_STATE_UNKNOWN:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
qmi_client_nas_attach_detach (
|
||||
ctx->client,
|
||||
input,
|
||||
5,
|
||||
NULL,
|
||||
(GAsyncReadyCallback)set_packet_service_state_ia_ready,
|
||||
task);
|
||||
|
||||
qmi_message_nas_attach_detach_input_unref (input);
|
||||
}
|
||||
|
||||
static void
|
||||
set_packet_service_state_sssp_ready (QmiClientNas *client,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
GError *error = NULL;
|
||||
QmiMessageNasSetSystemSelectionPreferenceOutput *output;
|
||||
|
||||
output = qmi_client_nas_set_system_selection_preference_finish (client, res, &error);
|
||||
if (!output || !qmi_message_nas_set_system_selection_preference_output_get_result (output, &error)) {
|
||||
if (!g_error_matches (error, QMI_PROTOCOL_ERROR, QMI_PROTOCOL_ERROR_NO_EFFECT)) {
|
||||
g_prefix_error (&error, "Couldn't set packet service state: ");
|
||||
g_task_return_error (task, error);
|
||||
goto out;
|
||||
}
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
g_task_return_boolean (task, TRUE);
|
||||
|
||||
out:
|
||||
g_object_unref (task);
|
||||
|
||||
if (output)
|
||||
qmi_message_nas_set_system_selection_preference_output_unref (output);
|
||||
}
|
||||
|
||||
static void
|
||||
set_packet_service_state_sssp (GTask *task)
|
||||
{
|
||||
QmiMessageNasSetSystemSelectionPreferenceInput *input;
|
||||
SetPacketServiceStateContext *ctx;
|
||||
|
||||
input = qmi_message_nas_set_system_selection_preference_input_new ();
|
||||
ctx = g_task_get_task_data (task);
|
||||
|
||||
switch (ctx->packet_service_state) {
|
||||
case MM_MODEM_3GPP_PACKET_SERVICE_STATE_ATTACHED:
|
||||
qmi_message_nas_set_system_selection_preference_input_set_service_domain_preference (
|
||||
input,
|
||||
QMI_NAS_SERVICE_DOMAIN_PREFERENCE_PS_ATTACH,
|
||||
NULL);
|
||||
break;
|
||||
case MM_MODEM_3GPP_PACKET_SERVICE_STATE_DETACHED:
|
||||
qmi_message_nas_set_system_selection_preference_input_set_service_domain_preference (
|
||||
input,
|
||||
QMI_NAS_SERVICE_DOMAIN_PREFERENCE_PS_DETACH,
|
||||
NULL);
|
||||
break;
|
||||
case MM_MODEM_3GPP_PACKET_SERVICE_STATE_UNKNOWN:
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
qmi_client_nas_set_system_selection_preference (
|
||||
ctx->client,
|
||||
input,
|
||||
5,
|
||||
NULL,
|
||||
(GAsyncReadyCallback)set_packet_service_state_sssp_ready,
|
||||
task);
|
||||
|
||||
qmi_message_nas_set_system_selection_preference_input_unref (input);
|
||||
}
|
||||
|
||||
void
|
||||
mm_shared_qmi_set_packet_service_state (MMIfaceModem3gpp *self,
|
||||
MMModem3gppPacketServiceState packet_service_state,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GTask *task;
|
||||
SetPacketServiceStateContext *ctx;
|
||||
QmiClient *client = NULL;
|
||||
Private *priv = NULL;
|
||||
|
||||
g_assert ((packet_service_state == MM_MODEM_3GPP_PACKET_SERVICE_STATE_ATTACHED) ||
|
||||
(packet_service_state == MM_MODEM_3GPP_PACKET_SERVICE_STATE_DETACHED));
|
||||
|
||||
/* Get NAS client */
|
||||
if (!mm_shared_qmi_ensure_client (MM_SHARED_QMI (self),
|
||||
QMI_SERVICE_NAS, &client,
|
||||
callback, user_data))
|
||||
return;
|
||||
|
||||
task = g_task_new (self, NULL, callback, user_data);
|
||||
|
||||
ctx = g_slice_new0 (SetPacketServiceStateContext);
|
||||
ctx->client = QMI_CLIENT_NAS (g_object_ref (client));
|
||||
ctx->packet_service_state = packet_service_state;
|
||||
g_task_set_task_data (task, ctx, (GDestroyNotify)set_packet_service_state_context_free);
|
||||
|
||||
priv = get_private (MM_SHARED_QMI (self));
|
||||
if (priv->feature_nas_ssp == FEATURE_SUPPORTED)
|
||||
set_packet_service_state_sssp (task);
|
||||
else
|
||||
set_packet_service_state_ia (task);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Location: Set SUPL server */
|
||||
|
||||
|
@@ -11,6 +11,7 @@
|
||||
* GNU General Public License for more details:
|
||||
*
|
||||
* Copyright (C) 2018 Aleksander Morgado <aleksander@aleksander.es>
|
||||
* Copyright (c) 2022 Qualcomm Innovation Center, Inc.
|
||||
*/
|
||||
|
||||
#ifndef MM_SHARED_QMI_H
|
||||
@@ -64,14 +65,21 @@ gboolean mm_shared_qmi_ensure_client (MMSharedQmi *self,
|
||||
|
||||
/* Shared QMI 3GPP operations */
|
||||
|
||||
void mm_shared_qmi_3gpp_register_in_network (MMIfaceModem3gpp *self,
|
||||
const gchar *operator_id,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_shared_qmi_3gpp_register_in_network_finish (MMIfaceModem3gpp *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
void mm_shared_qmi_3gpp_register_in_network (MMIfaceModem3gpp *self,
|
||||
const gchar *operator_id,
|
||||
GCancellable *cancellable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_shared_qmi_3gpp_register_in_network_finish (MMIfaceModem3gpp *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
void mm_shared_qmi_set_packet_service_state (MMIfaceModem3gpp *self,
|
||||
MMModem3gppPacketServiceState packet_service_state,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_shared_qmi_set_packet_service_state_finish (MMIfaceModem3gpp *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
/* Shared QMI device management support */
|
||||
|
||||
|
Reference in New Issue
Block a user