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;
|
GTask *activation_task;
|
||||||
|
|
||||||
/* Messaging helpers */
|
/* Messaging helpers */
|
||||||
gboolean messaging_fallback_at;
|
gboolean messaging_fallback_at_only;
|
||||||
gboolean messaging_unsolicited_events_enabled;
|
gboolean messaging_unsolicited_events_enabled;
|
||||||
gboolean messaging_unsolicited_events_setup;
|
gboolean messaging_unsolicited_events_setup;
|
||||||
guint messaging_event_report_indication_id;
|
guint messaging_event_report_indication_id;
|
||||||
@@ -5332,9 +5332,9 @@ parent_messaging_check_support_ready (MMIfaceModemMessaging *_self,
|
|||||||
{
|
{
|
||||||
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_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);
|
g_object_unref (task);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5379,8 +5379,8 @@ messaging_load_supported_storages_finish (MMIfaceModemMessaging *_self,
|
|||||||
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||||
MMSmsStorage supported;
|
MMSmsStorage supported;
|
||||||
|
|
||||||
/* Handle fallback */
|
/* Handle AT URC only fallback */
|
||||||
if (self->priv->messaging_fallback_at) {
|
if (self->priv->messaging_fallback_at_only) {
|
||||||
return iface_modem_messaging_parent->load_supported_storages_finish (_self, res, mem1, mem2, mem3, error);
|
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);
|
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||||
GTask *task;
|
GTask *task;
|
||||||
|
|
||||||
/* Handle fallback */
|
/* Handle AT URC only fallback */
|
||||||
if (self->priv->messaging_fallback_at) {
|
if (self->priv->messaging_fallback_at_only) {
|
||||||
iface_modem_messaging_parent->load_supported_storages (_self, callback, user_data);
|
iface_modem_messaging_parent->load_supported_storages (_self, callback, user_data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -5428,8 +5428,8 @@ modem_messaging_setup_sms_format_finish (MMIfaceModemMessaging *_self,
|
|||||||
{
|
{
|
||||||
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||||
|
|
||||||
/* Handle fallback */
|
/* Handle AT URC only fallback */
|
||||||
if (self->priv->messaging_fallback_at) {
|
if (self->priv->messaging_fallback_at_only) {
|
||||||
return iface_modem_messaging_parent->setup_sms_format_finish (_self, res, error);
|
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);
|
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||||
GTask *task;
|
GTask *task;
|
||||||
|
|
||||||
/* Handle fallback */
|
/* Handle AT URC only fallback */
|
||||||
if (self->priv->messaging_fallback_at) {
|
if (self->priv->messaging_fallback_at_only) {
|
||||||
return iface_modem_messaging_parent->setup_sms_format (_self, callback, user_data);
|
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);
|
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||||
|
|
||||||
/* Handle fallback */
|
/* Handle AT URC only fallback */
|
||||||
if (self->priv->messaging_fallback_at) {
|
if (self->priv->messaging_fallback_at_only) {
|
||||||
return iface_modem_messaging_parent->set_default_storage_finish (_self, res, error);
|
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;
|
GArray *routes_array;
|
||||||
QmiMessageWmsSetRoutesInputRouteListElement route;
|
QmiMessageWmsSetRoutesInputRouteListElement route;
|
||||||
|
|
||||||
/* Handle fallback */
|
/* Handle AT URC only fallback */
|
||||||
if (self->priv->messaging_fallback_at) {
|
if (self->priv->messaging_fallback_at_only) {
|
||||||
iface_modem_messaging_parent->set_default_storage (_self, storage, callback, user_data);
|
iface_modem_messaging_parent->set_default_storage (_self, storage, callback, user_data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -5594,8 +5594,8 @@ load_initial_sms_parts_finish (MMIfaceModemMessaging *_self,
|
|||||||
{
|
{
|
||||||
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||||
|
|
||||||
/* Handle fallback */
|
/* Handle AT URC only fallback */
|
||||||
if (self->priv->messaging_fallback_at) {
|
if (self->priv->messaging_fallback_at_only) {
|
||||||
return iface_modem_messaging_parent->load_initial_sms_parts_finish (_self, res, error);
|
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;
|
GTask *task;
|
||||||
QmiClient *client = NULL;
|
QmiClient *client = NULL;
|
||||||
|
|
||||||
/* Handle fallback */
|
/* Handle AT URC only fallback */
|
||||||
if (self->priv->messaging_fallback_at) {
|
if (self->priv->messaging_fallback_at_only) {
|
||||||
return iface_modem_messaging_parent->load_initial_sms_parts (_self, storage, callback, user_data);
|
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 {
|
typedef struct {
|
||||||
MMIfaceModemMessaging *self;
|
MMIfaceModemMessaging *self;
|
||||||
@@ -6108,57 +6108,23 @@ messaging_event_report_indication_cb (QmiClientNas *client,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
messaging_cleanup_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->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,
|
common_setup_cleanup_messaging_unsolicited_events (MMBroadbandModemQmi *self,
|
||||||
gboolean enable,
|
gboolean enable,
|
||||||
GAsyncReadyCallback callback,
|
GError **error)
|
||||||
gpointer user_data)
|
|
||||||
{
|
{
|
||||||
GTask *task;
|
|
||||||
QmiClient *client = NULL;
|
QmiClient *client = NULL;
|
||||||
|
|
||||||
if (!mm_shared_qmi_ensure_client (MM_SHARED_QMI (self),
|
client = mm_shared_qmi_peek_client (MM_SHARED_QMI (self),
|
||||||
QMI_SERVICE_WMS, &client,
|
QMI_SERVICE_WMS,
|
||||||
callback, user_data))
|
MM_PORT_QMI_FLAG_DEFAULT,
|
||||||
return;
|
error);
|
||||||
|
if (!client)
|
||||||
task = g_task_new (self, NULL, callback, user_data);
|
return FALSE;
|
||||||
|
|
||||||
if (enable == self->priv->messaging_unsolicited_events_setup) {
|
if (enable == self->priv->messaging_unsolicited_events_setup) {
|
||||||
mm_obj_dbg (self, "messaging unsolicited events already %s; skipping",
|
mm_obj_dbg (self, "messaging unsolicited events already %s; skipping",
|
||||||
enable ? "setup" : "cleanup");
|
enable ? "setup" : "cleanup");
|
||||||
g_task_return_boolean (task, TRUE);
|
return TRUE;
|
||||||
g_object_unref (task);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Store new state */
|
/* Store new state */
|
||||||
@@ -6178,44 +6144,119 @@ common_setup_cleanup_messaging_unsolicited_events (MMBroadbandModemQmi *self,
|
|||||||
self->priv->messaging_event_report_indication_id = 0;
|
self->priv->messaging_event_report_indication_id = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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_task_return_boolean (task, TRUE);
|
||||||
g_object_unref (task);
|
g_object_unref (task);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
messaging_cleanup_unsolicited_events (MMIfaceModemMessaging *_self,
|
messaging_cleanup_unsolicited_events (MMIfaceModemMessaging *self,
|
||||||
GAsyncReadyCallback callback,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
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 (
|
||||||
/* Handle fallback */
|
self,
|
||||||
if (self->priv->messaging_fallback_at) {
|
(GAsyncReadyCallback)parent_messaging_cleanup_unsolicited_events_ready,
|
||||||
return iface_modem_messaging_parent->cleanup_unsolicited_events (_self, callback, user_data);
|
g_task_new (self, NULL, callback, user_data));
|
||||||
}
|
}
|
||||||
|
|
||||||
common_setup_cleanup_messaging_unsolicited_events (MM_BROADBAND_MODEM_QMI (self),
|
/*****************************************************************************/
|
||||||
FALSE,
|
/* Setup unsolicited event handlers (Messaging interface) */
|
||||||
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
|
static void
|
||||||
messaging_setup_unsolicited_events (MMIfaceModemMessaging *_self,
|
parent_messaging_setup_unsolicited_events_ready (MMIfaceModemMessaging *_self,
|
||||||
|
GAsyncResult *res,
|
||||||
|
GTask *task)
|
||||||
|
{
|
||||||
|
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 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,
|
GAsyncReadyCallback callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
/* Enable AT URCs parent and chain QMI indication enabling */
|
||||||
|
iface_modem_messaging_parent->setup_unsolicited_events (
|
||||||
/* Handle fallback */
|
self,
|
||||||
if (self->priv->messaging_fallback_at) {
|
(GAsyncReadyCallback)parent_messaging_setup_unsolicited_events_ready,
|
||||||
return iface_modem_messaging_parent->setup_unsolicited_events (_self, callback, user_data);
|
g_task_new (self, NULL, callback, user_data));
|
||||||
}
|
|
||||||
|
|
||||||
common_setup_cleanup_messaging_unsolicited_events (MM_BROADBAND_MODEM_QMI (self),
|
|
||||||
TRUE,
|
|
||||||
callback,
|
|
||||||
user_data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
@@ -6232,8 +6273,8 @@ messaging_disable_unsolicited_events_finish (MMIfaceModemMessaging *_self,
|
|||||||
{
|
{
|
||||||
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||||
|
|
||||||
/* Handle fallback */
|
/* Handle AT URC only fallback */
|
||||||
if (self->priv->messaging_fallback_at && iface_modem_messaging_parent->disable_unsolicited_events_finish) {
|
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);
|
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);
|
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||||
|
|
||||||
/* Handle fallback */
|
/* Handle AT URC only fallback */
|
||||||
if (self->priv->messaging_fallback_at) {
|
if (self->priv->messaging_fallback_at_only) {
|
||||||
return iface_modem_messaging_parent->enable_unsolicited_events_finish (_self, res, error);
|
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);
|
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||||
|
|
||||||
/* Handle fallback */
|
/* Handle AT URC only fallback */
|
||||||
if (self->priv->messaging_fallback_at) {
|
if (self->priv->messaging_fallback_at_only) {
|
||||||
/* Generic implementation doesn't actually have a method to disable
|
/* Generic implementation doesn't actually have a method to disable
|
||||||
* unsolicited messaging events */
|
* unsolicited messaging events */
|
||||||
if (!iface_modem_messaging_parent->disable_unsolicited_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);
|
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||||
|
|
||||||
/* Handle fallback */
|
/* Handle AT URC only fallback */
|
||||||
if (self->priv->messaging_fallback_at) {
|
if (self->priv->messaging_fallback_at_only) {
|
||||||
return iface_modem_messaging_parent->enable_unsolicited_events (_self, callback, user_data);
|
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);
|
MMBroadbandModemQmi *self = MM_BROADBAND_MODEM_QMI (_self);
|
||||||
|
|
||||||
/* Handle fallback */
|
/* Handle AT URC only fallback */
|
||||||
if (self->priv->messaging_fallback_at) {
|
if (self->priv->messaging_fallback_at_only) {
|
||||||
return iface_modem_messaging_parent->create_sms (_self);
|
return iface_modem_messaging_parent->create_sms (_self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user