mbed IP library over Ethernet with setName and setNewAddress
Dependencies: Socket lwip-eth lwip-sys lwip
Dependents: JRO_CR2 JRO_DDSv2 JRO_DDSv2_rev2019
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) && !defined(TARGET_LPC4088) && !defined(TARGET_K64F) && !defined(TARGET_RZ_A1H) 00024 #error The Ethernet Interface library is not supported on this target 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 public: 00035 /** Initialize the interface with DHCP. 00036 * Initialize the interface and configure it to use DHCP (no connection at this point). 00037 * \return 0 on success, a negative number on failure 00038 */ 00039 static int init(); //With DHCP 00040 00041 /** Initialize the interface with a static IP address. 00042 * Initialize the interface and configure it with the following static configuration (no connection at this point). 00043 * \param ip the IP address to use 00044 * \param mask the IP address mask 00045 * \param gateway the gateway to use 00046 * \return 0 on success, a negative number on failure 00047 */ 00048 static int init(const char* ip, const char* mask, const char* gateway); 00049 00050 /** Change the interface with a new static IP address. 00051 * Change the interface and configure it with the following static configuration (no connection at this point). 00052 * \param ip the IP address to use 00053 * \param mask the IP address mask 00054 * \param gateway the gateway to use 00055 * \return 0 on success, a negative number on failure 00056 */ 00057 static int setNewAddr(const char* ip, const char* mask, const char* gateway); 00058 00059 /** Set the network name for this device. Apply this before calling 'connect'. 00060 * 00061 * \param myname is the name to assign for this node. 00062 * Only the first 32 characters will be used if the 00063 * name is longer. 00064 * Only '0'-'9', 'A'-'Z', 'a'-'z' are accepted, 00065 * any others are converted to '-'. 00066 * \return 0 on success, a negative number on failure. 00067 */ 00068 static int setName(const char * myname); 00069 00070 /** Connect 00071 * Bring the interface up, start DHCP if needed. 00072 * \param timeout_ms timeout in ms (default: (15)s). 00073 * \return 0 on success, a negative number on failure 00074 */ 00075 00076 static int connect(unsigned int timeout_ms=15000); 00077 00078 /** Disconnect 00079 * Bring the interface down 00080 * \return 0 on success, a negative number on failure 00081 */ 00082 static int disconnect(); 00083 00084 /** Get the MAC address of your Ethernet interface 00085 * \return a pointer to a string containing the MAC address 00086 */ 00087 static char* getMACAddress(); 00088 00089 /** Get the IP address of your Ethernet interface 00090 * \return a pointer to a string containing the IP address 00091 */ 00092 static char* getIPAddress(); 00093 00094 /** Get the Gateway address of your Ethernet interface 00095 * \return a pointer to a string containing the Gateway address 00096 */ 00097 static char* getGateway(); 00098 00099 /** Get the Network mask of your Ethernet interface 00100 * \return a pointer to a string containing the Network mask 00101 */ 00102 static char* getNetworkMask(); 00103 }; 00104 00105 #include "TCPSocketConnection.h" 00106 #include "TCPSocketServer.h" 00107 00108 #include "Endpoint.h" 00109 #include "UDPSocket.h" 00110 00111 #endif /* ETHERNETINTERFACE_H_ */
Generated on Fri Jul 15 2022 06:15:12 by 1.7.2