diff options
author | Dan Williams <dcbw@redhat.com> | 2011-08-14 16:02:41 -0500 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2011-08-14 16:02:41 -0500 |
commit | 8799f4da1fdf0f0cad36dc6de68e3c35cc8177ae (patch) | |
tree | c38ebe12a3d8f67968057ee01a6dd3429c1907ac | |
parent | 8ea17921e736d56f7d758f2f885326ea49e495d7 (diff) |
core: when probing mark ports as AT capable too
On a ZTE MF626, sometimes the aux port will respond only with
"ERROR" to probing commands (while the SIM is starting up) and
previously we'd lose the port because we were only looking for
valid probe responses. But if the port returns ERROR or CME ERROR
etc we know it's an AT port and that we can use it once we've
gotten the type response (CDMA or GSM) from the main port.
-rw-r--r-- | plugins/mm-plugin-zte.c | 2 | ||||
-rw-r--r-- | src/mm-plugin-base.c | 24 | ||||
-rw-r--r-- | src/mm-plugin-base.h | 1 |
3 files changed, 19 insertions, 8 deletions
diff --git a/plugins/mm-plugin-zte.c b/plugins/mm-plugin-zte.c index 4d8107e4..6329c3ab 100644 --- a/plugins/mm-plugin-zte.c +++ b/plugins/mm-plugin-zte.c @@ -49,6 +49,8 @@ get_level_for_capabilities (guint32 capabilities) return 10; if (capabilities & MM_PLUGIN_BASE_PORT_CAP_QCDM) return 10; + if (capabilities & MM_PLUGIN_BASE_PORT_CAP_AT) + return 10; return 0; } diff --git a/src/mm-plugin-base.c b/src/mm-plugin-base.c index 6c5658c4..01fe9c5d 100644 --- a/src/mm-plugin-base.c +++ b/src/mm-plugin-base.c @@ -716,15 +716,20 @@ real_handle_probe_response (MMPluginBase *self, { MMPluginBaseSupportsTaskPrivate *task_priv = MM_PLUGIN_BASE_SUPPORTS_TASK_GET_PRIVATE (task); MMAtSerialPort *port = task_priv->probe_port; - gboolean ignore_error = FALSE; /* Some modems (Huawei E160g) won't respond to +GCAP with no SIM, but - * will respond to ATI. + * will respond to ATI. Ignore the error and continue. */ - if (response && strstr (response, "+CME ERROR:")) - ignore_error = TRUE; + if (response && strstr (response, "+CME ERROR:")) { + task_priv->probed_caps |= MM_PLUGIN_BASE_PORT_CAP_AT; + error = NULL; + } + + if (error) { + /* If the modem returned a recognizable error, it can do AT commands */ + if (error->domain == MM_MOBILE_ERROR) + task_priv->probed_caps |= MM_PLUGIN_BASE_PORT_CAP_AT; - if (error && !ignore_error) { /* Only allow timeout errors in the initial AT+GCAP queries. If all AT+GCAP * get timed out, assume it's not an AT port. */ if (g_error_matches (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_RESPONSE_TIMEOUT)) { @@ -763,7 +768,8 @@ real_handle_probe_response (MMPluginBase *self, /* Some modems don't respond to AT+GCAP, but often they put a * GCAP-style response as a line in the ATI response. */ - task_priv->probed_caps = parse_caps_gcap (response); + task_priv->probed_caps |= parse_caps_gcap (response); + task_priv->probed_caps |= MM_PLUGIN_BASE_PORT_CAP_AT; break; case PROBE_STATE_CAPS_CPIN: /* Some devices (ZTE MF628/ONDA MT503HS for example) reply to @@ -771,13 +777,15 @@ real_handle_probe_response (MMPluginBase *self, * Since no known CDMA modems support AT+CPIN? we can consider the * device a GSM device if it returns a non-error response to AT+CPIN?. */ - task_priv->probed_caps = parse_caps_cpin (response); + task_priv->probed_caps |= parse_caps_cpin (response); + task_priv->probed_caps |= MM_PLUGIN_BASE_PORT_CAP_AT; break; case PROBE_STATE_CAPS_CGMM: /* Some models (BUSlink SCWi275u) stick stupid stuff in the CGMM * response but at least it allows us to identify them. */ - task_priv->probed_caps = parse_caps_cgmm (response); + task_priv->probed_caps |= parse_caps_cgmm (response); + task_priv->probed_caps |= MM_PLUGIN_BASE_PORT_CAP_AT; break; case PROBE_STATE_VENDOR_CGMI: case PROBE_STATE_VENDOR_GMI: diff --git a/src/mm-plugin-base.h b/src/mm-plugin-base.h index 5ab6ec21..4b0932ca 100644 --- a/src/mm-plugin-base.h +++ b/src/mm-plugin-base.h @@ -38,6 +38,7 @@ #define MM_PLUGIN_BASE_PORT_CAP_IS856 0x0100 /* CDMA 3G EVDO rev 0 */ #define MM_PLUGIN_BASE_PORT_CAP_IS856_A 0x0200 /* CDMA 3G EVDO rev A */ #define MM_PLUGIN_BASE_PORT_CAP_QCDM 0x0400 /* QCDM-capable port */ +#define MM_PLUGIN_BASE_PORT_CAP_AT 0x0800 /* Responds to AT commands */ #define MM_TYPE_PLUGIN_BASE_SUPPORTS_TASK (mm_plugin_base_supports_task_get_type ()) #define MM_PLUGIN_BASE_SUPPORTS_TASK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MM_TYPE_PLUGIN_BASE_SUPPORTS_TASK, MMPluginBaseSupportsTask)) |