My fork of the HTTPServer (working)

Dependents:   DGWWebServer LAN2

Embed: (wiki syntax)

« Back to documentation index

NetServer Class Reference

Network main class provides the basic network features. More...

#include <NetServer.h>

Public Member Functions

 ~NetServer ()
 Default destructor.
void setIPAddr (const struct ip_addr &value)
 Set MBed IP Address.
struct ip_addr & getIPAddr ()
 Get MBed IP Address.
void setNetmask (const struct ip_addr &value)
 Set Netmask.
struct ip_addr & getNetmask ()
 Get Netmask.
void setGateway (const struct ip_addr &value)
 Set default Gateway.
struct ip_addr & getGateway ()
 Get default Gateway.
void setDNS1 (const struct ip_addr &value)
 Set first Domain Name Server.
struct ip_addr & getDNS1 ()
 Get first Domain Name Server.
void setDNS2 (const struct ip_addr &value)
 Set second Domain Name Server.
struct ip_addr & getDNS2 ()
 Get second Domain Name Server.
void setHostname (char *value)
 Set MBed Hostname.
const char * getHostname () const
 Get MBed Hostname.
void setUseDHCP (const bool &value)
 Define if DHCP sould be used.
const bool & getUseDHCP () const
 Is the mbed board trying to use DHCP?
void init ()
 Initialise the network environment.
void setUp () const
 Set the network interface up.
void setDown () const
 Set the network interface down.
void waitUntilReady ()
 This function waits until the network interface is Up.
TCPCallbackListener * bindTCPPort (u16_t, err_t(*)(TCPCallbackListener *, struct tcp_pcb *, err_t)) const
 Bind Callbackfunctions to a TCPPort.
void free (TCPItem *item) const
 Frees TCPItems because they cant do it directly.

Static Public Member Functions

static NetServercreate ()
 Returns you the NetServer instance.
static NetServercreate (const struct ip_addr &ip, const struct ip_addr &netmask, const struct ip_addr &gateway)
 Returns you the NetServer instance.
static NetServerready ()
 Returns you the NetServer instance.
static NetServerget ()
 Returns you the NetServer instance.
static void poll ()
 Polls one time on the NetServer and all registert Interfaces.

Protected Member Functions

 NetServer ()
 Default constructor tryes to bring the network interface up with dhcp.
 NetServer (struct ip_addr me_ip, struct ip_addr netmask, struct ip_addr gateway)
 Constructor for fix ip setting.

Detailed Description

Network main class provides the basic network features.

Definition at line 22 of file NetServer.h.


Constructor & Destructor Documentation

~NetServer (  )

Default destructor.

Definition at line 40 of file NetServer.cpp.

NetServer (  ) [protected]

Default constructor tryes to bring the network interface up with dhcp.

Definition at line 26 of file NetServer.cpp.

NetServer ( struct ip_addr  me_ip,
struct ip_addr  netmask,
struct ip_addr  gateway 
) [protected]

Constructor for fix ip setting.

Definition at line 34 of file NetServer.cpp.


Member Function Documentation

TCPCallbackListener * bindTCPPort ( u16_t  port,
err_t(*)(TCPCallbackListener *, struct tcp_pcb *, err_t)  accept 
) const

Bind Callbackfunctions to a TCPPort.

It provides a clean lowlevel Interface to the TCPLayer.

Definition at line 95 of file NetServer.cpp.

static NetServer* create ( const struct ip_addr &  ip,
const struct ip_addr &  netmask,
const struct ip_addr &  gateway 
) [static]

Returns you the NetServer instance.

If there is no object it will create a new one. But it will not initialise it. You have to insert ipaddres, netmask and gateway.

Definition at line 43 of file NetServer.h.

static NetServer* create (  ) [static]

Returns you the NetServer instance.

If there is no object it will create a new one. But it will not initialise it. Configure the object for DHCP.

Definition at line 30 of file NetServer.h.

void free ( TCPItem item ) const

Frees TCPItems because they cant do it directly.

Definition at line 101 of file NetServer.cpp.

static NetServer* get (  ) [static]

Returns you the NetServer instance.

Even if there is no one created. That means use with care and in combination with NetServer::ready(). It is mutch quicker than NetServer::ready(). First call one time NetServer::ready() and then NetServer::get() and you are save.

Definition at line 76 of file NetServer.h.

struct ip_addr& getDNS1 (  ) [read]

Get first Domain Name Server.

Definition at line 134 of file NetServer.h.

struct ip_addr& getDNS2 (  ) [read]

Get second Domain Name Server.

Definition at line 144 of file NetServer.h.

struct ip_addr& getGateway (  ) [read]

Get default Gateway.

Definition at line 124 of file NetServer.h.

const char* getHostname (  ) const

Get MBed Hostname.

Definition at line 154 of file NetServer.h.

struct ip_addr& getIPAddr (  ) [read]

Get MBed IP Address.

Definition at line 104 of file NetServer.h.

struct ip_addr& getNetmask (  ) [read]

Get Netmask.

Definition at line 114 of file NetServer.h.

const bool& getUseDHCP (  ) const

Is the mbed board trying to use DHCP?

Definition at line 165 of file NetServer.h.

void init (  )

Initialise the network environment.

Set up all services. Please call after configuration.

Definition at line 54 of file NetServer.cpp.

static void poll (  ) [static]

Polls one time on the NetServer and all registert Interfaces.

Even if there is no one created. That means use with care and in combination with NetServer::ready(). It is mutch faster than NetServer::ready()->_poll(). First call one time NetServer::ready() and then NetServer::poll() and you are save.

Definition at line 88 of file NetServer.h.

static NetServer* ready (  ) [static]

Returns you the NetServer instance.

If there is no object it will create a new one and it will initialise it. A new created object will ever use DHCP and the default MAC address and default hostname.

Definition at line 57 of file NetServer.h.

void setDNS1 ( const struct ip_addr &  value )

Set first Domain Name Server.

Definition at line 129 of file NetServer.h.

void setDNS2 ( const struct ip_addr &  value )

Set second Domain Name Server.

Definition at line 139 of file NetServer.h.

void setDown (  ) const

Set the network interface down.

To disable the network interface temporary. To make the interface avalible again use setUp().

Definition at line 82 of file NetServer.cpp.

void setGateway ( const struct ip_addr &  value )

Set default Gateway.

Definition at line 119 of file NetServer.h.

void setHostname ( char *  value )

Set MBed Hostname.

Definition at line 149 of file NetServer.h.

void setIPAddr ( const struct ip_addr &  value )

Set MBed IP Address.

Definition at line 100 of file NetServer.h.

void setNetmask ( const struct ip_addr &  value )

Set Netmask.

Definition at line 109 of file NetServer.h.

void setUp (  ) const

Set the network interface up.

To enable the network interface after calling setDown() Automaticly called from init().

Definition at line 78 of file NetServer.cpp.

void setUseDHCP ( const bool &  value )

Define if DHCP sould be used.

Parameters:
valueBool if true dhcp is used else a static ip setting is assumed.

Definition at line 160 of file NetServer.h.

void waitUntilReady (  )

This function waits until the network interface is Up.

To use to wait after init with DHCP. Helps continue work after the network interface is completly up.

Definition at line 86 of file NetServer.cpp.