summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2020-01-21 12:21:28 +0100
committerAleksander Morgado <aleksander@aleksander.es>2020-03-14 09:47:03 +0100
commit593a942a63a5a61fdb7146ed41dd24ec390fa197 (patch)
treee4f07a57879179c546f972b71d6a3d3529fe8631
parenta9966e2e59959a50204f0e2a5959ffcca909f466 (diff)
huawei: only tag GETPORTMODE supported if it was really used
E.g. do nothing if the response is empty: <debug> (ttyUSB1): -->'AT^GETPORTMODE<CR>' <debug> (ttyUSB1): <--'<CR><LF>^GETPORTMODE: TYPE: WCDMA: Huawei Technologies Co.,Ltd.,<CR><LF><CR><LF>OK<CR><LF>' (cherry picked from commit 6eabfd27bf3c4c53d7779722b46e7261d22c1d92)
-rw-r--r--plugins/huawei/mm-plugin-huawei.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/plugins/huawei/mm-plugin-huawei.c b/plugins/huawei/mm-plugin-huawei.c
index b8bd8f08..c7df2a66 100644
--- a/plugins/huawei/mm-plugin-huawei.c
+++ b/plugins/huawei/mm-plugin-huawei.c
@@ -99,7 +99,7 @@ huawei_custom_init_finish (MMPortProbe *probe,
static void huawei_custom_init_step (GTask *task);
-static void
+static gboolean
cache_port_mode (MMDevice *device,
const gchar *reply,
const gchar *type,
@@ -114,9 +114,12 @@ cache_port_mode (MMDevice *device,
errno = 0;
/* shift by 1 so NULL return from g_object_get_data() means no tag */
i = 1 + strtol (p + strlen (type), NULL, 10);
- if (i > 0 && i < 256 && errno == 0)
+ if (i > 0 && i < 256 && errno == 0) {
g_object_set_data (G_OBJECT (device), tag, GINT_TO_POINTER ((gint) i));
+ return TRUE;
+ }
}
+ return FALSE;
}
static void
@@ -146,20 +149,22 @@ getportmode_ready (MMPortSerialAt *port,
/* Port mode not supported */
} else {
MMDevice *device;
+ guint n_cached_port_modes = 0;
mm_dbg ("(Huawei) port mode layout retrieved");
/* Results are cached in the parent device object */
device = mm_port_probe_peek_device (ctx->probe);
- cache_port_mode (device, response, "PCUI:", TAG_HUAWEI_PCUI_PORT);
- cache_port_mode (device, response, "MDM:", TAG_HUAWEI_MODEM_PORT);
- cache_port_mode (device, response, "NDIS:", TAG_HUAWEI_NDIS_PORT);
- cache_port_mode (device, response, "DIAG:", TAG_HUAWEI_DIAG_PORT);
+ n_cached_port_modes += cache_port_mode (device, response, "PCUI:", TAG_HUAWEI_PCUI_PORT);
+ n_cached_port_modes += cache_port_mode (device, response, "MDM:", TAG_HUAWEI_MODEM_PORT);
+ n_cached_port_modes += cache_port_mode (device, response, "NDIS:", TAG_HUAWEI_NDIS_PORT);
+ n_cached_port_modes += cache_port_mode (device, response, "DIAG:", TAG_HUAWEI_DIAG_PORT);
/* GETPORTMODE response format in newer devices... (e.g. E3372) */
- cache_port_mode (device, response, "pcui:", TAG_HUAWEI_PCUI_PORT);
- cache_port_mode (device, response, "modem:", TAG_HUAWEI_MODEM_PORT);
+ n_cached_port_modes += cache_port_mode (device, response, "pcui:", TAG_HUAWEI_PCUI_PORT);
+ n_cached_port_modes += cache_port_mode (device, response, "modem:", TAG_HUAWEI_MODEM_PORT);
- g_object_set_data (G_OBJECT (device), TAG_GETPORTMODE_SUPPORTED, GUINT_TO_POINTER (TRUE));
+ if (n_cached_port_modes > 0)
+ g_object_set_data (G_OBJECT (device), TAG_GETPORTMODE_SUPPORTED, GUINT_TO_POINTER (TRUE));
/* Mark port as being AT already */
mm_port_probe_set_result_at (ctx->probe, TRUE);