diff options
author | Dan Williams <dcbw@redhat.com> | 2011-06-05 20:23:51 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2011-06-05 20:58:18 -0500 |
commit | 1936979f112f81ca7acad1e1512ca940502d25b5 (patch) | |
tree | dfe629f3d6aa82c4d69ae60e61cc8dfef55a5297 /plugins | |
parent | b122938ab5fb6ff5be1d4575abb0ca81d2885ce3 (diff) |
longcheer: ensure the Alcatel X200 is not claimed
The X200 shares the same USB VID and PID as the X060s but the X200
does not use the same AT command set; it uses the X22X plugin
instead. Since both modems also report the same +GMM and +GMI
responses, we have to fall back to using +GMR even though that's
a pretty sketchy way to tell them apart if the firmware ever changes.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mm-plugin-longcheer.c | 54 |
1 files changed, 52 insertions, 2 deletions
diff --git a/plugins/mm-plugin-longcheer.c b/plugins/mm-plugin-longcheer.c index f90a8439..5f773a36 100644 --- a/plugins/mm-plugin-longcheer.c +++ b/plugins/mm-plugin-longcheer.c @@ -20,6 +20,7 @@ #include "mm-modem-longcheer-gsm.h" #include "mm-generic-gsm.h" #include "mm-generic-cdma.h" +#include "mm-modem-helpers.h" G_DEFINE_TYPE (MMPluginLongcheer, mm_plugin_longcheer, MM_TYPE_PLUGIN_BASE) @@ -62,6 +63,38 @@ probe_result (MMPluginBase *base, mm_plugin_base_supports_task_complete (task, get_level_for_capabilities (capabilities)); } +static gboolean +custom_init_response_cb (MMPluginBaseSupportsTask *task, + GString *response, + GError *error, + guint32 tries, + gboolean *out_stop, + guint32 *out_level, + gpointer user_data) +{ + const char *p = response->str; + + if (error) + return tries <= 4 ? TRUE : FALSE; + + /* Note the lack of a ':' on the GMR; the X200 doesn't send one */ + p = mm_strip_tag (response->str, "AT+GMR"); + if (*p == 'L') { + /* X200 modems have a GMR firmware revision that starts with 'L', and + * as far as I can tell X060s devices have a revision starting with 'C'. + * So use that to determine if the device is an X200, which this plugin + * does not support since it uses a different chipset even though the + * X060s and the X200 have the exact same USB VID and PID. + */ + *out_level = 0; + *out_stop = TRUE; + return FALSE; + } + + /* Continue with generic probing */ + return FALSE; +} + static MMPluginSupportsResult supports_port (MMPluginBase *base, MMModem *existing, @@ -69,7 +102,7 @@ supports_port (MMPluginBase *base, { GUdevDevice *port; guint32 cached = 0, level; - guint16 vendor = 0; + guint16 vendor = 0, product = 0; const char *subsys, *name; /* Can't do anything with non-serial ports */ @@ -80,7 +113,7 @@ supports_port (MMPluginBase *base, subsys = g_udev_device_get_subsystem (port); name = g_udev_device_get_name (port); - if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, NULL)) + if (!mm_plugin_base_get_device_ids (base, subsys, name, &vendor, &product)) return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED; /* Longcheer and TAMobile */ @@ -102,6 +135,23 @@ supports_port (MMPluginBase *base, return MM_PLUGIN_SUPPORTS_PORT_UNSUPPORTED; } + /* TCT/Alcatel in their infinite wisdom assigned the same USB VID/PID to + * the x060s (Longcheer firmware) and the x200 (something else) and thus + * we can't tell them apart via udev rules. Worse, they both report the + * same +GMM and +GMI, so we're left with just +GMR which is a sketchy way + * to tell modems apart. We can't really use Longcheer-specific commands + * like AT+MODODR or AT+PSRAT because we're not sure if they work when the + * SIM PIN has not been entered yet; many modems have a limited command + * parser before the SIM is unlocked. + */ + if (vendor == 0x1bbb && product == 0x0000) { + mm_plugin_base_supports_task_add_custom_init_command (task, + "AT+GMR", + 3, + custom_init_response_cb, + NULL); + } + /* Otherwise kick off a probe */ if (mm_plugin_base_probe_port (base, task, 100000, NULL)) return MM_PLUGIN_SUPPORTS_PORT_IN_PROGRESS; |