From 2de0e8958985f40eac1c9ad84f75ae2d75f25e17 Mon Sep 17 00:00:00 2001 From: Alexander Yashin Date: Mon, 29 Nov 2021 16:36:37 +0300 Subject: [PATCH] plugins: ublox: bearer: SIM absence should not break disconnect If we have a modem with an established connection, and then the SIM is getting removed from that modem, this forces modem reprobing sequence. It looks like that: ``` mm-base-modem:mm_base_modem_process_sim_event -> mm-base-modem:mm_base_modem_disable -> mm-base-modem:disable -> mm-broadband-modem:common_disable -> mm-broadband-modem:disabling_step, -> ctx->step=DISABLING_STEP_FIRST -> ctx->step=DISABLING_STEP_WAIT_FOR_FINAL_STATE -> ctx->step=DISABLING_STEP_DISCONNECT_BEARERS ``` At this stage, there is no actual connection existing already, but bearer objects still exist and are still marked as connected. So, if there were any active bearers - they will be disconnected. In order to disconnect, ublox bearer sends +CGACT=0,%u, modem then will return CME ERROR: 10(SIM not inserted): ``` [modem0/ttyACM0/at] --> 'AT+CGACT=0,1' [modem0/ttyACM0/at] <-- '+CME ERROR: 10' [modem0/ttyACM0/at] operation failure: 10 (SIM not inserted) [modem0/bearer0] couldn't disconnect: SIM not inserted ``` this error will break disabling and reprobing. To fix that, it's require to add 'SIM not inserted' state as a valid condition to continue bearer disconnection. --- plugins/ublox/mm-broadband-bearer-ublox.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/ublox/mm-broadband-bearer-ublox.c b/plugins/ublox/mm-broadband-bearer-ublox.c index daabdb2e..27db9b11 100644 --- a/plugins/ublox/mm-broadband-bearer-ublox.c +++ b/plugins/ublox/mm-broadband-bearer-ublox.c @@ -689,7 +689,8 @@ cgact_deactivate_ready (MMBaseModem *modem, */ if (!g_error_matches (error, MM_MOBILE_EQUIPMENT_ERROR, MM_MOBILE_EQUIPMENT_ERROR_GPRS_UNKNOWN) && !g_error_matches (error, MM_MOBILE_EQUIPMENT_ERROR, MM_MOBILE_EQUIPMENT_ERROR_LAST_PDN_DISCONNECTION_NOT_ALLOWED) && - !g_error_matches (error, MM_MOBILE_EQUIPMENT_ERROR, MM_MOBILE_EQUIPMENT_ERROR_LAST_PDN_DISCONNECTION_NOT_ALLOWED_LEGACY)) { + !g_error_matches (error, MM_MOBILE_EQUIPMENT_ERROR, MM_MOBILE_EQUIPMENT_ERROR_LAST_PDN_DISCONNECTION_NOT_ALLOWED_LEGACY) && + !g_error_matches (error, MM_MOBILE_EQUIPMENT_ERROR, MM_MOBILE_EQUIPMENT_ERROR_SIM_NOT_INSERTED)) { g_task_return_error (task, error); g_object_unref (task); return;