gsm: fix initial PIN checking for devices that echo by default

If the modem echoed commands by	default (since we may not have
initialized the modem yet), the echoed command would confuse
the PIN check reply parser.
This commit is contained in:
Dan Williams
2010-02-09 23:44:23 -08:00
parent 95dd4b5be1
commit d8ea5ea003
3 changed files with 18 additions and 4 deletions

View File

@@ -203,8 +203,8 @@ pin_check_done (MMSerialPort *port,
if (error)
info->error = g_error_copy (error);
else if (g_str_has_prefix (response->str, "+CPIN: ")) {
const char *str = response->str + 7;
else if (response && strstr (response->str, "+CPIN: ")) {
const char *str = strstr (response->str, "+CPIN: ") + 7;
if (g_str_has_prefix (str, "READY")) {
mm_modem_base_set_unlock_required (MM_MODEM_BASE (info->modem), NULL);
@@ -328,7 +328,9 @@ initial_pin_check_done (MMModem *modem, GError *error, gpointer user_data)
g_return_if_fail (MM_IS_GENERIC_GSM (modem));
priv = MM_GENERIC_GSM_GET_PRIVATE (modem);
if (error && priv->pin_check_tries++ < 3) {
if ( error
&& priv->pin_check_tries++ < 3
&& !mm_modem_base_get_unlock_required (MM_MODEM_BASE (modem))) {
/* Try it again a few times */
if (priv->pin_check_timeout)
g_source_remove (priv->pin_check_timeout);

View File

@@ -170,7 +170,17 @@ mm_modem_base_get_valid (MMModemBase *self)
return MM_MODEM_BASE_GET_PRIVATE (self)->valid;
}
void mm_modem_base_set_unlock_required (MMModemBase *self, const char *unlock_required)
const char *
mm_modem_base_get_unlock_required (MMModemBase *self)
{
g_return_val_if_fail (self != NULL, NULL);
g_return_val_if_fail (MM_IS_MODEM_BASE (self), NULL);
return MM_MODEM_BASE_GET_PRIVATE (self)->unlock_required;
}
void
mm_modem_base_set_unlock_required (MMModemBase *self, const char *unlock_required)
{
MMModemBasePrivate *priv;
const char *dbus_path;

View File

@@ -60,6 +60,8 @@ void mm_modem_base_set_valid (MMModemBase *self,
gboolean mm_modem_base_get_valid (MMModemBase *self);
const char *mm_modem_base_get_unlock_required (MMModemBase *self);
void mm_modem_base_set_unlock_required (MMModemBase *self,
const char *unlock_required);