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.

Files at this revision

API Documentation at this revision

Comitter:
JMF
Date:
Fri Mar 24 22:02:33 2017 +0000
Parent:
27:2dc9461c04dc
Child:
29:b278b745fb4f
Commit message:
Finished prefixing all WNC networking classes

Changed in this revision

Socket/WncEndpoint.h Show annotated file Show diff for this revision Revisions of this file
Socket/WncSocket.cpp Show annotated file Show diff for this revision Revisions of this file
Socket/WncSocket.h Show annotated file Show diff for this revision Revisions of this file
Socket/WncTCPSocketConnection.cpp Show annotated file Show diff for this revision Revisions of this file
Socket/WncTCPSocketConnection.h Show annotated file Show diff for this revision Revisions of this file
Socket/WncUDPSocket.cpp Show annotated file Show diff for this revision Revisions of this file
Socket/WncUDPSocket.h 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/Socket/WncEndpoint.h	Fri Mar 24 21:50:50 2017 +0000
+++ b/Socket/WncEndpoint.h	Fri Mar 24 22:02:33 2017 +0000
@@ -33,10 +33,10 @@
   unsigned int port;
   };
 
-class UDPSocket;
+class WncUDPSocket;
 
 class WncEndpoint {
-    friend class UDPSocket;
+    friend class WncUDPSocket;
 
 public:
     WncEndpoint(void);
--- a/Socket/WncSocket.cpp	Fri Mar 24 21:50:50 2017 +0000
+++ b/Socket/WncSocket.cpp	Fri Mar 24 22:02:33 2017 +0000
@@ -31,21 +31,18 @@
 // Set up the defaults in the constructor.  If the caller doesn't change anything
 // the APN will be set for AT&T, port #40 and timeout 1.5 seconds
 //
-Socket::Socket() : 
+WncSocket::WncSocket() : 
   _sock_type(-1), 
-  _timeout(1500) {
-}
+  _timeout(1500) {}
 
-Socket::~Socket() {
-}
-
+WncSocket::~WncSocket() {}
 
 //
 // ensure we have a WNC Controller attached and initialized by calling to get the 
 // network status,  This will provide us with all the network information.  if we
 // are not connected, will return -1.
 // 
-int Socket::init(int timeout) {
+int WncSocket::init(int timeout) {
 
     _timeout = timeout;
     M_LOCK;
@@ -59,7 +56,7 @@
 // either a TCP or UDP socket. The user is also expected to provide a port #.  
 // If the connection failed for any reason return 0, otherwise, return 1;
 //
-int Socket::connect(char *url, int type, int port) {
+int WncSocket::connect(char *url, int type, int port) {
   int rslt;
   char address[5];
   
@@ -89,7 +86,7 @@
 // -1 if there was an error
 //  0 if we disconnected
 //
-int Socket::disconnect() {
+int WncSocket::disconnect() {
   if( _sock_type<0 )
     return 0;  //nothing is connected currently
 
@@ -100,7 +97,7 @@
   return ret;
 }
 
-void Socket::set_blocking(bool blocking, unsigned int timeout) {
+void WncSocket::set_blocking(bool blocking, unsigned int timeout) {
     blocking = blocking;
     timeout= timeout;
 
--- a/Socket/WncSocket.h	Fri Mar 24 21:50:50 2017 +0000
+++ b/Socket/WncSocket.h	Fri Mar 24 22:02:33 2017 +0000
@@ -33,11 +33,11 @@
 #define SOCK_DGRAM      2  //a UDP Socket type
 
 /** Socket file descriptor and select wrapper */
-class Socket {
+class WncSocket {
   
 public:
-    Socket();
-    ~Socket();
+    WncSocket();
+    ~WncSocket();
 
     int init(int timeout=1500);
 
--- a/Socket/WncTCPSocketConnection.cpp	Fri Mar 24 21:50:50 2017 +0000
+++ b/Socket/WncTCPSocketConnection.cpp	Fri Mar 24 22:02:33 2017 +0000
@@ -47,7 +47,7 @@
 
 
 int TCPSocketConnection::connect(const char* host, const int port) {
-    Socket::connect((char*)host, SOCK_STREAM, port);
+    WncSocket::connect((char*)host, SOCK_STREAM, port);
     _is_blocking = false;   // start out not blocking, user will set it if desired
     return ( WNCInterface::_pwnc->getWncStatus() == WncController_fk::WncController::WNC_ON )? 0:-1;
 }
@@ -115,7 +115,7 @@
 }
 
 int TCPSocketConnection::close(void) {
-  Socket::disconnect();
+  WncSocket::disconnect();
   M_LOCK;
   int ret = ( WNCInterface::_pwnc->getWncStatus() == WncController_fk::WncController::WNC_ON )? 0:-1;
   M_ULOCK;
--- a/Socket/WncTCPSocketConnection.h	Fri Mar 24 21:50:50 2017 +0000
+++ b/Socket/WncTCPSocketConnection.h	Fri Mar 24 22:02:33 2017 +0000
@@ -31,7 +31,7 @@
 /**
 TCP socket connection
 */
-class TCPSocketConnection : public Socket, public WncEndpoint {
+class TCPSocketConnection : public WncSocket, public WncEndpoint {
     
 public:
     TCPSocketConnection();
--- a/Socket/WncUDPSocket.cpp	Fri Mar 24 21:50:50 2017 +0000
+++ b/Socket/WncUDPSocket.cpp	Fri Mar 24 22:02:33 2017 +0000
@@ -27,32 +27,32 @@
 #include "WncUDPSocket.h"
 #include <cstring>
 
-UDPSocket::UDPSocket() :
+WncUDPSocket::WncUDPSocket() :
     _is_blocking(0),
     _btimeout(0){
 }
 
-UDPSocket::~UDPSocket() {
+WncUDPSocket::~WncUDPSocket() {
 }
 
-int UDPSocket::init(void) {
+int WncUDPSocket::init(void) {
     _is_blocking = false;   // start out not blocking, user will set it if desired
     return ( WNCInterface::_pwnc->getWncStatus() == WNC_GOOD )? 0:-1;
 }
 
 
-int UDPSocket::close(void) {
-    Socket::disconnect();
+int WncUDPSocket::close(void) {
+    WncSocket::disconnect();
     return ( WNCInterface::_pwnc->getWncStatus() == WNC_GOOD )? 0:-1;
 }
 
 // -1 if unsuccessful, else number of bytes written
-int UDPSocket::sendTo(WncEndpoint &remote, char *packet, int length) {
+int WncUDPSocket::sendTo(WncEndpoint &remote, char *packet, int length) {
     int ret = -1;
     
     CHK_WNCFE(( WNCInterface::_pwnc->getWncStatus() == FATAL_FLAG ), fail);
     if( remote._epAddr.port ) {  //make sure the Endpoint has an port assoicated with it
-        if( Socket::connect(remote._epAddr.IP,SOCK_DGRAM,remote._epAddr.port) ) {
+        if( WncSocket::connect(remote._epAddr.IP,SOCK_DGRAM,remote._epAddr.port) ) {
             if( WNCInterface::_pwnc->write(0,(const uint8_t*)packet,length) )
                 ret = length;
             close();
@@ -65,7 +65,7 @@
 // blocking is used to make the WNC keep checking for incoming data for a
 // period of time.
 
-void UDPSocket::set_blocking (bool blocking, unsigned int timeout) {
+void WncUDPSocket::set_blocking (bool blocking, unsigned int timeout) {
     _is_blocking = blocking;   // true or false
     _btimeout = timeout;       // user specifies in msec
  
@@ -75,7 +75,7 @@
 }
 
 // -1 if unsuccessful, else number of bytes received
-int UDPSocket::receiveFrom(WncEndpoint &remote, char *buffer, int length) {
+int WncUDPSocket::receiveFrom(WncEndpoint &remote, char *buffer, int length) {
     const uint8_t *ptr;
     Timer t;
     int done, ret = -1;
@@ -85,7 +85,7 @@
       return -1;
 
     CHK_WNCFE(( WNCInterface::_pwnc->getWncStatus() == FATAL_FLAG ), fail);
-    ret = Socket::connect(remote._epAddr.IP,SOCK_DGRAM,remote._epAddr.port);        
+    ret = WncSocket::connect(remote._epAddr.IP,SOCK_DGRAM,remote._epAddr.port);        
     
     t.start();
     do {
--- a/Socket/WncUDPSocket.h	Fri Mar 24 21:50:50 2017 +0000
+++ b/Socket/WncUDPSocket.h	Fri Mar 24 22:02:33 2017 +0000
@@ -32,11 +32,11 @@
 /**
 UDP Socket
 */
-class UDPSocket : public Socket, public WNCInterface {
+class WncUDPSocket : public WncSocket, public WNCInterface {
     
 public:
-    UDPSocket();
-    ~UDPSocket();
+    WncUDPSocket();
+    ~WncUDPSocket();
 
     int init(void);
 
--- a/WNCInterface.h	Fri Mar 24 21:50:50 2017 +0000
+++ b/WNCInterface.h	Fri Mar 24 22:02:33 2017 +0000
@@ -88,9 +88,9 @@
 // will allow the Socket class to get to the WNC functions needed for the
 // socket. Forward reference the class
 
-class Socket;
+class WncSocket;
 class WncEndpoint;
-class UDPSocket;
+class WncUDPSocket;
 class TCPSocketConnection;
 class WNCSms;
 
@@ -98,9 +98,9 @@
 {
   class WncControllerK64F;  //forward reference the Controller Class
   friend class TCPSocketConnection;
-  friend class UDPSocket;
+  friend class WncUDPSocket;
   friend class WncEndpoint;
-  friend class Socket;
+  friend class WncSocket;
   friend class WNCSms;
 
 public: