adds getMACAddress() like getIPAddress(). Initializes in constructor.
Dependencies: Socket lwip-eth lwip-sys lwip
Fork of EthernetInterface by
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 #if !defined(TARGET_LPC1768) 00024 #error The Ethernet Interface library is supported only on the mbed NXP LPC1768 00025 #endif 00026 00027 #include "rtos.h" 00028 #include "lwip/netif.h" 00029 00030 /** Interface using Ethernet to connect to an IP-based network 00031 * 00032 */ 00033 class EthernetInterface 00034 { 00035 public: 00036 00037 /* 00038 * Constructor 00039 */ 00040 EthernetInterface(); 00041 00042 /** Initialize the interface with DHCP. 00043 * Initialize the interface and configure it to use DHCP (no connection at this point). 00044 * \return 0 on success, a negative number on failure 00045 */ 00046 static int init(); //With DHCP 00047 00048 /** Initialize the interface with a static IP address. 00049 * Initialize the interface and configure it with the following static configuration (no connection at this point). 00050 * \param ip the IP address to use 00051 * \param mask the IP address mask 00052 * \param gateway the gateway to use 00053 * \return 0 on success, a negative number on failure 00054 */ 00055 static int init(const char* ip, const char* mask, const char* gateway); 00056 00057 /** Connect 00058 * Bring the interface up, start DHCP if needed. 00059 * \param timeout_ms timeout in ms (default: (12)s). 00060 * \return 0 on success, a negative number on failure 00061 */ 00062 static int connect(unsigned int timeout_ms=12000); 00063 00064 /** Disconnect 00065 * Bring the interface down 00066 * \return 0 on success, a negative number on failure 00067 */ 00068 static int disconnect(); 00069 00070 static char* getIPAddress(); 00071 00072 static char* getMACAddress(); 00073 }; 00074 00075 #include "TCPSocketConnection.h" 00076 #include "TCPSocketServer.h" 00077 00078 #include "Endpoint.h" 00079 #include "UDPSocket.h" 00080 00081 #endif /* ETHERNETINTERFACE_H_ */
Generated on Fri Jul 15 2022 21:48:10 by 1.7.2