base-modem: don't run port init sequence if we're just sending a command

This may happen when sending commands to the modem while in non-enabled state,
like when sending the PIN. In this case, just send the command, don't fully
initialize the port with the initialization sequence.
This commit is contained in:
Aleksander Morgado
2013-02-18 16:06:01 +01:00
parent 7a58647af7
commit d593116d68

View File

@@ -28,6 +28,7 @@ abort_async_if_port_unusable (MMBaseModem *self,
gpointer user_data)
{
GError *error = NULL;
gboolean init_sequence_enabled = FALSE;
/* If no port given, probably the port dissapeared */
if (!port) {
@@ -53,6 +54,11 @@ abort_async_if_port_unusable (MMBaseModem *self,
return FALSE;
}
/* Temporarily disable init sequence if we're just sending a
* command to a just opened port */
g_object_get (port, MM_AT_SERIAL_PORT_INIT_SEQUENCE_ENABLED, &init_sequence_enabled, NULL);
g_object_set (port, MM_AT_SERIAL_PORT_INIT_SEQUENCE_ENABLED, FALSE, NULL);
/* Ensure we have a port open during the sequence */
if (!mm_serial_port_open (MM_SERIAL_PORT (port), &error)) {
g_simple_async_report_error_in_idle (
@@ -67,6 +73,9 @@ abort_async_if_port_unusable (MMBaseModem *self,
return FALSE;
}
/* Reset previous init sequence state */
g_object_set (port, MM_AT_SERIAL_PORT_INIT_SEQUENCE_ENABLED, init_sequence_enabled, NULL);
return TRUE;
}