broadband-modem-qmi: Enable AT URCs and QMI indications
Enable both AT URCs and QMI indications for messaging events. This allows to receive text messages during suspend on the PinePhone with a Quectel EG25 modem.
This commit is contained in:

committed by
Aleksander Morgado

parent
438ff54d03
commit
8bc90b7131
@@ -117,7 +117,7 @@ struct _MMBroadbandModemQmiPrivate {
|
||||
GTask *activation_task;
|
||||
|
||||
/* Messaging helpers */
|
||||
gboolean messaging_fallback_at;
|
||||
gboolean messaging_fallback_at_only;
|
||||
gboolean messaging_unsolicited_events_enabled;
|
||||
gboolean messaging_unsolicited_events_setup;
|
||||
guint messaging_event_report_indication_id;
|
||||
@@ -5332,9 +5332,9 @@ parent_messaging_check_support_ready (MMIfaceModemMessaging *_self,
|
||||
{
|
||||
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||
|
||||
self->priv->messaging_fallback_at = iface_modem_messaging_parent->check_support_finish (_self, res, NULL);
|
||||
self->priv->messaging_fallback_at_only = iface_modem_messaging_parent->check_support_finish (_self, res, NULL);
|
||||
|
||||
g_task_return_boolean (task, self->priv->messaging_fallback_at);
|
||||
g_task_return_boolean (task, self->priv->messaging_fallback_at_only);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
@@ -5379,8 +5379,8 @@ messaging_load_supported_storages_finish (MMIfaceModemMessaging *_self,
|
||||
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||
MMSmsStorage supported;
|
||||
|
||||
/* Handle fallback */
|
||||
if (self->priv->messaging_fallback_at) {
|
||||
/* Handle AT URC only fallback */
|
||||
if (self->priv->messaging_fallback_at_only) {
|
||||
return iface_modem_messaging_parent->load_supported_storages_finish (_self, res, mem1, mem2, mem3, error);
|
||||
}
|
||||
|
||||
@@ -5407,8 +5407,8 @@ messaging_load_supported_storages (MMIfaceModemMessaging *_self,
|
||||
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||
GTask *task;
|
||||
|
||||
/* Handle fallback */
|
||||
if (self->priv->messaging_fallback_at) {
|
||||
/* Handle AT URC only fallback */
|
||||
if (self->priv->messaging_fallback_at_only) {
|
||||
iface_modem_messaging_parent->load_supported_storages (_self, callback, user_data);
|
||||
return;
|
||||
}
|
||||
@@ -5428,8 +5428,8 @@ modem_messaging_setup_sms_format_finish (MMIfaceModemMessaging *_self,
|
||||
{
|
||||
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||
|
||||
/* Handle fallback */
|
||||
if (self->priv->messaging_fallback_at) {
|
||||
/* Handle AT URC only fallback */
|
||||
if (self->priv->messaging_fallback_at_only) {
|
||||
return iface_modem_messaging_parent->setup_sms_format_finish (_self, res, error);
|
||||
}
|
||||
|
||||
@@ -5444,8 +5444,8 @@ modem_messaging_setup_sms_format (MMIfaceModemMessaging *_self,
|
||||
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||
GTask *task;
|
||||
|
||||
/* Handle fallback */
|
||||
if (self->priv->messaging_fallback_at) {
|
||||
/* Handle AT URC only fallback */
|
||||
if (self->priv->messaging_fallback_at_only) {
|
||||
return iface_modem_messaging_parent->setup_sms_format (_self, callback, user_data);
|
||||
}
|
||||
|
||||
@@ -5465,8 +5465,8 @@ messaging_set_default_storage_finish (MMIfaceModemMessaging *_self,
|
||||
{
|
||||
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||
|
||||
/* Handle fallback */
|
||||
if (self->priv->messaging_fallback_at) {
|
||||
/* Handle AT URC only fallback */
|
||||
if (self->priv->messaging_fallback_at_only) {
|
||||
return iface_modem_messaging_parent->set_default_storage_finish (_self, res, error);
|
||||
}
|
||||
|
||||
@@ -5509,8 +5509,8 @@ messaging_set_default_storage (MMIfaceModemMessaging *_self,
|
||||
GArray *routes_array;
|
||||
QmiMessageWmsSetRoutesInputRouteListElement route;
|
||||
|
||||
/* Handle fallback */
|
||||
if (self->priv->messaging_fallback_at) {
|
||||
/* Handle AT URC only fallback */
|
||||
if (self->priv->messaging_fallback_at_only) {
|
||||
iface_modem_messaging_parent->set_default_storage (_self, storage, callback, user_data);
|
||||
return;
|
||||
}
|
||||
@@ -5594,8 +5594,8 @@ load_initial_sms_parts_finish (MMIfaceModemMessaging *_self,
|
||||
{
|
||||
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||
|
||||
/* Handle fallback */
|
||||
if (self->priv->messaging_fallback_at) {
|
||||
/* Handle AT URC only fallback */
|
||||
if (self->priv->messaging_fallback_at_only) {
|
||||
return iface_modem_messaging_parent->load_initial_sms_parts_finish (_self, res, error);
|
||||
}
|
||||
|
||||
@@ -5973,8 +5973,8 @@ load_initial_sms_parts (MMIfaceModemMessaging *_self,
|
||||
GTask *task;
|
||||
QmiClient *client = NULL;
|
||||
|
||||
/* Handle fallback */
|
||||
if (self->priv->messaging_fallback_at) {
|
||||
/* Handle AT URC only fallback */
|
||||
if (self->priv->messaging_fallback_at_only) {
|
||||
return iface_modem_messaging_parent->load_initial_sms_parts (_self, storage, callback, user_data);
|
||||
}
|
||||
|
||||
@@ -5995,7 +5995,7 @@ load_initial_sms_parts (MMIfaceModemMessaging *_self,
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Setup/Cleanup unsolicited event handlers (Messaging interface) */
|
||||
/* Common setup/cleanup unsolicited event handlers (Messaging interface) */
|
||||
|
||||
typedef struct {
|
||||
MMIfaceModemMessaging *self;
|
||||
@@ -6108,57 +6108,23 @@ messaging_event_report_indication_cb (QmiClientNas *client,
|
||||
}
|
||||
|
||||
static gboolean
|
||||
messaging_cleanup_unsolicited_events_finish (MMIfaceModemMessaging *_self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
common_setup_cleanup_messaging_unsolicited_events (MMBroadbandModemQmi *self,
|
||||
gboolean enable,
|
||||
GError **error)
|
||||
{
|
||||
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||
|
||||
/* Handle fallback */
|
||||
if (self->priv->messaging_fallback_at) {
|
||||
return iface_modem_messaging_parent->cleanup_unsolicited_events_finish (_self, res, error);
|
||||
}
|
||||
|
||||
return g_task_propagate_boolean (G_TASK (res), error);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
messaging_setup_unsolicited_events_finish (MMIfaceModemMessaging *_self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||
|
||||
/* Handle fallback */
|
||||
if (self->priv->messaging_fallback_at) {
|
||||
return iface_modem_messaging_parent->setup_unsolicited_events_finish (_self, res, error);
|
||||
}
|
||||
|
||||
return g_task_propagate_boolean (G_TASK (res), error);
|
||||
}
|
||||
|
||||
static void
|
||||
common_setup_cleanup_messaging_unsolicited_events (MMBroadbandModemQmi *self,
|
||||
gboolean enable,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GTask *task;
|
||||
QmiClient *client = NULL;
|
||||
|
||||
if (!mm_shared_qmi_ensure_client (MM_SHARED_QMI (self),
|
||||
QMI_SERVICE_WMS, &client,
|
||||
callback, user_data))
|
||||
return;
|
||||
|
||||
task = g_task_new (self, NULL, callback, user_data);
|
||||
client = mm_shared_qmi_peek_client (MM_SHARED_QMI (self),
|
||||
QMI_SERVICE_WMS,
|
||||
MM_PORT_QMI_FLAG_DEFAULT,
|
||||
error);
|
||||
if (!client)
|
||||
return FALSE;
|
||||
|
||||
if (enable == self->priv->messaging_unsolicited_events_setup) {
|
||||
mm_obj_dbg (self, "messaging unsolicited events already %s; skipping",
|
||||
enable ? "setup" : "cleanup");
|
||||
g_task_return_boolean (task, TRUE);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* Store new state */
|
||||
@@ -6178,44 +6144,119 @@ common_setup_cleanup_messaging_unsolicited_events (MMBroadbandModemQmi *self,
|
||||
self->priv->messaging_event_report_indication_id = 0;
|
||||
}
|
||||
|
||||
g_task_return_boolean (task, TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Cleanup unsolicited event handlers (Messaging interface) */
|
||||
|
||||
static gboolean
|
||||
messaging_cleanup_unsolicited_events_finish (MMIfaceModemMessaging *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
return g_task_propagate_boolean (G_TASK (res), error);
|
||||
}
|
||||
|
||||
static void
|
||||
parent_messaging_cleanup_unsolicited_events_ready (MMIfaceModemMessaging *_self,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||
GError *error = NULL;
|
||||
|
||||
if (!iface_modem_messaging_parent->cleanup_unsolicited_events_finish (_self, res, &error)) {
|
||||
if (self->priv->messaging_fallback_at_only) {
|
||||
g_task_return_error (task, error);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
mm_obj_dbg (self, "cleaning up parent messaging unsolicited events failed: %s", error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
/* handle AT URC only fallback */
|
||||
if (self->priv->messaging_fallback_at_only) {
|
||||
g_task_return_boolean (task, TRUE);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Disable QMI indications */
|
||||
if (!common_setup_cleanup_messaging_unsolicited_events (self, FALSE, &error))
|
||||
g_task_return_error (task, error);
|
||||
else
|
||||
g_task_return_boolean (task, TRUE);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static void
|
||||
messaging_cleanup_unsolicited_events (MMIfaceModemMessaging *_self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
messaging_cleanup_unsolicited_events (MMIfaceModemMessaging *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||
/* Disable AT URCs parent and chain QMI indications disabling */
|
||||
iface_modem_messaging_parent->cleanup_unsolicited_events (
|
||||
self,
|
||||
(GAsyncReadyCallback)parent_messaging_cleanup_unsolicited_events_ready,
|
||||
g_task_new (self, NULL, callback, user_data));
|
||||
}
|
||||
|
||||
/* Handle fallback */
|
||||
if (self->priv->messaging_fallback_at) {
|
||||
return iface_modem_messaging_parent->cleanup_unsolicited_events (_self, callback, user_data);
|
||||
}
|
||||
/*****************************************************************************/
|
||||
/* Setup unsolicited event handlers (Messaging interface) */
|
||||
|
||||
common_setup_cleanup_messaging_unsolicited_events (MM_BROADBAND_MODEM_QMI (self),
|
||||
FALSE,
|
||||
callback,
|
||||
user_data);
|
||||
static gboolean
|
||||
messaging_setup_unsolicited_events_finish (MMIfaceModemMessaging *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
return g_task_propagate_boolean (G_TASK (res), error);
|
||||
}
|
||||
|
||||
static void
|
||||
messaging_setup_unsolicited_events (MMIfaceModemMessaging *_self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
parent_messaging_setup_unsolicited_events_ready (MMIfaceModemMessaging *_self,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||
GError *error = NULL;
|
||||
|
||||
/* Handle fallback */
|
||||
if (self->priv->messaging_fallback_at) {
|
||||
return iface_modem_messaging_parent->setup_unsolicited_events (_self, callback, user_data);
|
||||
if (!iface_modem_messaging_parent->setup_unsolicited_events_finish (_self, res, &error)) {
|
||||
if (self->priv->messaging_fallback_at_only) {
|
||||
g_task_return_error (task, error);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
mm_obj_dbg (self, "setting up parent messaging unsolicited events failed: %s", error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
|
||||
common_setup_cleanup_messaging_unsolicited_events (MM_BROADBAND_MODEM_QMI (self),
|
||||
TRUE,
|
||||
callback,
|
||||
user_data);
|
||||
/* handle AT URC only fallback */
|
||||
if (self->priv->messaging_fallback_at_only) {
|
||||
g_task_return_boolean (task, TRUE);
|
||||
g_object_unref (task);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Enable QMI indications */
|
||||
if (!common_setup_cleanup_messaging_unsolicited_events (self, TRUE, &error))
|
||||
g_task_return_error (task, error);
|
||||
else
|
||||
g_task_return_boolean (task, TRUE);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static void
|
||||
messaging_setup_unsolicited_events (MMIfaceModemMessaging *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
/* Enable AT URCs parent and chain QMI indication enabling */
|
||||
iface_modem_messaging_parent->setup_unsolicited_events (
|
||||
self,
|
||||
(GAsyncReadyCallback)parent_messaging_setup_unsolicited_events_ready,
|
||||
g_task_new (self, NULL, callback, user_data));
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -6232,8 +6273,8 @@ messaging_disable_unsolicited_events_finish (MMIfaceModemMessaging *_self,
|
||||
{
|
||||
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||
|
||||
/* Handle fallback */
|
||||
if (self->priv->messaging_fallback_at && iface_modem_messaging_parent->disable_unsolicited_events_finish) {
|
||||
/* Handle AT URC only fallback */
|
||||
if (self->priv->messaging_fallback_at_only && iface_modem_messaging_parent->disable_unsolicited_events_finish) {
|
||||
return iface_modem_messaging_parent->disable_unsolicited_events_finish (_self, res, error);
|
||||
}
|
||||
|
||||
@@ -6247,8 +6288,8 @@ messaging_enable_unsolicited_events_finish (MMIfaceModemMessaging *_self,
|
||||
{
|
||||
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||
|
||||
/* Handle fallback */
|
||||
if (self->priv->messaging_fallback_at) {
|
||||
/* Handle AT URC only fallback */
|
||||
if (self->priv->messaging_fallback_at_only) {
|
||||
return iface_modem_messaging_parent->enable_unsolicited_events_finish (_self, res, error);
|
||||
}
|
||||
|
||||
@@ -6340,8 +6381,8 @@ messaging_disable_unsolicited_events (MMIfaceModemMessaging *_self,
|
||||
{
|
||||
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||
|
||||
/* Handle fallback */
|
||||
if (self->priv->messaging_fallback_at) {
|
||||
/* Handle AT URC only fallback */
|
||||
if (self->priv->messaging_fallback_at_only) {
|
||||
/* Generic implementation doesn't actually have a method to disable
|
||||
* unsolicited messaging events */
|
||||
if (!iface_modem_messaging_parent->disable_unsolicited_events) {
|
||||
@@ -6369,8 +6410,8 @@ messaging_enable_unsolicited_events (MMIfaceModemMessaging *_self,
|
||||
{
|
||||
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||
|
||||
/* Handle fallback */
|
||||
if (self->priv->messaging_fallback_at) {
|
||||
/* Handle AT URC only fallback */
|
||||
if (self->priv->messaging_fallback_at_only) {
|
||||
return iface_modem_messaging_parent->enable_unsolicited_events (_self, callback, user_data);
|
||||
}
|
||||
|
||||
@@ -6388,8 +6429,8 @@ messaging_create_sms (MMIfaceModemMessaging *_self)
|
||||
{
|
||||
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||
|
||||
/* Handle fallback */
|
||||
if (self->priv->messaging_fallback_at) {
|
||||
/* Handle AT URC only fallback */
|
||||
if (self->priv->messaging_fallback_at_only) {
|
||||
return iface_modem_messaging_parent->create_sms (_self);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user