diff --git a/features/cellular/framework/device/CellularStateMachine.cpp b/features/cellular/framework/device/CellularStateMachine.cpp index 3af35d48c2..9609f0ad1c 100644 --- a/features/cellular/framework/device/CellularStateMachine.cpp +++ b/features/cellular/framework/device/CellularStateMachine.cpp @@ -165,6 +165,12 @@ bool CellularStateMachine::open_sim() bool sim_ready = state == CellularDevice::SimStateReady; if (sim_ready) { +#ifdef MBED_CONF_CELLULAR_CLEAR_ON_CONNECT + if (_cellularDevice.clear() != NSAPI_ERROR_OK) { + tr_warning("CellularDevice clear failed"); + return false; + } +#endif _cb_data.error = _network.set_registration(_plmn); tr_debug("STM: set_registration: %d, plmn: %s", _cb_data.error, _plmn ? _plmn : "NULL"); if (_cb_data.error) { @@ -395,7 +401,6 @@ void CellularStateMachine::state_sim_pin() retry_state_or_fail(); return; } - if (_network.is_active_context()) { // check if context was already activated tr_debug("Active context found."); _status |= ACTIVE_PDP_CONTEXT;