I added functionality to get the RSSI, BER, and Cell Neighbor for reporting connection issues to M2X
Dependencies: WncControllerK64F
Diff: WNCInterface.cpp
- Revision:
- 8:4b38bfb1704d
- Parent:
- 7:fded23f50479
- Child:
- 9:9f0578ff157a
diff -r fded23f50479 -r 4b38bfb1704d WNCInterface.cpp --- a/WNCInterface.cpp Thu Oct 06 21:17:18 2016 +0000 +++ b/WNCInterface.cpp Fri Oct 07 00:36:47 2016 +0000 @@ -42,6 +42,7 @@ char * _fatal_err_loc; //GLOBAL::holds any error location info MODSERIAL * _dbgout; +Mutex _WNCLock; using namespace WncControllerK64F_fk; // namespace for the controller class use @@ -61,21 +62,18 @@ WncControllerK64F *WNCInterface::_pwnc; WncIpStats WNCInterface::myNetStats; string WNCInterface::mac; -Mutex *WNCInterface::WNCLock; WNCInterface::WNCInterface() { _dbgout = NULL; - WNCLock = new Mutex(); - WNCLock->unlock(); } void WNCInterface::doDebug( int v ) { //basic debug = 0x01 //more debug = 0x02 //all debug = 0x03 - WNCLock->lock(); + M_LOCK; _pwnc->enableDebug( (v&1), (v&2) ); - WNCLock->unlock(); + M_ULOCK; } // @@ -92,7 +90,7 @@ int WNCInterface::init(const char* apn, MODSERIAL * debug) { int ret = 0; - WNCLock->lock(); + M_LOCK; if( debug ) { _dbgout = debug; _pwnc = new WncControllerK64F_fk::WncControllerK64F::WncControllerK64F(&wncPinList, &mdmUart, debug); @@ -109,7 +107,7 @@ ret = ( _pwnc->powerWncOn(apn,40) )? 2:0; ret |= ( _pwnc->setApnName(apn) )? 1:0; ret |= ( _pwnc->getWncNetworkingStats(&myNetStats) )? 4:0; - WNCLock->unlock(); + M_ULOCK; return ret; } @@ -135,14 +133,14 @@ // update the networking stats and return the IP Address // char * WNCInterface::getIPAddress() { - WNCLock->lock(); + M_LOCK; if ( _pwnc->getWncNetworkingStats(&myNetStats) ) { if( WNCInterface::_pwnc->getWncStatus() == FATAL_FLAG ) FATAL_WNC_ERROR(null); - WNCLock->unlock(); + M_ULOCK; return &myNetStats.ip[0]; } - WNCLock->unlock(); + M_ULOCK; return NULL; } @@ -150,14 +148,14 @@ // update the networking stats and return the Gateway Address // char * WNCInterface::getGateway() { - WNCLock->lock(); + M_LOCK; if ( _pwnc->getWncNetworkingStats(&myNetStats) ) { if( WNCInterface::_pwnc->getWncStatus() == FATAL_FLAG ) FATAL_WNC_ERROR(null); - WNCLock->unlock(); + M_ULOCK; return &WNCInterface::myNetStats.gateway[0]; } - WNCLock->unlock(); + M_ULOCK; return NULL; } @@ -165,14 +163,14 @@ // update the networking stats and return the Network Mask // char * WNCInterface::getNetworkMask() { - WNCLock->lock(); + M_LOCK; if ( _pwnc->getWncNetworkingStats(&myNetStats) ) { if( WNCInterface::_pwnc->getWncStatus() == FATAL_FLAG ) FATAL_WNC_ERROR(null); - WNCLock->unlock(); + M_ULOCK; return &WNCInterface::myNetStats.mask[0]; } - WNCLock->unlock(); + M_ULOCK; return NULL; } @@ -182,16 +180,16 @@ char* WNCInterface::getMACAddress( void ) { string str; - WNCLock->lock(); + M_LOCK; if( _pwnc->getICCID(&str) ) { if( WNCInterface::_pwnc->getWncStatus() == FATAL_FLAG ) FATAL_WNC_ERROR(null); mac = str.substr(3,20); mac[2]=mac[5]=mac[8]=mac[11]=mac[14]=':'; - WNCLock->unlock(); + M_ULOCK; return (char*)mac.c_str(); } - WNCLock->unlock(); + M_ULOCK; return NULL; }