From 1a60422b74ad058060398d30d4830ffa133e0723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Teppo=20J=C3=A4rvelin?= Date: Wed, 20 Jun 2018 14:15:22 +0300 Subject: [PATCH] Cellular: fixed defect where SIM interface was closed too early causing crash with certain configurations. --- features/cellular/easy_cellular/CellularConnectionFSM.cpp | 4 ++-- features/cellular/easy_cellular/CellularConnectionFSM.h | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/features/cellular/easy_cellular/CellularConnectionFSM.cpp b/features/cellular/easy_cellular/CellularConnectionFSM.cpp index 340a0ab474..88ac53a2a0 100644 --- a/features/cellular/easy_cellular/CellularConnectionFSM.cpp +++ b/features/cellular/easy_cellular/CellularConnectionFSM.cpp @@ -436,8 +436,6 @@ void CellularConnectionFSM::state_sim_pin() retry_state_or_fail(); return; } - _cellularDevice->close_sim(); - _sim = NULL; if (_plmn) { enter_to_state(STATE_MANUAL_REGISTERING_NETWORK); } else { @@ -485,6 +483,8 @@ void CellularConnectionFSM::state_attaching() { _cellularDevice->set_timeout(TIMEOUT_CONNECT); if (_network->set_attach() == NSAPI_ERROR_OK) { + _cellularDevice->close_sim(); + _sim = NULL; enter_to_state(STATE_ACTIVATING_PDP_CONTEXT); } else { retry_state_or_fail(); diff --git a/features/cellular/easy_cellular/CellularConnectionFSM.h b/features/cellular/easy_cellular/CellularConnectionFSM.h index b0c2bdda6b..1875ff8c25 100644 --- a/features/cellular/easy_cellular/CellularConnectionFSM.h +++ b/features/cellular/easy_cellular/CellularConnectionFSM.h @@ -117,9 +117,9 @@ public: */ CellularDevice *get_device(); - /** Get cellular sim interface. SIM interface is released after SIM is open and ready for use (moving from STATE_SIM_PIN to next state). - * After SIM interface is closed this method will return NULL. SIM interface can be created again via CellularDevice - * which you can get with the method get_device(). + /** Get cellular sim interface. SIM interface is released when moving from STATE_ATTACHING_NETWORK to STATE_ACTIVATING_PDP_CONTEXT. + * After SIM interface is closed this method will return NULL and any instances fetched via this method are invalid. + * SIM interface can be created again via CellularDevice which you can get with the method get_device(). * @return sim interface, NULL on failure */ CellularSIM *get_sim();