modified by ohneta

Dependents:   HelloESP8266Interface_mine

Fork of NetworkSocketAPI by NetworkSocketAPI

Embed: (wiki syntax)

« Back to documentation index

NetworkInterface Class Reference

NetworkInterface Class Reference

NetworkInterface class. More...

#include <NetworkInterface.h>

Inherited by EthernetInterface, and WiFiInterface.

Public Member Functions

virtual int32_t init (void)=0
 Initialize the network interface with DHCP.
virtual int32_t init (const char *ip, const char *mask, const char *gateway)=0
 Initialize the network interface with a static IP address.
virtual int32_t connect (uint32_t timeout_ms=15000)=0
 Start the interface, using DHCP if needed.
virtual int32_t disconnect (void)=0
 Stop the interface, bringing down dhcp if necessary.
virtual char * getIPAddress (void)=0
 Get the current IP address.
virtual char * getGateway (void) const =0
 Get the current gateway address.
virtual char * getNetworkMask (void) const =0
 Get the current network mask.
virtual char * getMACAddress (void) const =0
 Get the devices MAC address.
virtual int32_t isConnected (void)=0
 Get the current status of the interface connection.
virtual SocketInterfaceallocateSocket (socket_protocol_t socketProtocol)=0
 Allocate space for a socket.
virtual int deallocateSocket (SocketInterface *socket)=0
 Deallocate space for a socket.

Protected Attributes

std::map< uint32_t,
SocketInterface * > 
sockets
 Map used to keep track of all SocketInterface instances.
uint32_t uuidCounter
 Counter used to create unique handles for new sockets.

Detailed Description

NetworkInterface class.

This is a common interface that is shared between all hardware that connect to a network over IP.

Definition at line 28 of file NetworkInterface.h.


Member Function Documentation

virtual SocketInterface* allocateSocket ( socket_protocol_t  socketProtocol ) [pure virtual]

Allocate space for a socket.

Parameters:
Thetype of socket you want to open, SOCK_TCP or SOCK_UDP
Returns:
a pointer to the allocated socket.
virtual int32_t connect ( uint32_t  timeout_ms = 15000 ) [pure virtual]

Start the interface, using DHCP if needed.

Parameters:
timeout_msTime in miliseconds to wait while attempting to connect before timing out
Returns:
0 on success, a negative number on failure
virtual int deallocateSocket ( SocketInterface socket ) [pure virtual]

Deallocate space for a socket.

Parameters:
Anallocated SocketInterface
Returns:
0 if object is destroyed, -1 otherwise
virtual int32_t disconnect ( void   ) [pure virtual]

Stop the interface, bringing down dhcp if necessary.

Returns:
0 on success, a negative number on failure
virtual char* getGateway ( void   ) const [pure virtual]

Get the current gateway address.

Returns:
a pointer to a string containing the gateway address.
virtual char* getIPAddress ( void   ) [pure virtual]

Get the current IP address.

Returns:
a pointer to a string containing the IP address.
virtual char* getMACAddress ( void   ) const [pure virtual]

Get the devices MAC address.

Returns:
a pointer to a string containing the mac address.
virtual char* getNetworkMask ( void   ) const [pure virtual]

Get the current network mask.

Returns:
a pointer to a string containing the network mask.
virtual int32_t init ( const char *  ip,
const char *  mask,
const char *  gateway 
) [pure virtual]

Initialize the network interface with a static IP address.

Parameters:
ipThe static IP address to use
maskThe IP address mask
gatewayThe gateway to use
Returns:
0 on success, a negative number on failure
virtual int32_t init ( void   ) [pure virtual]

Initialize the network interface with DHCP.

Returns:
0 on success, a negative number on failure
virtual int32_t isConnected ( void   ) [pure virtual]

Get the current status of the interface connection.

Returns:
true if connected, a negative number on failure

Field Documentation

std::map<uint32_t, SocketInterface*> sockets [protected]

Map used to keep track of all SocketInterface instances.

Definition at line 97 of file NetworkInterface.h.

uint32_t uuidCounter [protected]

Counter used to create unique handles for new sockets.

Should be incremented whenever a new socket is created.

Definition at line 102 of file NetworkInterface.h.