aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/sierra/mm-broadband-modem-sierra-icera.c4
-rw-r--r--plugins/sierra/mm-broadband-modem-sierra.c4
-rw-r--r--plugins/sierra/mm-common-sierra.c134
-rw-r--r--plugins/sierra/mm-common-sierra.h9
4 files changed, 98 insertions, 53 deletions
diff --git a/plugins/sierra/mm-broadband-modem-sierra-icera.c b/plugins/sierra/mm-broadband-modem-sierra-icera.c
index 42b11f5d..d9a4e400 100644
--- a/plugins/sierra/mm-broadband-modem-sierra-icera.c
+++ b/plugins/sierra/mm-broadband-modem-sierra-icera.c
@@ -130,6 +130,10 @@ mm_broadband_modem_sierra_icera_init (MMBroadbandModemSierraIcera *self)
static void
iface_modem_init (MMIfaceModem *iface)
{
+ mm_common_sierra_peek_parent_interfaces (iface);
+
+ iface->load_power_state = mm_common_sierra_load_power_state;
+ iface->load_power_state_finish = mm_common_sierra_load_power_state_finish;
iface->modem_power_up = mm_common_sierra_modem_power_up;
iface->modem_power_up_finish = mm_common_sierra_modem_power_up_finish;
iface->create_sim = mm_common_sierra_create_sim;
diff --git a/plugins/sierra/mm-broadband-modem-sierra.c b/plugins/sierra/mm-broadband-modem-sierra.c
index a9fa95a5..4c64e5b0 100644
--- a/plugins/sierra/mm-broadband-modem-sierra.c
+++ b/plugins/sierra/mm-broadband-modem-sierra.c
@@ -1153,6 +1153,8 @@ mm_broadband_modem_sierra_init (MMBroadbandModemSierra *self)
static void
iface_modem_init (MMIfaceModem *iface)
{
+ mm_common_sierra_peek_parent_interfaces (iface);
+
iface->load_allowed_modes = load_allowed_modes;
iface->load_allowed_modes_finish = load_allowed_modes_finish;
iface->set_allowed_modes = set_allowed_modes;
@@ -1161,6 +1163,8 @@ iface_modem_init (MMIfaceModem *iface)
iface->load_access_technologies_finish = load_access_technologies_finish;
iface->reset = modem_reset;
iface->reset_finish = modem_reset_finish;
+ iface->load_power_state = mm_common_sierra_load_power_state;
+ iface->load_power_state_finish = mm_common_sierra_load_power_state_finish;
iface->modem_power_up = mm_common_sierra_modem_power_up;
iface->modem_power_up_finish = mm_common_sierra_modem_power_up_finish;
iface->modem_init_power_down = modem_power_down;
diff --git a/plugins/sierra/mm-common-sierra.c b/plugins/sierra/mm-common-sierra.c
index d0bde95c..1cef0e8f 100644
--- a/plugins/sierra/mm-common-sierra.c
+++ b/plugins/sierra/mm-common-sierra.c
@@ -21,6 +21,8 @@
#include "mm-modem-helpers.h"
#include "mm-sim-sierra.h"
+static MMIfaceModem *iface_modem_parent;
+
/*****************************************************************************/
/* Modem power up (Modem interface) */
@@ -42,9 +44,9 @@ sierra_power_up_wait_cb (GSimpleAsyncResult *result)
}
static void
-full_functionality_status_ready (MMBaseModem *self,
- GAsyncResult *res,
- GSimpleAsyncResult *simple)
+cfun_enable_ready (MMBaseModem *self,
+ GAsyncResult *res,
+ GSimpleAsyncResult *simple)
{
GError *error = NULL;
guint i;
@@ -79,52 +81,6 @@ full_functionality_status_ready (MMBaseModem *self,
}
static void
-get_current_functionality_status_ready (MMBaseModem *self,
- GAsyncResult *res,
- GSimpleAsyncResult *simple)
-{
- const gchar *response;
- GError *error = NULL;
-
- response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error);
- if (!response) {
- mm_warn ("Failed checking if power-up command is needed: '%s'. "
- "Will assume it isn't.",
- error->message);
- g_error_free (error);
- /* On error, just assume we don't need the power-up command */
- g_simple_async_result_set_op_res_gboolean (simple, TRUE);
- g_simple_async_result_complete (simple);
- g_object_unref (simple);
- return;
- }
-
- response = mm_strip_tag (response, "+CFUN:");
- if (response && *response == '1') {
- /* If reported functionality status is '1', then we do not need to
- * issue the power-up command. Otherwise, do it. */
- mm_dbg ("Already in full functionality status, skipping power-up command");
- g_simple_async_result_set_op_res_gboolean (simple, TRUE);
- g_simple_async_result_complete (simple);
- g_object_unref (simple);
- return;
- }
-
- mm_warn ("Not in full functionality status, power-up command is needed. "
- "Note that it may reboot the modem.");
-
- /* Try to go to full functionality mode without rebooting the system.
- * Works well if we previously switched off the power with CFUN=4
- */
- mm_base_modem_at_command (MM_BASE_MODEM (self),
- "+CFUN=1,0", /* ",0" ensures no reset */
- 10,
- FALSE,
- (GAsyncReadyCallback)full_functionality_status_ready,
- simple);
-}
-
-static void
pcstate_enable_ready (MMBaseModem *self,
GAsyncResult *res,
GSimpleAsyncResult *simple)
@@ -162,16 +118,80 @@ mm_common_sierra_modem_power_up (MMIfaceModem *self,
return;
}
- /* For 3GPP modems, check if we'll need the power up */
+ mm_warn ("Not in full functionality status, power-up command is needed. "
+ "Note that it may reboot the modem.");
+
+ /* Try to go to full functionality mode without rebooting the system.
+ * Works well if we previously switched off the power with CFUN=4
+ */
mm_base_modem_at_command (MM_BASE_MODEM (self),
- "+CFUN?",
- 3,
+ "+CFUN=1,0", /* ",0" requests no reset */
+ 10,
FALSE,
- (GAsyncReadyCallback)get_current_functionality_status_ready,
+ (GAsyncReadyCallback)cfun_enable_ready,
result);
}
/*****************************************************************************/
+/* Power state loading (Modem interface) */
+
+MMModemPowerState
+mm_common_sierra_load_power_state_finish (MMIfaceModem *self,
+ GAsyncResult *res,
+ GError **error)
+{
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error))
+ return MM_MODEM_POWER_STATE_UNKNOWN;
+
+ return (MMModemPowerState)GPOINTER_TO_UINT (g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (res)));
+}
+
+static void
+parent_load_power_state_ready (MMIfaceModem *self,
+ GAsyncResult *res,
+ GSimpleAsyncResult *simple)
+{
+ GError *error = NULL;
+ MMModemPowerState state;
+
+ state = iface_modem_parent->load_power_state_finish (self, res, &error);
+ if (error)
+ g_simple_async_result_take_error (simple, error);
+ else
+ g_simple_async_result_set_op_res_gpointer (simple, GUINT_TO_POINTER (state), NULL);
+ g_simple_async_result_complete (simple);
+ g_object_unref (simple);
+}
+
+void
+mm_common_sierra_load_power_state (MMIfaceModem *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data)
+{
+ GSimpleAsyncResult *result;
+
+ result = g_simple_async_result_new (G_OBJECT (self),
+ callback,
+ user_data,
+ mm_common_sierra_load_power_state);
+
+ /* Assume we're initially offline in CDMA-only modems so that we power-up
+ * with !pcstate */
+ if (mm_iface_modem_is_cdma_only (self)) {
+ mm_dbg ("Assuming offline in CDMA-only modem...");
+ g_simple_async_result_set_op_res_gpointer (result, GUINT_TO_POINTER (MM_MODEM_POWER_STATE_OFF), NULL);
+ g_simple_async_result_complete_in_idle (result);
+ g_object_unref (result);
+ return;
+ }
+
+ /* Otherwise run parent's */
+ iface_modem_parent->load_power_state (self,
+ (GAsyncReadyCallback)parent_load_power_state_ready,
+ result);
+}
+
+/*****************************************************************************/
/* Create SIM (Modem interface) */
MMSim *
@@ -234,3 +254,11 @@ mm_common_sierra_setup_ports (MMBroadbandModem *self)
g_regex_unref (pacsp_regex);
}
+
+/*****************************************************************************/
+
+void
+mm_common_sierra_peek_parent_interfaces (MMIfaceModem *iface)
+{
+ iface_modem_parent = g_type_interface_peek_parent (iface);
+}
diff --git a/plugins/sierra/mm-common-sierra.h b/plugins/sierra/mm-common-sierra.h
index 9725652b..a82f87a0 100644
--- a/plugins/sierra/mm-common-sierra.h
+++ b/plugins/sierra/mm-common-sierra.h
@@ -21,6 +21,13 @@
#include "mm-broadband-modem.h"
#include "mm-iface-modem.h"
+void mm_common_sierra_load_power_state (MMIfaceModem *self,
+ GAsyncReadyCallback callback,
+ gpointer user_data);
+MMModemPowerState mm_common_sierra_load_power_state_finish (MMIfaceModem *self,
+ GAsyncResult *res,
+ GError **error);
+
void mm_common_sierra_modem_power_up (MMIfaceModem *self,
GAsyncReadyCallback callback,
gpointer user_data);
@@ -37,4 +44,6 @@ MMSim *mm_common_sierra_create_sim_finish (MMIfaceModem *self,
void mm_common_sierra_setup_ports (MMBroadbandModem *self);
+void mm_common_sierra_peek_parent_interfaces (MMIfaceModem *iface);
+
#endif /* MM_COMMON_SIERRA_H */