pantech: skip WMC ports

WMC ports will return "ERROR" to all AT commands, except for "AT" itself. So
just provide a custom AT probing logic, which uses "ATE0" instead, and assumes
the port is not an AT port if an error is returned.
This commit is contained in:
Aleksander Morgado
2013-04-02 17:41:54 +02:00
parent 678f596ff9
commit 9ffb424ed4
+41
View File
@@ -32,6 +32,46 @@ G_DEFINE_TYPE (MMPluginPantech, mm_plugin_pantech, MM_TYPE_PLUGIN)
int mm_plugin_major_version = MM_PLUGIN_MAJOR_VERSION;
int mm_plugin_minor_version = MM_PLUGIN_MINOR_VERSION;
/*****************************************************************************/
/* Custom commands for AT probing
* There's currently no WMC probing plugged in the logic, so We need to detect
* WMC ports ourselves somehow. Just assume that the WMC port will reply "ERROR"
* to the "ATE0" command.
*/
static gboolean
port_probe_response_processor_is_pantech_at (const gchar *command,
const gchar *response,
gboolean last_command,
const GError *error,
GVariant **result,
GError **result_error)
{
if (error) {
/* Timeout errors are the only ones not fatal;
* they will just go on to the next command. */
if (g_error_matches (error,
MM_SERIAL_ERROR,
MM_SERIAL_ERROR_RESPONSE_TIMEOUT)) {
return FALSE;
}
/* All other errors indicate NOT an AT port */
*result = g_variant_new_boolean (FALSE);
return TRUE;
}
/* No error reported, valid AT port! */
*result = g_variant_new_boolean (TRUE);
return TRUE;
}
static const MMPortProbeAtCommand custom_at_probe[] = {
{ "ATE0", 3, port_probe_response_processor_is_pantech_at },
{ "ATE0", 3, port_probe_response_processor_is_pantech_at },
{ "ATE0", 3, port_probe_response_processor_is_pantech_at },
{ NULL }
};
/*****************************************************************************/
static MMBaseModem *
@@ -102,6 +142,7 @@ mm_plugin_create (void)
MM_PLUGIN_ALLOWED_AT, TRUE,
MM_PLUGIN_ALLOWED_QCDM, TRUE,
MM_PLUGIN_ALLOWED_QMI, TRUE,
MM_PLUGIN_CUSTOM_AT_PROBE, custom_at_probe,
NULL));
}