From 8483d59879e458566064f4a171cea6fe0b46f9f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bora=20=C3=96zgen?= Date: Thu, 10 Sep 2020 16:19:31 +0200 Subject: [PATCH 1/3] Fix #13490 Cellular disconnect does not deactivate context (for some cases) --- .../cellular/source/framework/AT/AT_CellularContext.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/connectivity/cellular/source/framework/AT/AT_CellularContext.cpp b/connectivity/cellular/source/framework/AT/AT_CellularContext.cpp index b851cc4b38..3338f8ca69 100644 --- a/connectivity/cellular/source/framework/AT/AT_CellularContext.cpp +++ b/connectivity/cellular/source/framework/AT/AT_CellularContext.cpp @@ -544,6 +544,7 @@ nsapi_error_t AT_CellularContext::find_and_activate_context() delete_current_context(); } else if (err == NSAPI_ERROR_OK) { _is_context_active = true; + _is_context_activated = true; } _at.unlock(); @@ -757,8 +758,9 @@ void AT_CellularContext::check_and_deactivate_context() // For EPS, if an attempt is made to disconnect the last PDN connection, then the MT responds with ERROR if (_is_context_active && (rat < CellularNetwork::RAT_E_UTRAN || active_contexts_count > 1)) { _at.clear_error(); - deactivate_context(); } + + deactivate_context(); if (_new_context_set) { delete_current_context(); From 9f24c045d7041bc58e441b95546d535c70ba5fc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bora=20=C3=96zgen?= Date: Mon, 21 Sep 2020 14:37:56 +0200 Subject: [PATCH 2/3] Apply astyle --- .../cellular/source/framework/AT/AT_CellularContext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connectivity/cellular/source/framework/AT/AT_CellularContext.cpp b/connectivity/cellular/source/framework/AT/AT_CellularContext.cpp index 3338f8ca69..4692b38848 100644 --- a/connectivity/cellular/source/framework/AT/AT_CellularContext.cpp +++ b/connectivity/cellular/source/framework/AT/AT_CellularContext.cpp @@ -759,7 +759,7 @@ void AT_CellularContext::check_and_deactivate_context() if (_is_context_active && (rat < CellularNetwork::RAT_E_UTRAN || active_contexts_count > 1)) { _at.clear_error(); } - + deactivate_context(); if (_new_context_set) { From 0604c49a2e64da6798101fa6661b86a4c10d4627 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bora=20=C3=96zgen?= Date: Wed, 23 Sep 2020 16:04:23 +0200 Subject: [PATCH 3/3] Apply suggestion from review --- .../cellular/source/framework/AT/AT_CellularContext.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/connectivity/cellular/source/framework/AT/AT_CellularContext.cpp b/connectivity/cellular/source/framework/AT/AT_CellularContext.cpp index 4692b38848..f2b1d632b9 100644 --- a/connectivity/cellular/source/framework/AT/AT_CellularContext.cpp +++ b/connectivity/cellular/source/framework/AT/AT_CellularContext.cpp @@ -756,11 +756,11 @@ void AT_CellularContext::check_and_deactivate_context() rat = reg_params._act; // 3GPP TS 27.007: // For EPS, if an attempt is made to disconnect the last PDN connection, then the MT responds with ERROR - if (_is_context_active && (rat < CellularNetwork::RAT_E_UTRAN || active_contexts_count > 1)) { + if (_is_context_active && (rat < CellularNetwork::RAT_E_UTRAN || rat == CellularNetwork::RAT_NB1 || active_contexts_count > 1)) { _at.clear_error(); - } - deactivate_context(); + deactivate_context(); + } if (_new_context_set) { delete_current_context();