Base class for IP Based Networking Libraries

Dependencies:   DnsQuery

Dependents:   TempTower BSDInterfaceTests HelloBSDInterface ESP8266InterfaceTests ... more

For a complete getting started guide see the wiki...

Network Socket API

The Network Socket API provides a common interface for using sockets on network devices. The API provides a simple class-based interface that should be familiar to users experienced with other socket APIs. Additionally, the API provides a simple interface for implementing network devices, making it easy to connect hardware agnostic programs to new devices.

Network Interfaces

The NetworkInterface provides an abstract class for network devices that support sockets. Devices should provide a DeviceInterface class that inherits this interface and adds implementation specific methods for using the device. A NetworkInterface must be provided to a Socket constructor to open a socket on the interface. Currently two subclasses are defined for common devices, EthernetInterface and WiFiInterface.

Sockets

The Socket class is used for managing network sockets. Once opened, the socket provides a pipe through which data can sent and recieved to a specific endpoint. The socket class can be instantiated as either a TCPSocket or a UDPSocket which defines the protocol used for the connection.

Files at this revision

API Documentation at this revision

Comitter:
Christopher Haster
Date:
Wed Apr 20 11:07:19 2016 -0500
Parent:
113:80ba92c5e5ca
Child:
115:950b19eb0f02
Commit message:
Move get_mac_address into Interface interface

Changed in this revision

CellularInterface.h Show annotated file Show diff for this revision Revisions of this file
EthernetInterface.h Show annotated file Show diff for this revision Revisions of this file
MeshInterface.h Show annotated file Show diff for this revision Revisions of this file
NetworkStack.h Show annotated file Show diff for this revision Revisions of this file
SocketAddress.h Show annotated file Show diff for this revision Revisions of this file
WiFiInterface.h Show annotated file Show diff for this revision Revisions of this file
--- a/CellularInterface.h	Wed Apr 20 11:04:24 2016 -0500
+++ b/CellularInterface.h	Wed Apr 20 11:07:19 2016 -0500
@@ -40,6 +40,12 @@
      *  @return         0 on success, negative error code on failure
      */
     virtual int disconnect() = 0;
+
+    /** Get the local MAC address
+     *
+     *  @return         Null-terminated representation of the local MAC address
+     */
+    virtual const char *get_mac_address() = 0;
 };
  
 #endif
--- a/EthernetInterface.h	Wed Apr 20 11:04:24 2016 -0500
+++ b/EthernetInterface.h	Wed Apr 20 11:07:19 2016 -0500
@@ -37,6 +37,12 @@
      *  @return     0 on success, negative error code on failure
      */
     virtual int disconnect() = 0;
+
+    /** Get the local MAC address
+     *
+     *  @return         Null-terminated representation of the local MAC address
+     */
+    virtual const char *get_mac_address() = 0;
 };
 
 #endif
--- a/MeshInterface.h	Wed Apr 20 11:04:24 2016 -0500
+++ b/MeshInterface.h	Wed Apr 20 11:07:19 2016 -0500
@@ -37,6 +37,12 @@
      *  @return     0 on success, negative on failure
      */
     virtual int disconnect() = 0;
+
+    /** Get the local MAC address
+     *
+     *  @return         Null-terminated representation of the local MAC address
+     */
+    virtual const char *get_mac_address() = 0;
 };
 
 #endif
--- a/NetworkStack.h	Wed Apr 20 11:04:24 2016 -0500
+++ b/NetworkStack.h	Wed Apr 20 11:07:19 2016 -0500
@@ -77,14 +77,6 @@
     NSAPI_RCVBUF,    /*!< Sets recv buffer size */
 };
 
-/** Maximum size of MAC address representation
- */
-#define NSAPI_MAC_SIZE 18
-
-/** Maximum number of bytes for MAC address
- */
-#define NSAPI_MAC_BYTES 6
-
 
 /** NetworkStack class
  *
@@ -105,12 +97,6 @@
      */
     virtual const char *get_ip_address() = 0;
 
-    /** Get the local MAC address
-     *
-     *  @return         Null-terminated representation of the local MAC address
-     */
-    virtual const char *get_mac_address() = 0;
-
     /** Translates a hostname to an IP address
      *
      *  The hostname may be either a domain name or an IP address. If the
--- a/SocketAddress.h	Wed Apr 20 11:04:24 2016 -0500
+++ b/SocketAddress.h	Wed Apr 20 11:07:19 2016 -0500
@@ -28,6 +28,14 @@
  */
 #define NSAPI_IP_BYTES NSAPI_IPv6_BYTES
 
+/** Maximum size of MAC address representation
+ */
+#define NSAPI_MAC_SIZE 18
+
+/** Maximum number of bytes for MAC address
+ */
+#define NSAPI_MAC_BYTES 6
+
 /** Enum of IP address versions
  *
  *  The IP version specifies the type of an IP address.
--- a/WiFiInterface.h	Wed Apr 20 11:04:24 2016 -0500
+++ b/WiFiInterface.h	Wed Apr 20 11:07:19 2016 -0500
@@ -57,6 +57,12 @@
      *  @return          0 on success, negative error code on failure
      */
     virtual int disconnect() = 0;
+
+    /** Get the local MAC address
+     *
+     *  @return         Null-terminated representation of the local MAC address
+     */
+    virtual const char *get_mac_address() = 0;
 };
 
 #endif