From 0b8cd38dcd8cfae1d783e819bbfa0347128f1238 Mon Sep 17 00:00:00 2001 From: Antti Kauppila Date: Mon, 14 Oct 2019 14:25:29 +0300 Subject: [PATCH 1/2] Baremetal profile fixes --- .../framework/device/CellularStateMachine.cpp | 12 +++++++++--- .../cellular/framework/device/CellularStateMachine.h | 9 ++++++++- features/netsocket/L3IPInterface.cpp | 4 ++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/features/cellular/framework/device/CellularStateMachine.cpp b/features/cellular/framework/device/CellularStateMachine.cpp index c2e917be9f..480b108e75 100644 --- a/features/cellular/framework/device/CellularStateMachine.cpp +++ b/features/cellular/framework/device/CellularStateMachine.cpp @@ -50,9 +50,12 @@ const int DEVICE_READY = 0x04; namespace mbed { CellularStateMachine::CellularStateMachine(CellularDevice &device, events::EventQueue &queue, CellularNetwork &nw) : +#ifdef MBED_CONF_RTOS_PRESENT + _queue_thread(0), +#endif _cellularDevice(device), _state(STATE_INIT), _next_state(_state), _target_state(_state), - _event_status_cb(0), _network(nw), _queue(queue), _queue_thread(0), _sim_pin(0), - _retry_count(0), _event_timeout(-1), _event_id(-1), _plmn(0), _command_success(false), + _event_status_cb(0), _network(nw), _queue(queue), _sim_pin(0), _retry_count(0), + _event_timeout(-1), _event_id(-1), _plmn(0), _command_success(false), _is_retry(false), _cb_data(), _current_event(CellularDeviceReady), _status(0) { #if MBED_CONF_CELLULAR_RANDOM_MAX_START_DELAY == 0 @@ -102,11 +105,13 @@ void CellularStateMachine::reset() void CellularStateMachine::stop() { tr_debug("CellularStateMachine stop"); +#ifdef MBED_CONF_RTOS_PRESENT if (_queue_thread) { _queue_thread->terminate(); delete _queue_thread; _queue_thread = NULL; } +#endif reset(); _event_id = STM_STOPPED; @@ -635,6 +640,7 @@ void CellularStateMachine::event() nsapi_error_t CellularStateMachine::start_dispatch() { +#ifdef MBED_CONF_RTOS_PRESENT if (!_queue_thread) { _queue_thread = new rtos::Thread(osPriorityNormal, 2048, NULL, "stm_queue"); _event_id = STM_STOPPED; @@ -649,7 +655,7 @@ nsapi_error_t CellularStateMachine::start_dispatch() } _event_id = -1; - +#endif return NSAPI_ERROR_OK; } diff --git a/features/cellular/framework/device/CellularStateMachine.h b/features/cellular/framework/device/CellularStateMachine.h index d31bf2167d..6fda9abe39 100644 --- a/features/cellular/framework/device/CellularStateMachine.h +++ b/features/cellular/framework/device/CellularStateMachine.h @@ -22,9 +22,11 @@ #include "CellularCommon.h" #include "PlatformMutex.h" +#ifdef MBED_CONF_RTOS_PRESENT namespace rtos { class Thread; } +#endif namespace mbed { @@ -159,6 +161,12 @@ private: void send_event_cb(cellular_connection_status_t status); void change_timeout(const int &timeout); +private: + +#ifdef MBED_CONF_RTOS_PRESENT + rtos::Thread *_queue_thread; +#endif + CellularDevice &_cellularDevice; CellularState _state; CellularState _next_state; @@ -168,7 +176,6 @@ private: CellularNetwork &_network; events::EventQueue &_queue; - rtos::Thread *_queue_thread; const char *_sim_pin; int _retry_count; diff --git a/features/netsocket/L3IPInterface.cpp b/features/netsocket/L3IPInterface.cpp index 09c0e57fe8..ff0bf6fed3 100644 --- a/features/netsocket/L3IPInterface.cpp +++ b/features/netsocket/L3IPInterface.cpp @@ -16,6 +16,8 @@ */ #include "L3IPInterface.h" + +#if MBED_CONF_LWIP_L3IP_ENABLED #include "LWIPStack.h" using namespace mbed; @@ -157,3 +159,5 @@ nsapi_error_t L3IPInterface::set_blocking(bool blocking) _blocking = blocking; return NSAPI_ERROR_OK; } + +#endif From ac0b0f1f2c4c1ec51aa1c600f566293b45115bbc Mon Sep 17 00:00:00 2001 From: Antti Kauppila Date: Fri, 1 Nov 2019 15:22:28 +0200 Subject: [PATCH 2/2] Unittests fixed --- .../framework/device/cellularstatemachine/unittest.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UNITTESTS/features/cellular/framework/device/cellularstatemachine/unittest.cmake b/UNITTESTS/features/cellular/framework/device/cellularstatemachine/unittest.cmake index c248fcee89..172ba725d8 100644 --- a/UNITTESTS/features/cellular/framework/device/cellularstatemachine/unittest.cmake +++ b/UNITTESTS/features/cellular/framework/device/cellularstatemachine/unittest.cmake @@ -43,5 +43,5 @@ set(unittest-test-sources ) # defines -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMDMRTS=PTC0 -DMDMCTS=PTC1 -DMDMTXD=NC -DMDMRXD=NC -DMBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200 -DCELLULAR_DEVICE=myCellularDevice -DDEVICE_SERIAL_FC=1") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMDMRTS=PTC0 -DMDMCTS=PTC1 -DMDMTXD=NC -DMDMRXD=NC -DMBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200 -DCELLULAR_DEVICE=myCellularDevice -DDEVICE_SERIAL_FC=1") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DMDMRTS=PTC0 -DMDMCTS=PTC1 -DMDMTXD=NC -DMDMRXD=NC -DMBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200 -DCELLULAR_DEVICE=myCellularDevice -DDEVICE_SERIAL_FC=1 -DMBED_CONF_RTOS_PRESENT=1") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DMDMRTS=PTC0 -DMDMCTS=PTC1 -DMDMTXD=NC -DMDMRXD=NC -DMBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE=115200 -DCELLULAR_DEVICE=myCellularDevice -DDEVICE_SERIAL_FC=1 -DMBED_CONF_RTOS_PRESENT=1")