From 2de83fb28683d27b4a75dcea98e9cfb17a605f74 Mon Sep 17 00:00:00 2001 From: Marc Emmers Date: Mon, 29 Oct 2018 13:56:25 +0100 Subject: [PATCH 1/2] Unchain the queue when connection is stopped --- features/cellular/easy_cellular/CellularConnectionFSM.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/features/cellular/easy_cellular/CellularConnectionFSM.cpp b/features/cellular/easy_cellular/CellularConnectionFSM.cpp index 39c76736ab..6319dbc942 100644 --- a/features/cellular/easy_cellular/CellularConnectionFSM.cpp +++ b/features/cellular/easy_cellular/CellularConnectionFSM.cpp @@ -84,6 +84,11 @@ void CellularConnectionFSM::stop() _queue_thread = NULL; } + if (_at_queue) { + _at_queue->chain(NULL); + _at_queue = NULL; + } + if (_power) { _cellularDevice->close_power(); _power = NULL; From d55f6a991501068e4fbc0e58e1d1f8d92e3aa94d Mon Sep 17 00:00:00 2001 From: Marc Emmers Date: Mon, 29 Oct 2018 13:56:45 +0100 Subject: [PATCH 2/2] Check if a queue is present. Return an error otherwise --- features/cellular/easy_cellular/CellularConnectionFSM.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/features/cellular/easy_cellular/CellularConnectionFSM.cpp b/features/cellular/easy_cellular/CellularConnectionFSM.cpp index 6319dbc942..6a5c1ae335 100644 --- a/features/cellular/easy_cellular/CellularConnectionFSM.cpp +++ b/features/cellular/easy_cellular/CellularConnectionFSM.cpp @@ -136,6 +136,10 @@ nsapi_error_t CellularConnectionFSM::init() } _at_queue = _cellularDevice->get_queue(); + if (!_at_queue) { + stop(); + return NSAPI_ERROR_NO_MEMORY; + } _at_queue->chain(&_queue); _retry_count = 0;