diff --git a/features/cellular/easy_cellular/CellularConnectionUtil.cpp b/features/cellular/easy_cellular/CellularConnectionUtil.cpp index d8fd04d3a4..d3de1ffe05 100644 --- a/features/cellular/easy_cellular/CellularConnectionUtil.cpp +++ b/features/cellular/easy_cellular/CellularConnectionUtil.cpp @@ -533,3 +533,8 @@ CellularDevice* CellularConnectionUtil::get_device() return NULL; } } + +NetworkStack *CellularConnectionUtil::get_stack() +{ + return _cellularDevice->get_stack(); +} diff --git a/features/cellular/easy_cellular/CellularConnectionUtil.h b/features/cellular/easy_cellular/CellularConnectionUtil.h index 40cb8105b9..f36dedba30 100644 --- a/features/cellular/easy_cellular/CellularConnectionUtil.h +++ b/features/cellular/easy_cellular/CellularConnectionUtil.h @@ -76,6 +76,10 @@ protected: bool get_attach_network(CellularNetwork::AttachStatus &status); bool set_attach_network(); +protected: + friend class EasyCellularConnection; + NetworkStack *get_stack(); + private: void device_ready(); void report_failure(const char* msg); diff --git a/features/cellular/easy_cellular/EasyCellularConnection.cpp b/features/cellular/easy_cellular/EasyCellularConnection.cpp index b4e56a7dd2..669437b916 100644 --- a/features/cellular/easy_cellular/EasyCellularConnection.cpp +++ b/features/cellular/easy_cellular/EasyCellularConnection.cpp @@ -149,6 +149,6 @@ NetworkStack *EasyCellularConnection::get_stack() #if NSAPI_PPP_AVAILABLE return nsapi_ppp_get_stack(); #else - return NULL;//cellularConnection.get_network(); + return cellularConnection.get_stack(); #endif // #if NSAPI_PPP_AVAILABLE } diff --git a/features/cellular/framework/API/CellularDevice.h b/features/cellular/framework/API/CellularDevice.h index 4bd7013283..b919fb5bd4 100644 --- a/features/cellular/framework/API/CellularDevice.h +++ b/features/cellular/framework/API/CellularDevice.h @@ -26,6 +26,7 @@ #include "CellularPower.h" #include "CellularMultiplexer.h" #include "CellularInformation.h" +#include "NetworkStack.h" namespace mbed { @@ -114,6 +115,12 @@ public: * @param timeout milliseconds to wait response from modem */ virtual void set_timeout(int timeout) = 0; + + /** Get network stack. + * + * @return network stack + */ + virtual NetworkStack *get_stack() = 0; }; } // namespace mbed diff --git a/features/cellular/framework/AT/AT_CellularDevice.cpp b/features/cellular/framework/AT/AT_CellularDevice.cpp index 84b6ebdd31..37efdc9bd4 100644 --- a/features/cellular/framework/AT/AT_CellularDevice.cpp +++ b/features/cellular/framework/AT/AT_CellularDevice.cpp @@ -246,3 +246,11 @@ void AT_CellularDevice::set_timeout(int timeout) atHandler = atHandler->_nextATHandler; } } + +NetworkStack *AT_CellularDevice::get_stack() +{ + if (!_network) { + return NULL; + } + return _network->get_stack(); +} diff --git a/features/cellular/framework/AT/AT_CellularDevice.h b/features/cellular/framework/AT/AT_CellularDevice.h index 9185306d41..8d45aab4ec 100644 --- a/features/cellular/framework/AT/AT_CellularDevice.h +++ b/features/cellular/framework/AT/AT_CellularDevice.h @@ -127,6 +127,12 @@ public: // CellularDevice */ virtual void set_timeout(int timeout); + /** Get network stack. + * + * @return network stack + */ + NetworkStack *get_stack(); + protected: AT_CellularNetwork *_network; AT_CellularSMS *_sms;