Enable connection status callback with EasyCellularConnection

pull/6082/head
Juho Eskeli 2018-02-19 09:13:33 +02:00 committed by Ari Parkkila
parent 58c8176247
commit 331a27df63
3 changed files with 17 additions and 6 deletions

View File

@ -498,9 +498,6 @@ events::EventQueue *CellularConnectionUtil::get_queue()
CellularNetwork* CellularConnectionUtil::get_network() CellularNetwork* CellularConnectionUtil::get_network()
{ {
if (_state != STATE_CONNECTED) {
return NULL;
}
return _network; return _network;
} }

View File

@ -17,7 +17,7 @@
#include "CellularTargets.h" #include "CellularTargets.h"
#ifdef CELLULAR_DEVICE #ifdef CELLULAR_DEVICE
#if NSAPI_PPP_AVAILABLE #if NSAPI_PPP_AVAILABLE
#include "nsapi_ppp.h" #include "nsapi_ppp.h"
#endif #endif
@ -154,6 +154,14 @@ const char *EasyCellularConnection::get_gateway()
return cellularConnection.get_network()->get_gateway(); return cellularConnection.get_network()->get_gateway();
} }
void EasyCellularConnection::attach(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb)
{
CellularNetwork * network = cellularConnection.get_network();
if (network) {
network->attach(status_cb);
}
}
NetworkStack *EasyCellularConnection::get_stack() NetworkStack *EasyCellularConnection::get_stack()
{ {
#if NSAPI_PPP_AVAILABLE #if NSAPI_PPP_AVAILABLE

View File

@ -20,11 +20,11 @@
#include "CellularConnectionUtil.h" #include "CellularConnectionUtil.h"
#ifdef CELLULAR_DEVICE #ifdef CELLULAR_DEVICE
#include "netsocket/CellularBase.h" #include "netsocket/CellularBase.h"
namespace mbed { namespace mbed {
/** EasyCellularConnection class /** EasyCellularConnection class
* *
* Simplified adapter for cellular connection * Simplified adapter for cellular connection
@ -117,6 +117,12 @@ public:
*/ */
virtual const char *get_gateway(); virtual const char *get_gateway();
/** Register callback for status reporting
*
* @param status_cb The callback for status changes
*/
virtual void attach(mbed::Callback<void(nsapi_event_t, intptr_t)> status_cb);
protected: protected:
/** Provide access to the NetworkStack object /** Provide access to the NetworkStack object