]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/net/eth/EthernetInterface/EthernetInterface.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[qmk_firmware.git] / tool / mbed / mbed-sdk / libraries / net / eth / EthernetInterface / EthernetInterface.h
1 /* EthernetInterface.h */
2 /* Copyright (C) 2012 mbed.org, MIT License
3  *
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:
9  *
10  * The above copyright notice and this permission notice shall be included in all copies or
11  * substantial portions of the Software.
12  *
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.
18  */
19  
20 #ifndef ETHERNETINTERFACE_H_
21 #define ETHERNETINTERFACE_H_
22
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
25 #endif
26
27 #include "rtos.h"
28 #include "lwip/netif.h"
29
30  /** Interface using Ethernet to connect to an IP-based network
31  *
32  */
33 class EthernetInterface {
34 public:
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
38   */
39   static int init(); //With DHCP
40
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
47   */
48   static int init(const char* ip, const char* mask, const char* gateway);
49
50   /** Connect
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
54   */
55   static int connect(unsigned int timeout_ms=15000);
56   
57   /** Disconnect
58   * Bring the interface down
59   * \return 0 on success, a negative number on failure
60   */
61   static int disconnect();
62   
63   /** Get the MAC address of your Ethernet interface
64    * \return a pointer to a string containing the MAC address
65    */
66   static char* getMACAddress();
67   
68   /** Get the IP address of your Ethernet interface
69    * \return a pointer to a string containing the IP address
70    */
71   static char* getIPAddress();
72
73   /** Get the Gateway address of your Ethernet interface
74    * \return a pointer to a string containing the Gateway address
75    */
76   static char* getGateway();
77
78   /** Get the Network mask of your Ethernet interface
79    * \return a pointer to a string containing the Network mask
80    */
81   static char* getNetworkMask();
82 };
83
84 #include "TCPSocketConnection.h"
85 #include "TCPSocketServer.h"
86
87 #include "Endpoint.h"
88 #include "UDPSocket.h"
89
90 #endif /* ETHERNETINTERFACE_H_ */