aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2011-06-21 14:39:23 +0200
committerAleksander Morgado <aleksander@lanedo.com>2011-06-22 13:11:38 +0200
commit255525a5a2d499ef7b4d01cea660502bd1dff6a5 (patch)
tree5fc63b3a9988e57018ab9dc1fd47d0e7bd7b4ffc
parent6e9d980e8c29974f9b641a1f6bc3be5212500901 (diff)
wavecom: do not send power-up command if not needed
-rw-r--r--plugins/mm-modem-wavecom-gsm.c104
1 files changed, 63 insertions, 41 deletions
diff --git a/plugins/mm-modem-wavecom-gsm.c b/plugins/mm-modem-wavecom-gsm.c
index c66637cf..652511a0 100644
--- a/plugins/mm-modem-wavecom-gsm.c
+++ b/plugins/mm-modem-wavecom-gsm.c
@@ -869,7 +869,7 @@ set_highest_ms_class_cb (MMAtSerialPort *port,
}
/* All done without errors! */
- mm_dbg ("[5/5] All done");
+ mm_dbg ("[4/4] All done");
enable_complete (MM_GENERIC_GSM (info->modem), NULL, info);
}
@@ -975,7 +975,7 @@ get_current_ms_class_cb (MMAtSerialPort *port,
}
/* Next, set highest mobile station class possible */
- mm_dbg ("[4/5] Ensuring highest MS class...");
+ mm_dbg ("[3/4] Ensuring highest MS class...");
set_highest_ms_class (port, info);
}
@@ -1039,19 +1039,18 @@ get_supported_ms_classes_cb (MMAtSerialPort *port,
}
/* Next, query for current MS class */
- mm_dbg ("[3/5] Getting current MS class...");
+ mm_dbg ("[2/4] Getting current MS class...");
mm_at_serial_port_queue_command (port, "+CGCLASS?", 3, get_current_ms_class_cb, info);
}
static void
-get_current_functionality_status_cb (MMAtSerialPort *port,
- GString *response,
- GError *error,
- gpointer user_data)
+do_enable_power_up_done (MMGenericGsm *gsm,
+ GString *response,
+ GError *error,
+ MMCallbackInfo *info)
{
- MMCallbackInfo *info = user_data;
- const gchar *p;
- GError *inner_error;
+ MMAtSerialPort *port;
+ GError *inner_error = NULL;
/* If the modem has already been removed, return without
* scheduling callback */
@@ -1059,57 +1058,79 @@ get_current_functionality_status_cb (MMAtSerialPort *port,
return;
if (error) {
- enable_complete (MM_GENERIC_GSM (info->modem), error, info);
+ enable_complete (gsm, error, info);
return;
}
- p = mm_strip_tag (response->str, "+CFUN:");
- if (!p || *p != '1') {
- /* Reported functionality status MUST be '1'. Otherwise, RF is probably
- * switched off. */
- inner_error = g_error_new (MM_MODEM_ERROR,
- MM_MODEM_ERROR_GENERAL,
- "Unexpected functionality status: '%c'. ",
- p ? *p :' ');
- enable_complete (MM_GENERIC_GSM (info->modem), inner_error, info);
+ /* Get port */
+ port = mm_generic_gsm_get_best_at_port (gsm, &inner_error);
+ if (!port) {
+ enable_complete (gsm, inner_error, info);
g_error_free (inner_error);
+ return;
}
- /* Nex, query for supported MS classes */
- mm_dbg ("[2/5] Getting supported MS classes...");
+ mm_dbg ("[1/4] Getting supported MS classes...");
mm_at_serial_port_queue_command (port, "+CGCLASS=?", 3, get_supported_ms_classes_cb, info);
}
static void
-do_enable_power_up_done (MMGenericGsm *gsm,
- GString *response,
- GError *error,
- MMCallbackInfo *info)
+get_current_functionality_status_cb (MMAtSerialPort *port,
+ GString *response,
+ GError *error,
+ gpointer user_data)
{
- MMAtSerialPort *port;
- GError *inner_error = NULL;
+ MMCallbackInfo *info = user_data;
+ guint needed = FALSE;
/* If the modem has already been removed, return without
* scheduling callback */
if (mm_callback_info_check_modem_removed (info))
return;
- if (error) {
- enable_complete (gsm, error, info);
- return;
- }
+ /* On error, just assume we don't need the power-up command */
+ if (!error) {
+ const gchar *p;
+
+ p = mm_strip_tag (response->str, "+CFUN:");
+ if (p && *p == '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");
+ } else {
+ needed = TRUE;
+ mm_warn ("Not in full functionality status, power-up command is needed. "
+ "Note that it may reboot the modem.");
+ }
+ } else
+ mm_warn ("Failed checking if power-up command is needed: '%s'. "
+ "Will assume it isn't.",
+ error->message);
+
+ /* Set result and schedule */
+ mm_callback_info_set_result (info,
+ GUINT_TO_POINTER (needed),
+ NULL);
+ mm_callback_info_schedule (info);
+}
+
+static void
+do_enable_power_up_check_needed (MMGenericGsm *self,
+ MMModemUIntFn callback,
+ gpointer user_data)
+{
+ MMAtSerialPort *primary;
+ MMCallbackInfo *info;
+
+ info = mm_callback_info_uint_new (MM_MODEM (self), callback, user_data);
/* Get port */
- port = mm_generic_gsm_get_best_at_port (gsm, &inner_error);
- if (!port) {
- enable_complete (gsm, inner_error, info);
- g_error_free (inner_error);
- return;
- }
+ primary = mm_generic_gsm_get_at_port (self, MM_PORT_TYPE_PRIMARY);
+ g_assert (primary);
- /* Next, get current functionality status */
- mm_dbg ("[1/5] Getting current functionality status...");
- mm_at_serial_port_queue_command (port, "+CFUN?", 3, get_current_functionality_status_cb, info);
+ /* Get current functionality status */
+ mm_dbg ("Getting current functionality status...");
+ mm_at_serial_port_queue_command (primary, "+CFUN?", 3, get_current_functionality_status_cb, info);
}
/*****************************************************************************/
@@ -1158,6 +1179,7 @@ mm_modem_wavecom_gsm_class_init (MMModemWavecomGsmClass *klass)
MM_GENERIC_GSM_PROP_FLOW_CONTROL_CMD,
MM_GENERIC_GSM_FLOW_CONTROL_CMD);
+ gsm_class->do_enable_power_up_check_needed = do_enable_power_up_check_needed;
gsm_class->do_enable_power_up_done = do_enable_power_up_done;
gsm_class->set_allowed_mode = set_allowed_mode;
gsm_class->get_allowed_mode = get_allowed_mode;