From 66dce6dacc440d8bfe4270562ef5a840c87e5a04 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Tue, 7 Nov 2017 19:13:19 +0100 Subject: [PATCH] broadband-modem: use several SIM errors to flag the modem as GSM/UMTS When using CPIN? to detect capabilities, use several possible +CME errors as indication that the modem is at least GSM/UMTS. E.g. to avoid situations like this one where the modem doesn't even get into Failed state as we cannot gather capabilities: debug_log(): (ttyMux1): --> 'AT+GCAP' debug_log(): (ttyMux1): <-- '+CME ERROR: 100' mm_serial_parser_v1_parse(): Got failure code 100: Unknown error debug_log(): (ttyMux1): --> 'ATI' debug_log(): (ttyMux1): <-- 'CinterionEHS5-EREVISION 03.001OK' debug_log(): (ttyMux1): --> 'AT+CPIN?' debug_log(): (ttyMux1): <-- '+CME ERROR: 10' mm_serial_parser_v1_parse(): Got failure code 10: SIM not inserted debug_log(): (ttyMux1): --> 'AT+CGMM' debug_log(): (ttyMux1): <-- 'EHS5-E' debug_log(): (ttyMux1): <-- 'OK' iface_modem_initialize_ready(): Modem couldn't be initialized: couldn't load current capabilities: Failed to determine modem capabilities. --- src/mm-broadband-modem.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c index 3d96372a..c97afc13 100644 --- a/src/mm-broadband-modem.c +++ b/src/mm-broadband-modem.c @@ -481,8 +481,18 @@ parse_caps_cpin (MMBaseModem *self, GVariant **result, GError **result_error) { - if (!response) + if (!response) { + if (error && + (g_error_matches (error, MM_MOBILE_EQUIPMENT_ERROR, MM_MOBILE_EQUIPMENT_ERROR_SIM_NOT_INSERTED) || + g_error_matches (error, MM_MOBILE_EQUIPMENT_ERROR, MM_MOBILE_EQUIPMENT_ERROR_SIM_FAILURE) || + g_error_matches (error, MM_MOBILE_EQUIPMENT_ERROR, MM_MOBILE_EQUIPMENT_ERROR_SIM_BUSY) || + g_error_matches (error, MM_MOBILE_EQUIPMENT_ERROR, MM_MOBILE_EQUIPMENT_ERROR_SIM_WRONG))) { + /* At least, it's a GSM modem */ + *result = g_variant_new_uint32 (MM_MODEM_CAPABILITY_GSM_UMTS); + return TRUE; + } return FALSE; + } if (strcasestr (response, "SIM PIN") || strcasestr (response, "SIM PUK") ||