From e8a26f3f54eb0deac3f9803591d2e482e412c381 Mon Sep 17 00:00:00 2001 From: Ari Parkkila Date: Tue, 13 Feb 2018 15:35:51 +0200 Subject: [PATCH] Removed mbed.h --- .../easy_cellular/CellularConnectionUtil.cpp | 18 +++++++++++------- .../easy_cellular/CellularConnectionUtil.h | 18 +++++++++++++----- .../easy_cellular/EasyCellularConnection.cpp | 17 +++++++++++++---- .../easy_cellular/EasyCellularConnection.h | 10 +++++++++- .../framework/common/CellularTargets.h | 3 +-- 5 files changed, 47 insertions(+), 19 deletions(-) diff --git a/features/cellular/easy_cellular/CellularConnectionUtil.cpp b/features/cellular/easy_cellular/CellularConnectionUtil.cpp index 2700cbbddb..1f57349516 100644 --- a/features/cellular/easy_cellular/CellularConnectionUtil.cpp +++ b/features/cellular/easy_cellular/CellularConnectionUtil.cpp @@ -15,10 +15,8 @@ * limitations under the License. */ -#include - - #include "CellularConnectionUtil.h" +#ifdef CELLULAR_DEVICE #ifndef MBED_TRACE_MAX_LEVEL #define MBED_TRACE_MAX_LEVEL TRACE_LEVEL_INFO @@ -36,7 +34,9 @@ #define TIMEOUT_NETWORK (10*1000) #define TIMEOUT_REGISTRATION (180*1000) -static EventQueue at_queue(8 * EVENTS_EVENT_SIZE); +namespace mbed { + +static events::EventQueue at_queue(8 * EVENTS_EVENT_SIZE); static CELLULAR_DEVICE cellularDevice(at_queue); CellularConnectionUtil::CellularConnectionUtil() : _serial(0), _state(STATE_POWER_ON), _next_state(_state), @@ -463,12 +463,12 @@ nsapi_error_t CellularConnectionUtil::start_dispatch() MBED_ASSERT(!_queue_thread); - _queue_thread = new Thread(); + _queue_thread = new rtos::Thread(); if (!_queue_thread) { stop(); return NSAPI_ERROR_NO_MEMORY; } - if (_queue_thread->start(callback(&_queue, &EventQueue::dispatch_forever)) != osOK) { + if (_queue_thread->start(callback(&_queue, &events::EventQueue::dispatch_forever)) != osOK) { stop(); return NSAPI_ERROR_NO_MEMORY; } @@ -498,7 +498,7 @@ void CellularConnectionUtil::set_callback(mbed::Callback status_ _status_callback = status_callback; } -EventQueue *CellularConnectionUtil::get_queue() +events::EventQueue *CellularConnectionUtil::get_queue() { return &_queue; } @@ -524,3 +524,7 @@ NetworkStack *CellularConnectionUtil::get_stack() { return _cellularDevice->get_stack(); } + +} // namespace + +#endif // CELLULAR_DEVICE diff --git a/features/cellular/easy_cellular/CellularConnectionUtil.h b/features/cellular/easy_cellular/CellularConnectionUtil.h index 66398f32b9..3fda384a5a 100644 --- a/features/cellular/easy_cellular/CellularConnectionUtil.h +++ b/features/cellular/easy_cellular/CellularConnectionUtil.h @@ -18,9 +18,13 @@ #ifndef _CELLULAR_CONNECTION_UTIL_H #define _CELLULAR_CONNECTION_UTIL_H +#include "CellularTargets.h" +#ifdef CELLULAR_DEVICE + #include #include #include +#include #include "CellularNetwork.h" #include "CellularPower.h" @@ -28,9 +32,10 @@ // modem type is defined as CELLULAR_DEVICE macro #define _CELLULAR_STRINGIFY(a) #a #define CELLULAR_STRINGIFY(a) _CELLULAR_STRINGIFY(a) -#include "CellularTargets.h" #include CELLULAR_STRINGIFY(CELLULAR_DEVICE.h) +namespace mbed { + const int PIN_SIZE = 8; /** CellularConnectionUtil class @@ -79,7 +84,7 @@ public: /** Get event queue that can be chained to main event queue (or use start_dispatch) * @return event queue */ - EventQueue* get_queue(); + events::EventQueue* get_queue(); /** Start event queue dispatching * @return see nsapi_error_t, 0 on success @@ -133,15 +138,18 @@ private: CellularState _state; CellularState _next_state; - mbed::Callback _status_callback; + Callback _status_callback; CellularNetwork *_network; CellularPower *_power; - EventQueue _queue; - Thread *_queue_thread; + events::EventQueue _queue; + rtos::Thread *_queue_thread; CellularDevice *_cellularDevice; char _sim_pin[PIN_SIZE+1]; }; +} // namespace + +#endif // CELLULAR_DEVICE #endif /* _CELLULAR_CONNECTION_UTIL_H */ diff --git a/features/cellular/easy_cellular/EasyCellularConnection.cpp b/features/cellular/easy_cellular/EasyCellularConnection.cpp index 9d23ed10af..6122764a27 100644 --- a/features/cellular/easy_cellular/EasyCellularConnection.cpp +++ b/features/cellular/easy_cellular/EasyCellularConnection.cpp @@ -15,19 +15,24 @@ * limitations under the License. */ -#include +#include "CellularTargets.h" +#ifdef CELLULAR_DEVICE + +#if NSAPI_PPP_AVAILABLE +#include "nsapi_ppp.h" +#endif #include "CellularConnectionUtil.h" -#include "CellularTargets.h" #include "CellularUtil.h" #include "EasyCellularConnection.h" #include "CellularLog.h" -#include "CellularConnectionUtil.h" +namespace mbed { + static CellularConnectionUtil cellularConnection; -static Semaphore cellularSemaphore(0); +static rtos::Semaphore cellularSemaphore(0); static UARTSerial cellularSerial(MDMTXD, MDMRXD, MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE); @@ -157,3 +162,7 @@ NetworkStack *EasyCellularConnection::get_stack() return cellularConnection.get_stack(); #endif // #if NSAPI_PPP_AVAILABLE } + +} // namespace + +#endif // CELLULAR_DEVICE diff --git a/features/cellular/easy_cellular/EasyCellularConnection.h b/features/cellular/easy_cellular/EasyCellularConnection.h index 4af9ea8b49..b05ed1d863 100644 --- a/features/cellular/easy_cellular/EasyCellularConnection.h +++ b/features/cellular/easy_cellular/EasyCellularConnection.h @@ -18,9 +18,13 @@ #ifndef EASY_CELLULAR_CONNECTION_H #define EASY_CELLULAR_CONNECTION_H -#include "netsocket/CellularBase.h" #include "CellularConnectionUtil.h" +#ifdef CELLULAR_DEVICE + +#include "netsocket/CellularBase.h" +namespace mbed { + /** EasyCellularConnection class * * Simplified adapter for cellular connection @@ -132,6 +136,10 @@ private: CellularConnectionUtil::CellularState _target_state; }; +} // namespace + +#endif // CELLULAR_DEVICE + #endif // EASY_CELLULAR_CONNECTION_H /** @}*/ diff --git a/features/cellular/framework/common/CellularTargets.h b/features/cellular/framework/common/CellularTargets.h index 6cc65e74fc..df86fbad10 100644 --- a/features/cellular/framework/common/CellularTargets.h +++ b/features/cellular/framework/common/CellularTargets.h @@ -34,9 +34,8 @@ namespace mbed { #define CELLULAR_DEVICE UBLOX_C027 #elif TARGET_UBLOX_C027 #define CELLULAR_DEVICE UBLOX_C027 - #else -#error Cellular target not defined, see cellular/targets.h +//#error Cellular target not defined, see cellular/targets.h //#define CELLULAR_TARGET //#define MDMTXD //#define MDMRXD