diff --git a/lib/libesp32/ESP32-Ethernet/README.md b/lib/libesp32/ESP32-Ethernet/README.md deleted file mode 100644 index ac4d80fa4..000000000 --- a/lib/libesp32/ESP32-Ethernet/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# Ethernet Arduino Library for ESP32 - -See https://github.com/espressif/arduino-esp32/issues/3554#issuecomment-596902806 - diff --git a/lib/libesp32/ESP32-Ethernet/examples/EthernetLAN_IP101/EthernetLAN_IP101.ino b/lib/libesp32/ESP32-Ethernet/examples/EthernetLAN_IP101/EthernetLAN_IP101.ino deleted file mode 100644 index 3bbe837a1..000000000 --- a/lib/libesp32/ESP32-Ethernet/examples/EthernetLAN_IP101/EthernetLAN_IP101.ino +++ /dev/null @@ -1,82 +0,0 @@ -#include - -#define ETH_ADDR 1 -#define ETH_POWER_PIN 5 -#define ETH_MDC_PIN 23 -#define ETH_MDIO_PIN 18 -#define ETH_TYPE ETH_PHY_IP101 - -static bool eth_connected = false; - -void WiFiEvent(WiFiEvent_t event) -{ - switch (event) { - case SYSTEM_EVENT_ETH_START: - Serial.println("ETH Started"); - //set eth hostname here - ETH.setHostname("esp32-ethernet"); - break; - case SYSTEM_EVENT_ETH_CONNECTED: - Serial.println("ETH Connected"); - break; - case SYSTEM_EVENT_ETH_GOT_IP: - Serial.print("ETH MAC: "); - Serial.print(ETH.macAddress()); - Serial.print(", IPv4: "); - Serial.print(ETH.localIP()); - if (ETH.fullDuplex()) { - Serial.print(", FULL_DUPLEX"); - } - Serial.print(", "); - Serial.print(ETH.linkSpeed()); - Serial.println("Mbps"); - eth_connected = true; - break; - case SYSTEM_EVENT_ETH_DISCONNECTED: - Serial.println("ETH Disconnected"); - eth_connected = false; - break; - case SYSTEM_EVENT_ETH_STOP: - Serial.println("ETH Stopped"); - eth_connected = false; - break; - default: - break; - } -} - -void testClient(const char * host, uint16_t port) -{ - Serial.print("\nconnecting to "); - Serial.println(host); - - WiFiClient client; - if (!client.connect(host, port)) { - Serial.println("connection failed"); - return; - } - client.printf("GET / HTTP/1.1\r\nHost: %s\r\n\r\n", host); - while (client.connected() && !client.available()); - while (client.available()) { - Serial.write(client.read()); - } - - Serial.println("closing connection\n"); - client.stop(); -} - -void setup() -{ - Serial.begin(115200); - WiFi.onEvent(WiFiEvent); - ETH.begin(ETH_ADDR, ETH_POWER_PIN, ETH_MDC_PIN, ETH_MDIO_PIN, ETH_TYPE); -} - - -void loop() -{ - if (eth_connected) { - testClient("google.com", 80); - } - delay(10000); -} \ No newline at end of file diff --git a/lib/libesp32/ESP32-Ethernet/library.json b/lib/libesp32/ESP32-Ethernet/library.json deleted file mode 100644 index 96ba3e110..000000000 --- a/lib/libesp32/ESP32-Ethernet/library.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": "ESP32 Ethernet", - "keywords": "esp32, ethernet, communication", - "description": "Ethernet Library for ESP32", - "version": "1.1.0", - "frameworks": "arduino", - "platforms": "espressif32" -} diff --git a/lib/libesp32/ESP32-Ethernet/library.properties b/lib/libesp32/ESP32-Ethernet/library.properties deleted file mode 100644 index f7f4fd845..000000000 --- a/lib/libesp32/ESP32-Ethernet/library.properties +++ /dev/null @@ -1,9 +0,0 @@ -name=ESP32 Ethernet -version=1.1.0 -author=Espressif -maintainer=Espressif -sentence=Ethernet Library for ESP32 -paragraph=This library allows ESP32 to use ethernet hardware -category=Communication -url= -architectures=esp32 diff --git a/lib/libesp32/ESP32-Ethernet/src/ETH.cpp b/lib/libesp32/ESP32-Ethernet/src/ETH.cpp deleted file mode 100644 index 68e7a0593..000000000 --- a/lib/libesp32/ESP32-Ethernet/src/ETH.cpp +++ /dev/null @@ -1,304 +0,0 @@ -/* - ETH.h - espre ETH PHY support. - Based on WiFi.h from Arduino WiFi shield library. - Copyright (c) 2011-2014 Arduino. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "ETH.h" -#include "eth_phy/phy.h" -#include "eth_phy/phy_tlk110.h" -#include "eth_phy/phy_lan8720.h" -#include "eth_phy/phy_ip101.h" -#include "lwip/err.h" -#include "lwip/dns.h" - -extern void tcpipInit(); - -static int _eth_phy_mdc_pin = -1; -static int _eth_phy_mdio_pin = -1; -static int _eth_phy_power_pin = -1; -static eth_phy_power_enable_func _eth_phy_power_enable_orig = NULL; - -static void _eth_phy_config_gpio(void) -{ - if(_eth_phy_mdc_pin < 0 || _eth_phy_mdio_pin < 0){ - log_e("MDC and MDIO pins are not configured!"); - return; - } - phy_rmii_configure_data_interface_pins(); - phy_rmii_smi_configure_pins(_eth_phy_mdc_pin, _eth_phy_mdio_pin); -} - -static void _eth_phy_power_enable(bool enable) -{ - pinMode(_eth_phy_power_pin, OUTPUT); - digitalWrite(_eth_phy_power_pin, enable); - delay(1); -} - -ETHClass::ETHClass():initialized(false),started(false),staticIP(false) -{ -} - -ETHClass::~ETHClass() -{} - -bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_type_t type, eth_clock_mode_t clock_mode) -{ - esp_err_t err; - if(initialized){ - err = esp_eth_enable(); - if(err){ - log_e("esp_eth_enable error: %d", err); - return false; - } - started = true; - return true; - } - _eth_phy_mdc_pin = mdc; - _eth_phy_mdio_pin = mdio; - _eth_phy_power_pin = power; - - if(type == ETH_PHY_LAN8720) - { - eth_config_t config = phy_lan8720_default_ethernet_config; - memcpy(ð_config, &config, sizeof(eth_config_t)); - } - else if(type == ETH_PHY_TLK110) - { - eth_config_t config = phy_tlk110_default_ethernet_config; - memcpy(ð_config, &config, sizeof(eth_config_t)); - } - else if(type == ETH_PHY_IP101) - { - eth_config_t config = phy_ip101_default_ethernet_config; - memcpy(ð_config, &config, sizeof(eth_config_t)); - } - else - { - log_e("Bad ETH_PHY type: %u", (uint8_t)type); - return false; - } - - eth_config.phy_addr = (eth_phy_base_t)phy_addr; - eth_config.clock_mode = clock_mode; - eth_config.gpio_config = _eth_phy_config_gpio; - eth_config.tcpip_input = tcpip_adapter_eth_input; - if(_eth_phy_power_pin >= 0){ - _eth_phy_power_enable_orig = eth_config.phy_power_enable; - eth_config.phy_power_enable = _eth_phy_power_enable; - } - - tcpipInit(); - err = esp_eth_init(ð_config); - if(!err){ - initialized = true; - err = esp_eth_enable(); - if(err){ - log_e("esp_eth_enable error: %d", err); - } else { - started = true; - return true; - } - } else { - log_e("esp_eth_init error: %d", err); - } - return false; -} - -bool ETHClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1, IPAddress dns2) -{ - esp_err_t err = ESP_OK; - tcpip_adapter_ip_info_t info; - - if(local_ip != (uint32_t)0x00000000){ - info.ip.addr = static_cast(local_ip); - info.gw.addr = static_cast(gateway); - info.netmask.addr = static_cast(subnet); - } else { - info.ip.addr = 0; - info.gw.addr = 0; - info.netmask.addr = 0; - } - - err = tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_ETH); - if(err != ESP_OK && err != ESP_ERR_TCPIP_ADAPTER_DHCP_ALREADY_STOPPED){ - log_e("DHCP could not be stopped! Error: %d", err); - return false; - } - - err = tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_ETH, &info); - if(err != ERR_OK){ - log_e("STA IP could not be configured! Error: %d", err); - return false; -} - if(info.ip.addr){ - staticIP = true; - } else { - err = tcpip_adapter_dhcpc_start(TCPIP_ADAPTER_IF_ETH); - if(err != ESP_OK && err != ESP_ERR_TCPIP_ADAPTER_DHCP_ALREADY_STARTED){ - log_w("DHCP could not be started! Error: %d", err); - return false; - } - staticIP = false; - } - - ip_addr_t d; - d.type = IPADDR_TYPE_V4; - - if(dns1 != (uint32_t)0x00000000) { - // Set DNS1-Server - d.u_addr.ip4.addr = static_cast(dns1); - dns_setserver(0, &d); - } - - if(dns2 != (uint32_t)0x00000000) { - // Set DNS2-Server - d.u_addr.ip4.addr = static_cast(dns2); - dns_setserver(1, &d); - } - - return true; -} - -IPAddress ETHClass::localIP() -{ - tcpip_adapter_ip_info_t ip; - if(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, &ip)){ - return IPAddress(); - } - return IPAddress(ip.ip.addr); -} - -IPAddress ETHClass::subnetMask() -{ - tcpip_adapter_ip_info_t ip; - if(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, &ip)){ - return IPAddress(); - } - return IPAddress(ip.netmask.addr); -} - -IPAddress ETHClass::gatewayIP() -{ - tcpip_adapter_ip_info_t ip; - if(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, &ip)){ - return IPAddress(); - } - return IPAddress(ip.gw.addr); -} - -IPAddress ETHClass::dnsIP(uint8_t dns_no) -{ -#ifdef ESP_IDF_VERSION_VAL //idf_version.h header file is only available in ESP-IDF v4.0 -> this is equal to: #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0) - const ip_addr_t *dns_ip = dns_getserver(dns_no); - return IPAddress(dns_ip->u_addr.ip4.addr); -#else - ip_addr_t dns_ip = dns_getserver(dns_no); - return IPAddress(dns_ip.u_addr.ip4.addr); -#endif -} - -IPAddress ETHClass::broadcastIP() -{ - tcpip_adapter_ip_info_t ip; - if(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, &ip)){ - return IPAddress(); - } - return WiFiGenericClass::calculateBroadcast(IPAddress(ip.gw.addr), IPAddress(ip.netmask.addr)); -} - -IPAddress ETHClass::networkID() -{ - tcpip_adapter_ip_info_t ip; - if(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, &ip)){ - return IPAddress(); - } - return WiFiGenericClass::calculateNetworkID(IPAddress(ip.gw.addr), IPAddress(ip.netmask.addr)); -} - -uint8_t ETHClass::subnetCIDR() -{ - tcpip_adapter_ip_info_t ip; - if(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_ETH, &ip)){ - return (uint8_t)0; - } - return WiFiGenericClass::calculateSubnetCIDR(IPAddress(ip.netmask.addr)); -} - -const char * ETHClass::getHostname() -{ - const char * hostname; - if(tcpip_adapter_get_hostname(TCPIP_ADAPTER_IF_ETH, &hostname)){ - return NULL; - } - return hostname; -} - -bool ETHClass::setHostname(const char * hostname) -{ - return tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_ETH, hostname) == 0; -} - -bool ETHClass::fullDuplex() -{ - return eth_config.phy_get_duplex_mode(); -} - -bool ETHClass::linkUp() -{ - return eth_config.phy_check_link(); -} - -uint8_t ETHClass::linkSpeed() -{ - return eth_config.phy_get_speed_mode()?100:10; -} - -bool ETHClass::enableIpV6() -{ - return tcpip_adapter_create_ip6_linklocal(TCPIP_ADAPTER_IF_ETH) == 0; -} - -IPv6Address ETHClass::localIPv6() -{ - static ip6_addr_t addr; - if(tcpip_adapter_get_ip6_linklocal(TCPIP_ADAPTER_IF_ETH, &addr)){ - return IPv6Address(); - } - return IPv6Address(addr.addr); -} - -uint8_t * macAddress(uint8_t* mac) -{ - if(!mac){ - return NULL; - } - esp_eth_get_mac(mac); - return mac; -} - -String ETHClass::macAddress(void) -{ - uint8_t mac[6]; - char macStr[18] = { 0 }; - esp_eth_get_mac(mac); - sprintf(macStr, "%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); - return String(macStr); -} - -ETHClass ETH; diff --git a/lib/libesp32/ESP32-Ethernet/src/ETH.h b/lib/libesp32/ESP32-Ethernet/src/ETH.h deleted file mode 100644 index 7f175e13f..000000000 --- a/lib/libesp32/ESP32-Ethernet/src/ETH.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - ETH.h - espre ETH PHY support. - Based on WiFi.h from Ardiono WiFi shield library. - Copyright (c) 2011-2014 Arduino. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef _ETH_H_ -#define _ETH_H_ - -#include "WiFi.h" -#include "esp_eth.h" - -#ifndef ETH_PHY_ADDR -#define ETH_PHY_ADDR 0 -#endif - -#ifndef ETH_PHY_TYPE -#define ETH_PHY_TYPE ETH_PHY_LAN8720 -#endif - -#ifndef ETH_PHY_POWER -#define ETH_PHY_POWER -1 -#endif - -#ifndef ETH_PHY_MDC -#define ETH_PHY_MDC 23 -#endif - -#ifndef ETH_PHY_MDIO -#define ETH_PHY_MDIO 18 -#endif - -#ifndef ETH_CLK_MODE -#define ETH_CLK_MODE ETH_CLOCK_GPIO0_IN -#endif - -typedef enum { ETH_PHY_LAN8720, ETH_PHY_TLK110, ETH_PHY_IP101, ETH_PHY_MAX } eth_phy_type_t; - -class ETHClass { - private: - bool initialized; - bool started; - bool staticIP; - eth_config_t eth_config; - public: - ETHClass(); - ~ETHClass(); - - bool begin(uint8_t phy_addr=ETH_PHY_ADDR, int power=ETH_PHY_POWER, int mdc=ETH_PHY_MDC, int mdio=ETH_PHY_MDIO, eth_phy_type_t type=ETH_PHY_TYPE, eth_clock_mode_t clk_mode=ETH_CLK_MODE); - - bool config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1 = (uint32_t)0x00000000, IPAddress dns2 = (uint32_t)0x00000000); - - const char * getHostname(); - bool setHostname(const char * hostname); - - bool fullDuplex(); - bool linkUp(); - uint8_t linkSpeed(); - - bool enableIpV6(); - IPv6Address localIPv6(); - - IPAddress localIP(); - IPAddress subnetMask(); - IPAddress gatewayIP(); - IPAddress dnsIP(uint8_t dns_no = 0); - - IPAddress broadcastIP(); - IPAddress networkID(); - uint8_t subnetCIDR(); - - uint8_t * macAddress(uint8_t* mac); - String macAddress(); - - friend class WiFiClient; - friend class WiFiServer; -}; - -extern ETHClass ETH; - -#endif /* _ETH_H_ */