cinterion: implement custom shared reset operation
Implemented for all QMI, MBIM and AT based modems. The parent reset operation always takes priority if available.
This commit is contained in:
@@ -441,30 +441,6 @@ messaging_check_support (MMIfaceModemMessaging *self,
|
||||
task);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Reset (Modem interface) */
|
||||
|
||||
static gboolean
|
||||
modem_reset_finish (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
return !!mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, error);
|
||||
}
|
||||
|
||||
static void
|
||||
modem_reset (MMIfaceModem *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
mm_base_modem_at_command (MM_BASE_MODEM (self),
|
||||
"+CFUN=1,1",
|
||||
3,
|
||||
FALSE,
|
||||
callback,
|
||||
user_data);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Power down */
|
||||
|
||||
@@ -2984,8 +2960,8 @@ iface_modem_init (MMIfaceModem *iface)
|
||||
iface->modem_after_sim_unlock_finish = after_sim_unlock_finish;
|
||||
iface->load_unlock_retries = load_unlock_retries;
|
||||
iface->load_unlock_retries_finish = load_unlock_retries_finish;
|
||||
iface->reset = modem_reset;
|
||||
iface->reset_finish = modem_reset_finish;
|
||||
iface->reset = mm_shared_cinterion_modem_reset;
|
||||
iface->reset_finish = mm_shared_cinterion_modem_reset_finish;
|
||||
iface->modem_power_down = modem_power_down;
|
||||
iface->modem_power_down_finish = modem_power_down_finish;
|
||||
iface->modem_power_off = modem_power_off;
|
||||
@@ -2994,6 +2970,12 @@ iface_modem_init (MMIfaceModem *iface)
|
||||
iface->setup_sim_hot_swap_finish = modem_setup_sim_hot_swap_finish;
|
||||
}
|
||||
|
||||
static MMIfaceModem *
|
||||
peek_parent_interface (MMSharedCinterion *self)
|
||||
{
|
||||
return iface_modem_parent;
|
||||
}
|
||||
|
||||
static void
|
||||
iface_modem_3gpp_init (MMIfaceModem3gpp *iface)
|
||||
{
|
||||
@@ -3091,6 +3073,7 @@ peek_parent_time_interface (MMSharedCinterion *self)
|
||||
static void
|
||||
shared_cinterion_init (MMSharedCinterion *iface)
|
||||
{
|
||||
iface->peek_parent_interface = peek_parent_interface;
|
||||
iface->peek_parent_location_interface = peek_parent_location_interface;
|
||||
iface->peek_parent_voice_interface = peek_parent_voice_interface;
|
||||
iface->peek_parent_time_interface = peek_parent_time_interface;
|
||||
|
||||
@@ -24,21 +24,25 @@
|
||||
#include "ModemManager.h"
|
||||
#include "mm-log.h"
|
||||
#include "mm-errors-types.h"
|
||||
#include "mm-iface-modem.h"
|
||||
#include "mm-iface-modem-location.h"
|
||||
#include "mm-iface-modem-voice.h"
|
||||
#include "mm-broadband-modem-mbim-cinterion.h"
|
||||
#include "mm-shared-cinterion.h"
|
||||
|
||||
static void iface_modem_init (MMIfaceModem *iface);
|
||||
static void iface_modem_location_init (MMIfaceModemLocation *iface);
|
||||
static void iface_modem_voice_init (MMIfaceModemVoice *iface);
|
||||
static void iface_modem_time_init (MMIfaceModemTime *iface);
|
||||
static void shared_cinterion_init (MMSharedCinterion *iface);
|
||||
|
||||
static MMIfaceModem *iface_modem_parent;
|
||||
static MMIfaceModemLocation *iface_modem_location_parent;
|
||||
static MMIfaceModemVoice *iface_modem_voice_parent;
|
||||
static MMIfaceModemTime *iface_modem_time_parent;
|
||||
|
||||
G_DEFINE_TYPE_EXTENDED (MMBroadbandModemMbimCinterion, mm_broadband_modem_mbim_cinterion, MM_TYPE_BROADBAND_MODEM_MBIM, 0,
|
||||
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM, iface_modem_init)
|
||||
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_LOCATION, iface_modem_location_init)
|
||||
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_VOICE, iface_modem_voice_init)
|
||||
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_TIME, iface_modem_time_init)
|
||||
@@ -72,6 +76,21 @@ mm_broadband_modem_mbim_cinterion_init (MMBroadbandModemMbimCinterion *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
iface_modem_init (MMIfaceModem *iface)
|
||||
{
|
||||
iface_modem_parent = g_type_interface_peek_parent (iface);
|
||||
|
||||
iface->reset = mm_shared_cinterion_modem_reset;
|
||||
iface->reset_finish = mm_shared_cinterion_modem_reset_finish;
|
||||
}
|
||||
|
||||
static MMIfaceModem *
|
||||
peek_parent_interface (MMSharedCinterion *self)
|
||||
{
|
||||
return iface_modem_parent;
|
||||
}
|
||||
|
||||
static void
|
||||
iface_modem_location_init (MMIfaceModemLocation *iface)
|
||||
{
|
||||
@@ -136,6 +155,7 @@ peek_parent_time_interface (MMSharedCinterion *self)
|
||||
static void
|
||||
shared_cinterion_init (MMSharedCinterion *iface)
|
||||
{
|
||||
iface->peek_parent_interface = peek_parent_interface;
|
||||
iface->peek_parent_location_interface = peek_parent_location_interface;
|
||||
iface->peek_parent_voice_interface = peek_parent_voice_interface;
|
||||
iface->peek_parent_time_interface = peek_parent_time_interface;
|
||||
|
||||
@@ -25,21 +25,25 @@
|
||||
#include "ModemManager.h"
|
||||
#include "mm-log.h"
|
||||
#include "mm-errors-types.h"
|
||||
#include "mm-iface-modem.h"
|
||||
#include "mm-iface-modem-location.h"
|
||||
#include "mm-iface-modem-voice.h"
|
||||
#include "mm-broadband-modem-qmi-cinterion.h"
|
||||
#include "mm-shared-cinterion.h"
|
||||
|
||||
static void iface_modem_init (MMIfaceModem *iface);
|
||||
static void iface_modem_location_init (MMIfaceModemLocation *iface);
|
||||
static void iface_modem_voice_init (MMIfaceModemVoice *iface);
|
||||
static void iface_modem_time_init (MMIfaceModemTime *iface);
|
||||
static void shared_cinterion_init (MMSharedCinterion *iface);
|
||||
|
||||
static MMIfaceModem *iface_modem_parent;
|
||||
static MMIfaceModemLocation *iface_modem_location_parent;
|
||||
static MMIfaceModemVoice *iface_modem_voice_parent;
|
||||
static MMIfaceModemTime *iface_modem_time_parent;
|
||||
|
||||
G_DEFINE_TYPE_EXTENDED (MMBroadbandModemQmiCinterion, mm_broadband_modem_qmi_cinterion, MM_TYPE_BROADBAND_MODEM_QMI, 0,
|
||||
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM, iface_modem_init)
|
||||
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_LOCATION, iface_modem_location_init)
|
||||
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_VOICE, iface_modem_voice_init)
|
||||
G_IMPLEMENT_INTERFACE (MM_TYPE_IFACE_MODEM_TIME, iface_modem_time_init)
|
||||
@@ -73,6 +77,21 @@ mm_broadband_modem_qmi_cinterion_init (MMBroadbandModemQmiCinterion *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
iface_modem_init (MMIfaceModem *iface)
|
||||
{
|
||||
iface_modem_parent = g_type_interface_peek_parent (iface);
|
||||
|
||||
iface->reset = mm_shared_cinterion_modem_reset;
|
||||
iface->reset_finish = mm_shared_cinterion_modem_reset_finish;
|
||||
}
|
||||
|
||||
static MMIfaceModem *
|
||||
peek_parent_interface (MMSharedCinterion *self)
|
||||
{
|
||||
return iface_modem_parent;
|
||||
}
|
||||
|
||||
static void
|
||||
iface_modem_location_init (MMIfaceModemLocation *iface)
|
||||
{
|
||||
@@ -137,6 +156,7 @@ peek_parent_time_interface (MMSharedCinterion *self)
|
||||
static void
|
||||
shared_cinterion_init (MMSharedCinterion *iface)
|
||||
{
|
||||
iface->peek_parent_interface = peek_parent_interface;
|
||||
iface->peek_parent_location_interface = peek_parent_location_interface;
|
||||
iface->peek_parent_voice_interface = peek_parent_voice_interface;
|
||||
iface->peek_parent_time_interface = peek_parent_time_interface;
|
||||
|
||||
@@ -44,6 +44,8 @@ typedef enum {
|
||||
} FeatureSupport;
|
||||
|
||||
typedef struct {
|
||||
/* modem */
|
||||
MMIfaceModem *iface_modem_parent;
|
||||
/* location */
|
||||
MMIfaceModemLocation *iface_modem_location_parent;
|
||||
MMModemLocationSource supported_sources;
|
||||
@@ -87,7 +89,11 @@ get_private (MMSharedCinterion *self)
|
||||
priv->slcc_regex = mm_cinterion_get_slcc_regex ();
|
||||
priv->ctzu_regex = mm_cinterion_get_ctzu_regex ();
|
||||
|
||||
/* Setup parent class' MMIfaceModemLocation, MMIfaceModemVoice and MMIfaceModemTime */
|
||||
/* Setup parent class' MMIfaceModem, MMIfaceModemLocation, MMIfaceModemVoice
|
||||
* and MMIfaceModemTime */
|
||||
|
||||
g_assert (MM_SHARED_CINTERION_GET_INTERFACE (self)->peek_parent_interface);
|
||||
priv->iface_modem_parent = MM_SHARED_CINTERION_GET_INTERFACE (self)->peek_parent_interface (self);
|
||||
|
||||
g_assert (MM_SHARED_CINTERION_GET_INTERFACE (self)->peek_parent_location_interface);
|
||||
priv->iface_modem_location_parent = MM_SHARED_CINTERION_GET_INTERFACE (self)->peek_parent_location_interface (self);
|
||||
@@ -104,6 +110,85 @@ get_private (MMSharedCinterion *self)
|
||||
return priv;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Modem interface */
|
||||
|
||||
gboolean
|
||||
mm_shared_cinterion_modem_reset_finish (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error)
|
||||
{
|
||||
return g_task_propagate_boolean (G_TASK (res), error);
|
||||
}
|
||||
|
||||
static void
|
||||
modem_reset_at_ready (MMBaseModem *self,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
if (!mm_base_modem_at_command_finish (self, res, &error))
|
||||
g_task_return_error (task, error);
|
||||
else
|
||||
g_task_return_boolean (task, TRUE);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static void
|
||||
modem_reset_at (GTask *task)
|
||||
{
|
||||
MMSharedCinterion *self;
|
||||
|
||||
self = g_task_get_source_object (task);
|
||||
|
||||
mm_base_modem_at_command (MM_BASE_MODEM (self),
|
||||
"+CFUN=1,1",
|
||||
3,
|
||||
FALSE,
|
||||
(GAsyncReadyCallback) modem_reset_at_ready,
|
||||
task);
|
||||
}
|
||||
|
||||
static void
|
||||
parent_modem_reset_ready (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GTask *task)
|
||||
{
|
||||
Private *priv;
|
||||
|
||||
priv = get_private (MM_SHARED_CINTERION (self));
|
||||
if (!priv->iface_modem_parent->reset_finish (self, res, NULL)) {
|
||||
modem_reset_at (task);
|
||||
return;
|
||||
}
|
||||
|
||||
g_task_return_boolean (task, TRUE);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
void
|
||||
mm_shared_cinterion_modem_reset (MMIfaceModem *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
GTask *task;
|
||||
Private *priv;
|
||||
|
||||
priv = get_private (MM_SHARED_CINTERION (self));
|
||||
task = g_task_new (self, NULL, callback, user_data);
|
||||
|
||||
if (priv->iface_modem_parent->reset &&
|
||||
priv->iface_modem_parent->reset_finish) {
|
||||
priv->iface_modem_parent->reset (self,
|
||||
(GAsyncReadyCallback) parent_modem_reset_ready,
|
||||
task);
|
||||
return;
|
||||
}
|
||||
|
||||
modem_reset_at (task);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* GPS trace received */
|
||||
|
||||
|
||||
@@ -40,6 +40,9 @@ typedef struct _MMSharedCinterion MMSharedCinterion;
|
||||
struct _MMSharedCinterion {
|
||||
GTypeInterface g_iface;
|
||||
|
||||
/* Peek modem interface of the parent class of the object */
|
||||
MMIfaceModem * (* peek_parent_interface) (MMSharedCinterion *self);
|
||||
|
||||
/* Peek location interface of the parent class of the object */
|
||||
MMIfaceModemLocation * (* peek_parent_location_interface) (MMSharedCinterion *self);
|
||||
|
||||
@@ -52,6 +55,16 @@ struct _MMSharedCinterion {
|
||||
|
||||
GType mm_shared_cinterion_get_type (void);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Modem interface */
|
||||
|
||||
void mm_shared_cinterion_modem_reset (MMIfaceModem *self,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
gboolean mm_shared_cinterion_modem_reset_finish (MMIfaceModem *self,
|
||||
GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Location interface */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user