The WDCInterface is is a drop-in replacement for an EthernetInterface class that allows the user to connect to the Internet with a Wistron NeWeb Corporation (WNC) M14A2A Series data module using the standard network Socket API's. This interface class is used in the AT&T Cellular IoT Starter Kit which is sold by Avnet (http://cloudconnectkits.org/product/att-cellular-iot-starter-kit).
Dependencies: WncControllerK64F
Dependents: WNCProximityMqtt Pubnub_ATT_IoT_SK_WNC_sync BluemixDemo BluemixQS ... more
See the WNCInterface README in the Wiki tab for detailed information on this library.
Revision 3:1d7e6ed11269, committed 2016-09-27
- Comitter:
- JMF
- Date:
- Tue Sep 27 19:16:22 2016 +0000
- Parent:
- 2:dab56b75d4dd
- Child:
- 4:99e7aeaceae7
- Commit message:
- Changed creation of WncControllerK64F class from static to dynamic so that it can be created either with or without the debug port. The caller must provide a pointer to a MODSERIAL object if they want debug output.
Changed in this revision
| WNCInterface.cpp | Show annotated file Show diff for this revision Revisions of this file |
| WNCInterface.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/WNCInterface.cpp Tue Sep 27 16:29:16 2016 +0000
+++ b/WNCInterface.cpp Tue Sep 27 19:16:22 2016 +0000
@@ -57,30 +57,18 @@
static MODSERIAL mdmUart(PTD3,PTD2,256,4096); //UART for WNC Module
-#if WNC_DEBUG == 1
-static MODSERIAL debugUart(USBTX,USBRX,256,256); //UART used for stdio/stderr
-static WncControllerK64F wnc(&wncPinList, &mdmUart, &debugUart);
-#else
-static WncControllerK64F wnc(&wncPinList, &mdmUart, NULL);
-#endif
-
-WncControllerK64F *WNCInterface::_pwnc = &wnc;
+WncControllerK64F *WNCInterface::_pwnc;
WncIpStats WNCInterface::myNetStats;
string WNCInterface::mac;
WNCInterface::WNCInterface() {
-#if WNC_DEBUG == 1
- debugUart.baud(115200); // set stdio/stderr. use 115.2K since the WNC part uses this--keep up.
-#endif
}
void WNCInterface::doDebug( int v ) {
-#if WNC_DEBUG == 1
//basic debug = 0x01
//more debug = 0x02
//all debug = 0x03
_pwnc->enableDebug( (v&1), (v&2) );
-#endif
}
//
@@ -94,20 +82,18 @@
// Returns: 0 if unable to initialize the WNC module
// -1 if successfully initialized
//
-int WNCInterface::init(const char* apn, int debug) {
+int WNCInterface::init(const char* apn, MODSERIAL * debug) {
int ret = 0;
_pwnc = &wnc; //set the pointer to the WNC controller class. Used for all WNC accesses
+ if( debug )
+ _pwnc = new WncControllerK64F_fk::WncControllerK64F::WncControllerK64F(&wncPinList, &mdmUart, debug);
+ else
+ _pwnc = new WncControllerK64F_fk::WncControllerK64F::WncControllerK64F(&wncPinList, &mdmUart, NULL);
+
if( apn==NULL )
apn = APN_DEFAULT;
-#if WNC_DEBUG == 1
- if( debug )
- _pwnc->enableDebug( (debug&1), (debug&2) );
-#else
- debug=debug; //keep the compiler from complaining.
-#endif
-
ret = ( _pwnc->powerWncOn(apn,40) )? 2:0;
ret |= ( _pwnc->setApnName(apn) )? 1:0;
ret |= ( _pwnc->getWncNetworkingStats(&myNetStats) )? 4:0;
@@ -184,3 +170,4 @@
return NULL;
}
+
--- a/WNCInterface.h Tue Sep 27 16:29:16 2016 +0000
+++ b/WNCInterface.h Tue Sep 27 19:16:22 2016 +0000
@@ -35,6 +35,8 @@
//0=simply return failed response for all socket calls
#define DISPLAY_FE 1 //1 to display the fatal error when it occurs
//0 to NOT display the fatal error
+#define RESETON_FE 1 //1 to cause the MCU to reset on fatal error
+ //0 to NOT reset the MCU
#define APN_DEFAULT "m2m.com.attz"
//
@@ -46,25 +48,34 @@
#define RETfail return -1
#define RETvoid return
#define RETnull return NULL
+#define RETresume
+
#define DORET(x) RET##x
#define TOSTR(x) #x
#define INTSTR(x) TOSTR(x)
#define FATAL_STR __FILE__ ":" INTSTR(__LINE__)
+#if RESETON_FE == 1
+#define MCURESET ((*((volatile unsigned long *)0xE000ED0CU))=(unsigned long)((0x5fa<<16) | 0x04L))
+#define RSTMSG "RESET MCU! "
+#else
+#define MCURESET
+#define RSTMSG ""
+#endif
+
#if DISPLAY_FE == 1
-#define PFE printf("WNC FAILED @ %s\r\n", FATAL_STR)
+#define PFE printf(RSTMSG "WNC FAILED @ %s\r\n", FATAL_STR)
#else
#define PFE
#endif
#if STOP_ON_FE == 1
-#define FATAL_WNC_ERROR(v) {extern char *_fatal_err_loc;_fatal_err_loc=FATAL_STR;PFE;while(1);}
+#define FATAL_WNC_ERROR(v) {extern char *_fatal_err_loc;_fatal_err_loc=FATAL_STR;PFE;MCURESET;while(1);}
#else
#define FATAL_WNC_ERROR(v) {extern char *_fatal_err_loc;_fatal_err_loc=FATAL_STR;PFE;DORET(v);}
#endif
-
// Because the WncController has intermixed socket & interface functionallity
// will need to make the Socket class a friend of the Interface class. This
// will allow the Socket class to get to the WNC functions needed for the
@@ -90,7 +101,7 @@
/** Initialize the interface (no connection at this point).
* \return 0 on success, a negative number on failure
*/
- static int init(const char* apn=NULL, int debug=0);
+ static int init(const char* apn=NULL, MODSERIAL * debug=NULL);
/** Open an LTE internet data connection
@return 0 on success, error code on failure

