diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2013-11-11 01:12:21 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2013-12-09 23:07:19 +0100 |
commit | fc42b2df8c0c68425f79dae17f6fac988f69f6f5 (patch) | |
tree | 6b68a9892244885c05eb93aefe0647f817b8361b | |
parent | e81fdd07c3e8ef824b13e157d4c50213786d9973 (diff) |
huawei: handle empty response to AT^SYSCFG=?
Some Huawei modems (e.g. E220) may give an empty response for AT^SYSCFG=?, even
if they do support the command. Handle this case by prividing a default fallback
format string when this happens.
-rw-r--r-- | plugins/huawei/mm-broadband-modem-huawei.c | 15 | ||||
-rw-r--r-- | plugins/huawei/mm-modem-helpers-huawei.h | 4 | ||||
-rw-r--r-- | plugins/huawei/tests/test-modem-helpers-huawei.c | 35 |
3 files changed, 52 insertions, 2 deletions
diff --git a/plugins/huawei/mm-broadband-modem-huawei.c b/plugins/huawei/mm-broadband-modem-huawei.c index eff183a0..80c8e7b1 100644 --- a/plugins/huawei/mm-broadband-modem-huawei.c +++ b/plugins/huawei/mm-broadband-modem-huawei.c @@ -912,8 +912,19 @@ syscfg_test_ready (MMBroadbandModemHuawei *self, GError *error = NULL; response = mm_base_modem_at_command_finish (MM_BASE_MODEM (self), res, &error); - if (response) - self->priv->syscfg_supported_modes = mm_huawei_parse_syscfg_test (response, &error); + if (response) { + /* There are 2G+3G Huawei modems out there which support mode switching with + * AT^SYSCFG, but fail to provide a valid response for AT^SYSCFG=? (they just + * return an empty string). So handle that case by providing a default response + * string to get parsed. Ugly, ugly, blame Huawei. + */ + if (response[0]) + self->priv->syscfg_supported_modes = mm_huawei_parse_syscfg_test (response, &error); + else { + self->priv->syscfg_supported_modes = mm_huawei_parse_syscfg_test (MM_HUAWEI_DEFAULT_SYSCFG_FMT, NULL); + g_assert (self->priv->syscfg_supported_modes != NULL); + } + } if (self->priv->syscfg_supported_modes) { MMModemModeCombination mode; diff --git a/plugins/huawei/mm-modem-helpers-huawei.h b/plugins/huawei/mm-modem-helpers-huawei.h index 944e7a5f..05894f34 100644 --- a/plugins/huawei/mm-modem-helpers-huawei.h +++ b/plugins/huawei/mm-modem-helpers-huawei.h @@ -73,6 +73,10 @@ const MMHuaweiPrefmodeCombination *mm_huawei_parse_prefmode_response (const gcha /*****************************************************************************/ /* ^SYSCFG test parser */ +/* This is the default string we use as fallback when the modem gives + * an empty response to AT^SYSCFG=? */ +#define MM_HUAWEI_DEFAULT_SYSCFG_FMT "^SYSCFG:(2,13,14,16),(0-3),,," + typedef struct { guint mode; guint acqorder; diff --git a/plugins/huawei/tests/test-modem-helpers-huawei.c b/plugins/huawei/tests/test-modem-helpers-huawei.c index dc03973a..b74821fb 100644 --- a/plugins/huawei/tests/test-modem-helpers-huawei.c +++ b/plugins/huawei/tests/test-modem-helpers-huawei.c @@ -440,6 +440,41 @@ typedef struct { static const SyscfgTest syscfg_tests[] = { { + MM_HUAWEI_DEFAULT_SYSCFG_FMT, + { + { + .mode = 2, + .acqorder = 0, + .allowed = (MM_MODEM_MODE_3G | MM_MODEM_MODE_2G), + .preferred = MM_MODEM_MODE_NONE + }, + { + .mode = 2, + .acqorder = 1, + .allowed = (MM_MODEM_MODE_3G | MM_MODEM_MODE_2G), + .preferred = MM_MODEM_MODE_2G + }, + { + .mode = 2, + .acqorder = 2, + .allowed = (MM_MODEM_MODE_3G | MM_MODEM_MODE_2G), + .preferred = MM_MODEM_MODE_3G + }, + { + .mode = 13, + .acqorder = 0, + .allowed = MM_MODEM_MODE_2G, + .preferred = MM_MODEM_MODE_NONE + }, + { + .mode = 14, + .acqorder = 0, + .allowed = MM_MODEM_MODE_3G, + .preferred = MM_MODEM_MODE_NONE + } + } + }, + { "^SYSCFG:(2,13,14,16),(0-3),((400000,\"WCDMA2100\")),(0-2),(0-4)\r\n", { { |