diff options
author | mank.wang <mank.wang@quectel.com> | 2023-09-27 14:10:13 +0800 |
---|---|---|
committer | Aleksander Morgado <aleksandermj@chromium.org> | 2023-10-18 21:29:06 +0000 |
commit | 1b6e4c434998258c9342895593538946c11f6e05 (patch) | |
tree | a17a8dfddb376f1dc00625bed9c0f18acdeba6b1 /src/plugins/quectel/mm-modem-helpers-quectel.c | |
parent | 7b878765c6c8025ca7a4594af798a3d892e5bc58 (diff) |
quectel: avoid incorrect module version report after the upgrade
After LVFS upgrade, the module needs to be restarted. ModemManager
queries the module information, sometimes the module is not ready, and
the information queried by "mmcli -m any --firmware-status" is
incomplete,
It is now modified to re query once per second when obtaining
incomplete versions, up to a maximum of 16 times.
Signed-off-by: mank.wang <mank.wang@quectel.com>
Diffstat (limited to 'src/plugins/quectel/mm-modem-helpers-quectel.c')
-rw-r--r-- | src/plugins/quectel/mm-modem-helpers-quectel.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/plugins/quectel/mm-modem-helpers-quectel.c b/src/plugins/quectel/mm-modem-helpers-quectel.c index 262d9794..4335e506 100644 --- a/src/plugins/quectel/mm-modem-helpers-quectel.c +++ b/src/plugins/quectel/mm-modem-helpers-quectel.c @@ -89,3 +89,52 @@ mm_quectel_parse_ctzu_test_response (const gchar *response, return TRUE; } + +/*****************************************************************************/ +/* standard firmware info + * Format of the string is: + * "[main version]_[modem and app version]" + * e.g. EM05GFAR07A07M1G_01.016.01.016 + */ +#define QUECTEL_STD_FIRMWARE_VERSION_SEG 2 + +/* Format of the string is: + * "modem_main.modem_minor.ap_main.ap_minor" + * e.g. 01.016.01.016 + */ +#define QUECTEL_STD_MODEM_AP_FIRMWARE_VER_SEG 4 +#define QUECTEL_STD_MODEM_AP_FIRMWARE_VER_LEN 13 + +#define QUECTEL_MAIN_VERSION_INVALID_TAG "00" +#define QUECTEL_MINOR_VERSION_INVALID_TAG "000" + +gboolean +mm_quectel_check_standard_firmware_version_valid (const gchar *std_str) +{ + gboolean valid = TRUE; + g_auto(GStrv) split_std_fw = NULL; + g_auto(GStrv) split_modem_ap_fw = NULL; + const gchar *modem_ap_fw; + + if (std_str) { + split_std_fw = g_strsplit (std_str, "_", QUECTEL_STD_FIRMWARE_VERSION_SEG); + /* Quectel standard format of the [main version]_[modem and app version] + * Sometimes we find that the [modem and app version] query is missing by [AT+QMGR] + * for example: we expect EM05GFAR07A07M1G_01.016.01.016,but unexpected EM05GFAR07A07M1G_01.016.00.000 was returned + * Quectel will check for this abnormal [modem and app version] and flag it + */ + if (g_strv_length (split_std_fw) == QUECTEL_STD_FIRMWARE_VERSION_SEG) { + modem_ap_fw = split_std_fw[1]; + if (strlen (modem_ap_fw) == QUECTEL_STD_MODEM_AP_FIRMWARE_VER_LEN) { + split_modem_ap_fw = g_strsplit (modem_ap_fw, ".", QUECTEL_STD_MODEM_AP_FIRMWARE_VER_SEG); + + if (g_strv_length (split_modem_ap_fw) == QUECTEL_STD_MODEM_AP_FIRMWARE_VER_SEG && + !g_strcmp0 (split_modem_ap_fw[2], QUECTEL_MAIN_VERSION_INVALID_TAG) && + !g_strcmp0 (split_modem_ap_fw[3], QUECTEL_MINOR_VERSION_INVALID_TAG)){ + valid = FALSE; + } + } + } + } + return valid; +} |