Embedded WebSockets Experiment

Dependencies:   mbed MD5

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 (const 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.
int isUp () const
 Returns 1 if the network is up otherwise 0.
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 23 of file NetServer.h.


Constructor & Destructor Documentation

~NetServer (  )

Default destructor.

Definition at line 42 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 35 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 101 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 44 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 31 of file NetServer.h.

void free ( TCPItem item ) const

Frees TCPItems because they cant do it directly.

Definition at line 107 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 77 of file NetServer.h.

struct ip_addr& getDNS1 (  ) [read]

Get first Domain Name Server.

Definition at line 135 of file NetServer.h.

struct ip_addr& getDNS2 (  ) [read]

Get second Domain Name Server.

Definition at line 145 of file NetServer.h.

struct ip_addr& getGateway (  ) [read]

Get default Gateway.

Definition at line 125 of file NetServer.h.

const char* getHostname (  ) const

Get MBed Hostname.

Definition at line 155 of file NetServer.h.

struct ip_addr& getIPAddr (  ) [read]

Get MBed IP Address.

Definition at line 105 of file NetServer.h.

struct ip_addr& getNetmask (  ) [read]

Get Netmask.

Definition at line 115 of file NetServer.h.

const bool& getUseDHCP (  ) const

Is the mbed board trying to use DHCP?

Definition at line 166 of file NetServer.h.

void init (  )

Initialise the network environment.

Set up all services. Please call after configuration.

Definition at line 56 of file NetServer.cpp.

int isUp (  ) const

Returns 1 if the network is up otherwise 0.

Definition at line 88 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 89 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 58 of file NetServer.h.

void setDNS1 ( const struct ip_addr &  value )

Set first Domain Name Server.

Definition at line 130 of file NetServer.h.

void setDNS2 ( const struct ip_addr &  value )

Set second Domain Name Server.

Definition at line 140 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 84 of file NetServer.cpp.

void setGateway ( const struct ip_addr &  value )

Set default Gateway.

Definition at line 120 of file NetServer.h.

void setHostname ( const char *  value )

Set MBed Hostname.

Definition at line 150 of file NetServer.h.

void setIPAddr ( const struct ip_addr &  value )

Set MBed IP Address.

Definition at line 101 of file NetServer.h.

void setNetmask ( const struct ip_addr &  value )

Set Netmask.

Definition at line 110 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 80 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 161 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 92 of file NetServer.cpp.