Ethernetwebsoc

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

Committer:
GordonSin
Date:
Fri May 31 04:09:54 2013 +0000
Revision:
0:0ed2a7c7190c
31/5/2013;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
GordonSin 0:0ed2a7c7190c 1 /* EthernetInterface.h */
GordonSin 0:0ed2a7c7190c 2 /* Copyright (C) 2012 mbed.org, MIT License
GordonSin 0:0ed2a7c7190c 3 *
GordonSin 0:0ed2a7c7190c 4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
GordonSin 0:0ed2a7c7190c 5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
GordonSin 0:0ed2a7c7190c 6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
GordonSin 0:0ed2a7c7190c 7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
GordonSin 0:0ed2a7c7190c 8 * furnished to do so, subject to the following conditions:
GordonSin 0:0ed2a7c7190c 9 *
GordonSin 0:0ed2a7c7190c 10 * The above copyright notice and this permission notice shall be included in all copies or
GordonSin 0:0ed2a7c7190c 11 * substantial portions of the Software.
GordonSin 0:0ed2a7c7190c 12 *
GordonSin 0:0ed2a7c7190c 13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
GordonSin 0:0ed2a7c7190c 14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
GordonSin 0:0ed2a7c7190c 15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
GordonSin 0:0ed2a7c7190c 16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
GordonSin 0:0ed2a7c7190c 17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
GordonSin 0:0ed2a7c7190c 18 */
GordonSin 0:0ed2a7c7190c 19
GordonSin 0:0ed2a7c7190c 20 #ifndef ETHERNETINTERFACE_H_
GordonSin 0:0ed2a7c7190c 21 #define ETHERNETINTERFACE_H_
GordonSin 0:0ed2a7c7190c 22
GordonSin 0:0ed2a7c7190c 23 #include "rtos.h"
GordonSin 0:0ed2a7c7190c 24 #include "lwip/netif.h"
GordonSin 0:0ed2a7c7190c 25
GordonSin 0:0ed2a7c7190c 26 /** Interface using Ethernet to connect to an IP-based network
GordonSin 0:0ed2a7c7190c 27 *
GordonSin 0:0ed2a7c7190c 28 */
GordonSin 0:0ed2a7c7190c 29 class EthernetInterface {
GordonSin 0:0ed2a7c7190c 30 public:
GordonSin 0:0ed2a7c7190c 31 /** Initialize the interface with DHCP.
GordonSin 0:0ed2a7c7190c 32 * Initialize the interface and configure it to use DHCP (no connection at this point).
GordonSin 0:0ed2a7c7190c 33 * \return 0 on success, a negative number on failure
GordonSin 0:0ed2a7c7190c 34 */
GordonSin 0:0ed2a7c7190c 35 static int init(); //With DHCP
GordonSin 0:0ed2a7c7190c 36
GordonSin 0:0ed2a7c7190c 37 /** Initialize the interface with a static IP address.
GordonSin 0:0ed2a7c7190c 38 * Initialize the interface and configure it with the following static configuration (no connection at this point).
GordonSin 0:0ed2a7c7190c 39 * \param ip the IP address to use
GordonSin 0:0ed2a7c7190c 40 * \param mask the IP address mask
GordonSin 0:0ed2a7c7190c 41 * \param gateway the gateway to use
GordonSin 0:0ed2a7c7190c 42 * \return 0 on success, a negative number on failure
GordonSin 0:0ed2a7c7190c 43 */
GordonSin 0:0ed2a7c7190c 44 static int init(const char* ip, const char* mask, const char* gateway);
GordonSin 0:0ed2a7c7190c 45
GordonSin 0:0ed2a7c7190c 46 /** Connect
GordonSin 0:0ed2a7c7190c 47 * Bring the interface up, start DHCP if needed.
GordonSin 0:0ed2a7c7190c 48 * \return 0 on success, a negative number on failure
GordonSin 0:0ed2a7c7190c 49 */
GordonSin 0:0ed2a7c7190c 50 static int connect();
GordonSin 0:0ed2a7c7190c 51
GordonSin 0:0ed2a7c7190c 52 /** Disconnect
GordonSin 0:0ed2a7c7190c 53 * Bring the interface down
GordonSin 0:0ed2a7c7190c 54 * \return 0 on success, a negative number on failure
GordonSin 0:0ed2a7c7190c 55 */
GordonSin 0:0ed2a7c7190c 56 static int disconnect();
GordonSin 0:0ed2a7c7190c 57
GordonSin 0:0ed2a7c7190c 58 static char* getIPAddress();
GordonSin 0:0ed2a7c7190c 59 };
GordonSin 0:0ed2a7c7190c 60
GordonSin 0:0ed2a7c7190c 61 #include "TCPSocketConnection.h"
GordonSin 0:0ed2a7c7190c 62 #include "TCPSocketServer.h"
GordonSin 0:0ed2a7c7190c 63
GordonSin 0:0ed2a7c7190c 64 #include "Endpoint.h"
GordonSin 0:0ed2a7c7190c 65 #include "UDPSocket.h"
GordonSin 0:0ed2a7c7190c 66
GordonSin 0:0ed2a7c7190c 67 #endif /* ETHERNETINTERFACE_H_ */