Ethernetwebsoc

Dependencies:   C12832_lcd LM75B WebSocketClient mbed-rtos mbed Socket lwip-eth lwip-sys lwip

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers EthernetInterface.h Source File

EthernetInterface.h

00001 /* EthernetInterface.h */
00002 /* Copyright (C) 2012 mbed.org, MIT License
00003  *
00004  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
00005  * and associated documentation files (the "Software"), to deal in the Software without restriction,
00006  * including without limitation the rights to use, copy, modify, merge, publish, distribute,
00007  * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
00008  * furnished to do so, subject to the following conditions:
00009  *
00010  * The above copyright notice and this permission notice shall be included in all copies or
00011  * substantial portions of the Software.
00012  *
00013  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
00014  * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
00015  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
00016  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00017  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00018  */
00019  
00020 #ifndef ETHERNETINTERFACE_H_
00021 #define ETHERNETINTERFACE_H_
00022 
00023 #include "rtos.h"
00024 #include "lwip/netif.h"
00025 
00026  /** Interface using Ethernet to connect to an IP-based network
00027  *
00028  */
00029 class EthernetInterface {
00030 public:
00031   /** Initialize the interface with DHCP.
00032   * Initialize the interface and configure it to use DHCP (no connection at this point).
00033   * \return 0 on success, a negative number on failure
00034   */
00035   static int init(); //With DHCP
00036 
00037   /** Initialize the interface with a static IP address.
00038   * Initialize the interface and configure it with the following static configuration (no connection at this point).
00039   * \param ip the IP address to use
00040   * \param mask the IP address mask
00041   * \param gateway the gateway to use
00042   * \return 0 on success, a negative number on failure
00043   */
00044   static int init(const char* ip, const char* mask, const char* gateway);
00045 
00046   /** Connect
00047   * Bring the interface up, start DHCP if needed.
00048   * \return 0 on success, a negative number on failure
00049   */
00050   static int connect();
00051   
00052   /** Disconnect
00053   * Bring the interface down
00054   * \return 0 on success, a negative number on failure
00055   */
00056   static int disconnect();
00057   
00058   static char* getIPAddress();
00059 };
00060 
00061 #include "TCPSocketConnection.h"
00062 #include "TCPSocketServer.h"
00063 
00064 #include "Endpoint.h"
00065 #include "UDPSocket.h"
00066 
00067 #endif /* ETHERNETINTERFACE_H_ */