aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@lanedo.com>2011-06-21 12:54:09 +0200
committerAleksander Morgado <aleksander@lanedo.com>2011-06-22 13:08:53 +0200
commit6e9d980e8c29974f9b641a1f6bc3be5212500901 (patch)
tree0d5e1e303bd93ca3d798edf42bd7aec1ad2f282d /src
parent895f0f2ea3868091baefa897d88a6fbc3a0ca897 (diff)
gsm: allow plugins to check if they need to issue the power-up command
Some modems only like the power-up command if not already in full functionality mode. If the power-up is sent while already in full functionality mode, they get rebooted and reseted. With this changes, plugins can check whether they need the power-up and ask the generic gsm code base to skip the command or not. By default, power-up command (if any given) is never skipped.
Diffstat (limited to 'src')
-rw-r--r--src/mm-generic-gsm.c34
-rw-r--r--src/mm-generic-gsm.h11
2 files changed, 38 insertions, 7 deletions
diff --git a/src/mm-generic-gsm.c b/src/mm-generic-gsm.c
index d814c57c..34ab8233 100644
--- a/src/mm-generic-gsm.c
+++ b/src/mm-generic-gsm.c
@@ -1541,6 +1541,27 @@ enable_done (MMAtSerialPort *port,
}
static void
+enable_power_up_check_needed_done (MMModem *self,
+ guint32 needed,
+ GError *error,
+ gpointer user_data)
+{
+ MMGenericGsmPrivate *priv = MM_GENERIC_GSM_GET_PRIVATE (self);
+ char *cmd = NULL;
+
+ if (needed)
+ g_object_get (G_OBJECT (self), MM_GENERIC_GSM_POWER_UP_CMD, &cmd, NULL);
+ else
+ mm_dbg ("Power-up not needed, skipping...");
+
+ if (cmd && strlen (cmd))
+ mm_at_serial_port_queue_command (MM_AT_SERIAL_PORT (priv->primary), cmd, 5, enable_done, user_data);
+ else
+ enable_done (MM_AT_SERIAL_PORT (priv->primary), NULL, NULL, user_data);
+ g_free (cmd);
+}
+
+static void
init_done (MMAtSerialPort *port,
GString *response,
GError *error,
@@ -1573,12 +1594,13 @@ init_done (MMAtSerialPort *port,
mm_at_serial_port_queue_command (port, cmd, 2, NULL, NULL);
g_free (cmd);
- g_object_get (G_OBJECT (info->modem), MM_GENERIC_GSM_POWER_UP_CMD, &cmd, NULL);
- if (cmd && strlen (cmd))
- mm_at_serial_port_queue_command (port, cmd, 5, enable_done, user_data);
+ /* Plugins can now check if they need the power up command or not */
+ if (MM_GENERIC_GSM_GET_CLASS (info->modem)->do_enable_power_up_check_needed)
+ MM_GENERIC_GSM_GET_CLASS (info->modem)->do_enable_power_up_check_needed (MM_GENERIC_GSM (info->modem),
+ enable_power_up_check_needed_done,
+ info);
else
- enable_done (port, NULL, NULL, user_data);
- g_free (cmd);
+ enable_power_up_check_needed_done (info->modem, TRUE, NULL, info);
}
static void
@@ -4875,7 +4897,7 @@ ussd_send_done (MMAtSerialPort *port,
ussd_update_state (MM_GENERIC_GSM (info->modem), MM_MODEM_GSM_USSD_STATE_IDLE);
}
- /* Otherwise if no error wait for the response to show up via the
+ /* Otherwise if no error wait for the response to show up via the
* unsolicited response code.
*/
}
diff --git a/src/mm-generic-gsm.h b/src/mm-generic-gsm.h
index 57b65bf8..73a03ad2 100644
--- a/src/mm-generic-gsm.h
+++ b/src/mm-generic-gsm.h
@@ -90,7 +90,15 @@ typedef struct {
* encountered during the process and the MMCallbackInfo created from the
* callback and user_data passed in here.
*/
- void (*do_enable) (MMGenericGsm *self, MMModemFn callback, gpointer user_data);
+ void (*do_enable) (MMGenericGsm *self,
+ MMModemFn callback,
+ gpointer user_data);
+
+ /* Called before issuing the power-up command, to check whether it should
+ * really be issued or not. */
+ void (*do_enable_power_up_check_needed) (MMGenericGsm *self,
+ MMModemUIntFn callback,
+ gpointer user_data);
/* Called after the generic class has attempted to power up the modem.
* Subclasses can handle errors here if they know the device supports their
@@ -143,6 +151,7 @@ typedef struct {
void (*get_sim_iccid) (MMGenericGsm *self,
MMModemStringFn callback,
gpointer user_data);
+
} MMGenericGsmClass;
GType mm_generic_gsm_get_type (void);