From 488baa13302c6d1e839db6afc9fed088e9d5dbba Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Fri, 11 Dec 2009 13:19:21 -0800 Subject: [PATCH] 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. --- plugins/mm-modem-mbm.c | 36 +++++++++++++++++++++++++++++------- 1 file 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