aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2009-12-11 13:19:21 -0800
committerDan Williams <dcbw@redhat.com>2009-12-11 13:19:21 -0800
commit488baa13302c6d1e839db6afc9fed088e9d5dbba (patch)
tree36ec6ac28c0101e25038982921a6a5fdac2f933d
parenteaf167bebdc24c992b0a7b130432064eb5c537b7 (diff)
mbm: ensure various unsolicited responses are turned off when disabling
If the modem wasn't connected when disable is called, the generic GSM code doesn't need to shut anything down and thus closes the serial port immediately. That means the mbm plugin's CREG=0 and CMER=0 won't get sent because the port is closed. mbm needs to ensure that it's commands actually get sent to the modem by really sending them and waiting for the response before chaining up to the parent's disable.
-rw-r--r--plugins/mm-modem-mbm.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/plugins/mm-modem-mbm.c b/plugins/mm-modem-mbm.c
index 386409ab..686b35ce 100644
--- a/plugins/mm-modem-mbm.c
+++ b/plugins/mm-modem-mbm.c
@@ -407,23 +407,45 @@ do_enable (MMGenericGsm *self, MMModemFn callback, gpointer user_data)
mm_serial_port_queue_command (primary, "*EMRDY?", 5, mbm_emrdy_done, info);
}
+typedef struct {
+ MMModem *modem;
+ MMModemFn callback;
+ gpointer user_data;
+} DisableInfo;
+
+static void
+disable_creg_cmer_done (MMSerialPort *port,
+ GString *response,
+ GError *error,
+ gpointer user_data)
+
+{
+ MMModem *parent_modem_iface;
+ DisableInfo *info = user_data;
+
+ parent_modem_iface = g_type_interface_peek_parent (MM_MODEM_GET_INTERFACE (info->modem));
+ parent_modem_iface->disable (info->modem, info->callback, info->user_data);
+ g_free (info);
+}
+
static void
disable (MMModem *modem,
MMModemFn callback,
gpointer user_data)
{
- MMModem *parent_modem_iface;
MMSerialPort *primary;
+ DisableInfo *info;
+
+ info = g_malloc0 (sizeof (DisableInfo));
+ info->callback = callback;
+ info->user_data = user_data;
+ info->modem = modem;
primary = mm_generic_gsm_get_port (MM_GENERIC_GSM (modem), MM_PORT_TYPE_PRIMARY);
g_assert (primary);
- /* Random stuff that mbm apparently wants. Are these really needed? */
- mm_serial_port_queue_command (primary, "+CREG=0", 5, NULL, NULL);
- mm_serial_port_queue_command (primary, "+CMER=0", 5, NULL, NULL);
-
- parent_modem_iface = g_type_interface_peek_parent (MM_MODEM_GET_INTERFACE (modem));
- parent_modem_iface->disable (modem, callback, user_data);
+ /* Turn off unsolicited +CIEV signal strength indicator */
+ mm_serial_port_queue_command (primary, "+CREG=0;+CMER=0", 5, disable_creg_cmer_done, info);
}
static void