]>
git.gir.st - tmk_keyboard.git/blob - tmk_core/tool/mbed/mbed-sdk/libraries/net/eth/EthernetInterface/EthernetInterface.h
1 /* EthernetInterface.h */
2 /* Copyright (C) 2012 mbed.org, MIT License
4 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
5 * and associated documentation files (the "Software"), to deal in the Software without restriction,
6 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
7 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice shall be included in all copies or
11 * substantial portions of the Software.
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
14 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
17 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 #ifndef ETHERNETINTERFACE_H_
21 #define ETHERNETINTERFACE_H_
23 #if !defined(TARGET_LPC1768) && !defined(TARGET_LPC4088) && !defined(TARGET_LPC4088_DM) && !defined(TARGET_K64F) && !defined(TARGET_RZ_A1H) && !defined(TARGET_STM32F4)
24 #error The Ethernet Interface library is not supported on this target
28 #include "lwip/netif.h"
30 /** Interface using Ethernet to connect to an IP-based network
33 class EthernetInterface
{
35 /** Initialize the interface with DHCP.
36 * Initialize the interface and configure it to use DHCP (no connection at this point).
37 * \return 0 on success, a negative number on failure
39 static int init(); //With DHCP
41 /** Initialize the interface with a static IP address.
42 * Initialize the interface and configure it with the following static configuration (no connection at this point).
43 * \param ip the IP address to use
44 * \param mask the IP address mask
45 * \param gateway the gateway to use
46 * \return 0 on success, a negative number on failure
48 static int init(const char* ip
, const char* mask
, const char* gateway
);
51 * Bring the interface up, start DHCP if needed.
52 * \param timeout_ms timeout in ms (default: (15)s).
53 * \return 0 on success, a negative number on failure
55 static int connect(unsigned int timeout_ms
=15000);
58 * Bring the interface down
59 * \return 0 on success, a negative number on failure
61 static int disconnect();
63 /** Get the MAC address of your Ethernet interface
64 * \return a pointer to a string containing the MAC address
66 static char* getMACAddress();
68 /** Get the IP address of your Ethernet interface
69 * \return a pointer to a string containing the IP address
71 static char* getIPAddress();
73 /** Get the Gateway address of your Ethernet interface
74 * \return a pointer to a string containing the Gateway address
76 static char* getGateway();
78 /** Get the Network mask of your Ethernet interface
79 * \return a pointer to a string containing the Network mask
81 static char* getNetworkMask();
84 #include "TCPSocketConnection.h"
85 #include "TCPSocketServer.h"
88 #include "UDPSocket.h"
90 #endif /* ETHERNETINTERFACE_H_ */