From d04bc0fedc077f0d4f6e7758ca0b4f879cc26d45 Mon Sep 17 00:00:00 2001 From: Khoi Hoang <57012152+khoih-prog@users.noreply.github.com> Date: Thu, 8 Sep 2022 01:30:05 -0400 Subject: [PATCH] v1.8.0 to fix `macAddress` bug, etc. ### Releases v1.8.0 1. Fix `macAddress` bug. Check [Unable so set MAC Address #2](https://github.com/khoih-prog/Ethernet_Manager/issues/2) 2. Permit setting `macAddress` for supporting Ethernet shields W5x00 and ENC28J60 3. Add functions relating to `macAddress` 4. Rewrite all the examples to support new features 5. Drop support to `Ethernet_ESP8266` 6. Update `Packages' Patches` --- examples/AM2315_Ethernet/AM2315_Ethernet.ino | 40 +- examples/AM2315_Ethernet/defines.h | 33 +- .../Ethernet_Generic/Ethernet_Generic.ino | 90 ++-- examples/Ethernet_Generic/defines.h | 56 ++- examples/Ethernet_RP2040/Ethernet_RP2040.ino | 35 +- examples/Ethernet_RP2040/defines.h | 6 +- examples/Ethernet_SAMD/Ethernet_SAMD.ino | 35 +- examples/Ethernet_SAMD/defines.h | 33 +- .../Ethernet_SAM_DUE/Ethernet_SAM_DUE.ino | 87 ++-- examples/Ethernet_SAM_DUE/defines.h | 38 +- examples/Ethernet_Teensy/Ethernet_Teensy.ino | 22 +- examples/Ethernet_Teensy/defines.h | 1 - .../Ethernet_WT32_ETH01.ino | 34 +- examples/Ethernet_WT32_ETH01/defines.h | 465 +----------------- examples/Ethernet_nRF52/Ethernet_nRF52.ino | 35 +- examples/Ethernet_nRF52/defines.h | 55 ++- .../MQTT_ThingStream_Ethernet_Generic.ino | 35 +- .../defines.h | 33 +- .../MQTT_ThingStream_Ethernet_RP2040.ino | 38 +- .../defines.h | 33 +- .../MQTT_ThingStream_Ethernet_SAMD.ino | 35 +- .../MQTT_ThingStream_Ethernet_SAMD/defines.h | 33 +- .../MQTT_ThingStream_Ethernet_SAM_DUE.ino | 35 +- .../defines.h | 31 +- .../MQTT_ThingStream_Ethernet_Teensy.ino | 22 +- .../defines.h | 1 - .../MQTT_ThingStream_Ethernet_WT32_ETH01.ino | 12 +- .../defines.h | 465 +----------------- .../MQTT_ThingStream_Ethernet_nRF52.ino | 35 +- .../MQTT_ThingStream_Ethernet_nRF52/defines.h | 33 +- .../defines.h | 1 - examples/QNEthernet_Teensy/defines.h | 1 - 32 files changed, 690 insertions(+), 1218 deletions(-) diff --git a/examples/AM2315_Ethernet/AM2315_Ethernet.ino b/examples/AM2315_Ethernet/AM2315_Ethernet.ino index f8eb6e02..1f5017db 100644 --- a/examples/AM2315_Ethernet/AM2315_Ethernet.ino +++ b/examples/AM2315_Ethernet/AM2315_Ethernet.ino @@ -65,30 +65,39 @@ void heartBeatPrint() localEthernetIP = Ethernet.localIP(); -#if ( (USE_ETHERNET2 || USE_ETHERNET3) && !(USE_NATIVE_ETHERNET) ) - // To modify Ethernet2 library +#if (USE_ETHERNET_GENERIC) + + #if USE_W5100 + // The linkStatus() is not working with W5100. Just using IP != 0.0.0.0 + if ( (uint32_t) localEthernetIP != 0 ) + #else linkStatus = Ethernet.link(); - ET_LOGINFO3("localEthernetIP = ", localEthernetIP, ", linkStatus = ", (linkStatus == 1) ? "LinkON" : "LinkOFF" ); + ETM_LOGINFO1("localEthernetIP = ", localEthernetIP); + + if ( ( linkStatus == 1 ) || ((uint32_t) localEthernetIP != 0) ) + #endif - if ( ( linkStatus == 1 ) && ((uint32_t) localEthernetIP != 0) ) #else // The linkStatus() is not working with W5100. Just using IP != 0.0.0.0 // Better to use ping for W5100 linkStatus = (int) Ethernet.linkStatus(); - ET_LOGINFO3("localEthernetIP = ", localEthernetIP, ", linkStatus = ", (linkStatus == LinkON) ? "LinkON" : "LinkOFF" ); - - if ( ( (linkStatus == LinkON) || !isW5500 ) && ((uint32_t) localEthernetIP != 0) ) + ETM_LOGINFO1("localEthernetIP = ", localEthernetIP); + + if ( ( (linkStatus == LinkON) || !isW5500 ) || ((uint32_t) localEthernetIP != 0) ) #endif { Serial.print(F("H")); } else - Serial.print(F("F")); + Serial.print(F("F")); if (num == 80) { Serial.println(); + + ethernet_manager.printMacAddress(); + num = 1; } else if (num++ % 10 == 0) @@ -127,8 +136,6 @@ void initEthernet() ET_LOGWARN(F("======== USE_NATIVE_ETHERNET ========")); #elif USE_ETHERNET_GENERIC ET_LOGWARN(F("=========== USE_ETHERNET_GENERIC ===========")); -#elif USE_ETHERNET_ESP8266 - ET_LOGWARN(F("=========== USE_ETHERNET_ESP8266 ===========")); #elif USE_ETHERNET_ENC ET_LOGWARN(F("=========== USE_ETHERNET_ENC ===========")); #else @@ -321,6 +328,19 @@ void setup() ethernet_manager.setCORSHeader("Your Access-Control-Allow-Origin"); #endif + ////////////////////////////////////////////// + +#define USING_CUSTOM_MAC_ADDRESS false + +#if USING_CUSTOM_MAC_ADDRESS + // To use your specified macAddress + byte newMacAddress[6] = { 0xFE, 0xED, 0xDE, 0xAD, 0xBE, 0xEF }; + + ethernet_manager.setMacAddress(newMacAddress); +#endif + + ////////////////////////////////////////////// + ethernet_manager.begin(); ////////////////////////////////////////////// diff --git a/examples/AM2315_Ethernet/defines.h b/examples/AM2315_Ethernet/defines.h index d569e0ae..83eae49a 100644 --- a/examples/AM2315_Ethernet/defines.h +++ b/examples/AM2315_Ethernet/defines.h @@ -22,7 +22,7 @@ // Debug Level from 0 to 4 #define _ETHERNET_WEBSERVER_LOGLEVEL_ 2 -#define _ETHERNET_MANAGER_LOGLEVEL_ 2 +#define _ETHERNET_MANAGER_LOGLEVEL_ 4 #define DRD_GENERIC_DEBUG true @@ -80,11 +80,27 @@ #if defined(ETHERNET_USE_SAMD) // For SAMD - // Default pin 10 to SS/CS - #define USE_THIS_SS_PIN 10 + // Default pin SS/CS,if no SS pin, use pin 10 + #if defined(PIN_SPI_MOSI) + //#warning Using SS pin + #define USE_THIS_SS_PIN 10 //SS + #else + #define USE_THIS_SS_PIN 10 + #endif #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) #define BOARD_TYPE "SAMD Zero" + + // Default to use W5100. Must change to false for W5500, W5100S, for faster SPI clock + // Must use true for SAMD21, such as Zero, SAMD_FEATHER_M0_EXPRESS, etc. + #define USE_W5100 true + + // Use this for ARDUINO_SAMD_ZERO, etc. if can't print to terminal with Serial.print + #if defined(SERIAL_PORT_USBVIRTUAL) + #define Serial SERIAL_PORT_USBVIRTUAL + #warning Using SAMD Zero SerialUSB + #endif + #elif defined(ARDUINO_SAMD_MKR1000) #define BOARD_TYPE "SAMD MKR1000" #elif defined(ARDUINO_SAMD_MKRWIFI1010) @@ -226,6 +242,7 @@ #endif #elif ( defined(CORE_TEENSY) ) + #error Teensy not supported // Default pin 10 to SS/CS #define USE_THIS_SS_PIN 10 @@ -335,8 +352,6 @@ //#define USE_UIP_ETHERNET true #define USE_UIP_ETHERNET false -// Note: To rename ESP628266 Ethernet lib files to Ethernet_ESP8266.h and Ethernet_ESP8266.cpp -// In order to USE_ETHERNET_ESP8266 #if ( !defined(USE_UIP_ETHERNET) || !USE_UIP_ETHERNET ) // To override the default CS/SS pin. Don't use unless you know exactly which pin to use @@ -346,11 +361,10 @@ // Only one if the following to be true #define USE_ETHERNET_GENERIC true - #define USE_ETHERNET_ESP8266 false #define USE_ETHERNET_ENC false #define USE_CUSTOM_ETHERNET false - #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ESP8266 || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET ) + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET ) #ifdef USE_CUSTOM_ETHERNET #undef USE_CUSTOM_ETHERNET #endif @@ -375,11 +389,6 @@ #include "Ethernet_Generic.h" #warning Using Ethernet_Generic lib - - #elif USE_ETHERNET_ESP8266 - #include "Ethernet_ESP8266.h" - #warning Using Ethernet_ESP8266 lib - #define SHIELD_TYPE "W5x00 using Ethernet_ESP8266 Library" #elif USE_ETHERNET_ENC #include "EthernetENC.h" diff --git a/examples/Ethernet_Generic/Ethernet_Generic.ino b/examples/Ethernet_Generic/Ethernet_Generic.ino index 1c32bb7e..989760da 100644 --- a/examples/Ethernet_Generic/Ethernet_Generic.ino +++ b/examples/Ethernet_Generic/Ethernet_Generic.ino @@ -30,18 +30,25 @@ void heartBeatPrint() localEthernetIP = Ethernet.localIP(); #if (USE_ETHERNET_GENERIC) + + #if USE_W5100 + // The linkStatus() is not working with W5100. Just using IP != 0.0.0.0 + if ( (uint32_t) localEthernetIP != 0 ) + #else linkStatus = Ethernet.link(); - ET_LOGINFO3("localEthernetIP = ", localEthernetIP, ", linkStatus = ", (linkStatus == 1) ? "LinkON" : "LinkOFF" ); + ETM_LOGINFO1("localEthernetIP = ", localEthernetIP); + + if ( ( linkStatus == 1 ) || ((uint32_t) localEthernetIP != 0) ) + #endif - if ( ( linkStatus == 1 ) && ((uint32_t) localEthernetIP != 0) ) #else // The linkStatus() is not working with W5100. Just using IP != 0.0.0.0 // Better to use ping for W5100 linkStatus = (int) Ethernet.linkStatus(); - ET_LOGINFO3("localEthernetIP = ", localEthernetIP, ", linkStatus = ", (linkStatus == LinkON) ? "LinkON" : "LinkOFF" ); - - if ( ( (linkStatus == LinkON) || !isW5500 ) && ((uint32_t) localEthernetIP != 0) ) + ETM_LOGINFO1("localEthernetIP = ", localEthernetIP); + + if ( ( (linkStatus == LinkON) || !isW5500 ) || ((uint32_t) localEthernetIP != 0) ) #endif { Serial.print(F("H")); @@ -52,6 +59,9 @@ void heartBeatPrint() if (num == 80) { Serial.println(); + + ethernet_manager.printMacAddress(); + num = 1; } else if (num++ % 10 == 0) @@ -70,6 +80,7 @@ void check_status() if ((millis() > checkstatus_timeout)) { heartBeatPrint(); + checkstatus_timeout = millis() + STATUS_CHECK_INTERVAL; } } @@ -77,25 +88,23 @@ void check_status() void initEthernet() { #if ( defined(USE_UIP_ETHERNET) && USE_UIP_ETHERNET ) - ET_LOGWARN(F("======== USE_UIP_ETHERNET ========")); + ETM_LOGWARN(F("======== USE_UIP_ETHERNET ========")); #elif USE_NATIVE_ETHERNET - ET_LOGWARN(F("======== USE_NATIVE_ETHERNET ========")); + ETM_LOGWARN(F("======== USE_NATIVE_ETHERNET ========")); #elif USE_ETHERNET_GENERIC - ET_LOGWARN(F("=========== USE_ETHERNET_GENERIC ===========")); -#elif USE_ETHERNET_ESP8266 - ET_LOGWARN(F("=========== USE_ETHERNET_ESP8266 ===========")); + ETM_LOGWARN(F("=========== USE_ETHERNET_GENERIC ===========")); #elif USE_ETHERNET_ENC - ET_LOGWARN(F("=========== USE_ETHERNET_ENC ===========")); + ETM_LOGWARN(F("=========== USE_ETHERNET_ENC ===========")); #else - ET_LOGWARN(F("=========================")); + ETM_LOGWARN(F("=========================")); #endif - ET_LOGWARN(F("Default SPI pinout:")); - ET_LOGWARN1(F("MOSI:"), MOSI); - ET_LOGWARN1(F("MISO:"), MISO); - ET_LOGWARN1(F("SCK:"), SCK); - ET_LOGWARN1(F("SS:"), SS); - ET_LOGWARN(F("=========================")); + ETM_LOGWARN(F("Default SPI pinout:")); + ETM_LOGWARN1(F("MOSI:"), MOSI); + ETM_LOGWARN1(F("MISO:"), MISO); + ETM_LOGWARN1(F("SCK:"), SCK); + ETM_LOGWARN1(F("SS:"), SS); + ETM_LOGWARN(F("=========================")); #if defined(ESP8266) @@ -111,7 +120,7 @@ void initEthernet() #define USE_THIS_SS_PIN D2 // For ESP8266 #endif - ET_LOGWARN1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN); + ETM_LOGWARN1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN); #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) // For ESP8266 @@ -160,7 +169,7 @@ void initEthernet() #endif #endif - ET_LOGWARN1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN); + ETM_LOGWARN1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN); // For other boards, to change if necessary #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) @@ -186,9 +195,9 @@ void initEthernet() #endif #if defined(BOARD_NAME) - ET_LOGWARN3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN); + ETM_LOGWARN3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN); #else - ET_LOGWARN1(F("Unknown board setCsPin:"), USE_THIS_SS_PIN); + ETM_LOGWARN1(F("Unknown board setCsPin:"), USE_THIS_SS_PIN); #endif // For other boards, to change if necessary @@ -209,20 +218,20 @@ void initEthernet() // Just info to know how to connect correctly #if defined(CUR_PIN_MISO) - ET_LOGWARN(F("Currently Used SPI pinout:")); - ET_LOGWARN1(F("MOSI:"), CUR_PIN_MOSI); - ET_LOGWARN1(F("MISO:"), CUR_PIN_MISO); - ET_LOGWARN1(F("SCK:"), CUR_PIN_SCK); - ET_LOGWARN1(F("SS:"), CUR_PIN_SS); + ETM_LOGWARN(F("Currently Used SPI pinout:")); + ETM_LOGWARN1(F("MOSI:"), CUR_PIN_MOSI); + ETM_LOGWARN1(F("MISO:"), CUR_PIN_MISO); + ETM_LOGWARN1(F("SCK:"), CUR_PIN_SCK); + ETM_LOGWARN1(F("SS:"), CUR_PIN_SS); #else - ET_LOGWARN(F("Currently Used SPI pinout:")); - ET_LOGWARN1(F("MOSI:"), MOSI); - ET_LOGWARN1(F("MISO:"), MISO); - ET_LOGWARN1(F("SCK:"), SCK); - ET_LOGWARN1(F("SS:"), SS); + ETM_LOGWARN(F("Currently Used SPI pinout:")); + ETM_LOGWARN1(F("MOSI:"), MOSI); + ETM_LOGWARN1(F("MISO:"), MISO); + ETM_LOGWARN1(F("SCK:"), SCK); + ETM_LOGWARN1(F("SS:"), SS); #endif - ET_LOGWARN(F("=========================")); + ETM_LOGWARN(F("=========================")); } #if USING_CUSTOMS_STYLE @@ -234,7 +243,7 @@ void setup() { // Debug console Serial.begin(115200); - while (!Serial); + while (!Serial && millis() < 5000); delay(200); @@ -272,6 +281,19 @@ void setup() ethernet_manager.setCORSHeader("Your Access-Control-Allow-Origin"); #endif + ////////////////////////////////////////////// + +#define USING_CUSTOM_MAC_ADDRESS true //false + +#if USING_CUSTOM_MAC_ADDRESS + // To use your specified macAddress + byte newMacAddress[6] = { 0xFE, 0xED, 0xDE, 0xAD, 0xBE, 0xEF }; + + ethernet_manager.setMacAddress(newMacAddress); +#endif + + ////////////////////////////////////////////// + ethernet_manager.begin(); ////////////////////////////////////////////// diff --git a/examples/Ethernet_Generic/defines.h b/examples/Ethernet_Generic/defines.h index d569e0ae..fea6b566 100644 --- a/examples/Ethernet_Generic/defines.h +++ b/examples/Ethernet_Generic/defines.h @@ -80,11 +80,27 @@ #if defined(ETHERNET_USE_SAMD) // For SAMD - // Default pin 10 to SS/CS - #define USE_THIS_SS_PIN 10 + // Default pin SS/CS,if no SS pin, use pin 10 + #if defined(PIN_SPI_MOSI) + //#warning Using SS pin + #define USE_THIS_SS_PIN 10 //SS + #else + #define USE_THIS_SS_PIN 10 + #endif #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) #define BOARD_TYPE "SAMD Zero" + + // Default to use W5100. Must change to false for W5500, W5100S, for faster SPI clock + // Must use true for SAMD21, such as Zero, SAMD_FEATHER_M0_EXPRESS, etc. + #define USE_W5100 true + + // Use this for ARDUINO_SAMD_ZERO, etc. if can't print to terminal with Serial.print + #if defined(SERIAL_PORT_USBVIRTUAL) + #define Serial SERIAL_PORT_USBVIRTUAL + #warning Using SAMD Zero SerialUSB + #endif + #elif defined(ARDUINO_SAMD_MKR1000) #define BOARD_TYPE "SAMD MKR1000" #elif defined(ARDUINO_SAMD_MKRWIFI1010) @@ -226,10 +242,12 @@ #endif #elif ( defined(CORE_TEENSY) ) + #error Teensy not supported // Default pin 10 to SS/CS #define USE_THIS_SS_PIN 10 #if defined(__IMXRT1062__) + // For Teensy 4.1/4.0 #if defined(ARDUINO_TEENSY41) #define BOARD_TYPE "TEENSY 4.1" @@ -335,8 +353,6 @@ //#define USE_UIP_ETHERNET true #define USE_UIP_ETHERNET false -// Note: To rename ESP628266 Ethernet lib files to Ethernet_ESP8266.h and Ethernet_ESP8266.cpp -// In order to USE_ETHERNET_ESP8266 #if ( !defined(USE_UIP_ETHERNET) || !USE_UIP_ETHERNET ) // To override the default CS/SS pin. Don't use unless you know exactly which pin to use @@ -346,11 +362,10 @@ // Only one if the following to be true #define USE_ETHERNET_GENERIC true - #define USE_ETHERNET_ESP8266 false #define USE_ETHERNET_ENC false #define USE_CUSTOM_ETHERNET false - #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ESP8266 || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET ) + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET ) #ifdef USE_CUSTOM_ETHERNET #undef USE_CUSTOM_ETHERNET #endif @@ -363,23 +378,18 @@ #define SHIELD_TYPE "Custom Ethernet using Teensy 4.1 NativeEthernet Library" #elif USE_ETHERNET_GENERIC - #if USING_SPI2 - #define SHIELD_TYPE "W5x00 using Ethernet_Generic Library on SPI1" - #else - #define SHIELD_TYPE "W5x00 using Ethernet_Generic Library on SPI0/SPI" - #endif - - #define ETHERNET_LARGE_BUFFERS - - #define _ETG_LOGLEVEL_ 1 - - #include "Ethernet_Generic.h" - #warning Using Ethernet_Generic lib - - #elif USE_ETHERNET_ESP8266 - #include "Ethernet_ESP8266.h" - #warning Using Ethernet_ESP8266 lib - #define SHIELD_TYPE "W5x00 using Ethernet_ESP8266 Library" + #if USING_SPI2 + #define SHIELD_TYPE "W5x00 using Ethernet_Generic Library on SPI1" + #else + #define SHIELD_TYPE "W5x00 using Ethernet_Generic Library on SPI0/SPI" + #endif + + #define ETHERNET_LARGE_BUFFERS + + #define _ETG_LOGLEVEL_ 1 + + #include "Ethernet_Generic.h" + #warning Using Ethernet_Generic lib #elif USE_ETHERNET_ENC #include "EthernetENC.h" diff --git a/examples/Ethernet_RP2040/Ethernet_RP2040.ino b/examples/Ethernet_RP2040/Ethernet_RP2040.ino index 5f4574c2..7d368421 100644 --- a/examples/Ethernet_RP2040/Ethernet_RP2040.ino +++ b/examples/Ethernet_RP2040/Ethernet_RP2040.ino @@ -30,18 +30,25 @@ void heartBeatPrint() localEthernetIP = Ethernet.localIP(); #if (USE_ETHERNET_GENERIC) + + #if USE_W5100 + // The linkStatus() is not working with W5100. Just using IP != 0.0.0.0 + if ( (uint32_t) localEthernetIP != 0 ) + #else linkStatus = Ethernet.link(); - ET_LOGINFO3("localEthernetIP = ", localEthernetIP, ", linkStatus = ", (linkStatus == 1) ? "LinkON" : "LinkOFF" ); + ETM_LOGINFO1("localEthernetIP = ", localEthernetIP); + + if ( ( linkStatus == 1 ) || ((uint32_t) localEthernetIP != 0) ) + #endif - if ( ( linkStatus == 1 ) && ((uint32_t) localEthernetIP != 0) ) #else // The linkStatus() is not working with W5100. Just using IP != 0.0.0.0 // Better to use ping for W5100 linkStatus = (int) Ethernet.linkStatus(); - ET_LOGINFO3("localEthernetIP = ", localEthernetIP, ", linkStatus = ", (linkStatus == LinkON) ? "LinkON" : "LinkOFF" ); - - if ( ( (linkStatus == LinkON) || !isW5500 ) && ((uint32_t) localEthernetIP != 0) ) + ETM_LOGINFO1("localEthernetIP = ", localEthernetIP); + + if ( ( (linkStatus == LinkON) || !isW5500 ) || ((uint32_t) localEthernetIP != 0) ) #endif { Serial.print(F("H")); @@ -52,6 +59,9 @@ void heartBeatPrint() if (num == 80) { Serial.println(); + + ethernet_manager.printMacAddress(); + num = 1; } else if (num++ % 10 == 0) @@ -78,8 +88,6 @@ void initEthernet() { #if USE_ETHERNET_GENERIC ET_LOGWARN(F("=========== USE_ETHERNET_GENERIC ===========")); -#elif USE_ETHERNET_ESP8266 - ET_LOGWARN(F("=========== USE_ETHERNET_ESP8266 ===========")); #elif USE_ETHERNET_ENC ET_LOGWARN(F("=========== USE_ETHERNET_ENC ===========")); #else @@ -186,6 +194,19 @@ void setup() ethernet_manager.setCORSHeader("Your Access-Control-Allow-Origin"); #endif + ////////////////////////////////////////////// + +#define USING_CUSTOM_MAC_ADDRESS false + +#if USING_CUSTOM_MAC_ADDRESS + // To use your specified macAddress + byte newMacAddress[6] = { 0xFE, 0xED, 0xDE, 0xAD, 0xBE, 0xEF }; + + ethernet_manager.setMacAddress(newMacAddress); +#endif + + ////////////////////////////////////////////// + ethernet_manager.begin(); ////////////////////////////////////////////// diff --git a/examples/Ethernet_RP2040/defines.h b/examples/Ethernet_RP2040/defines.h index 2ad17379..0c9437e4 100644 --- a/examples/Ethernet_RP2040/defines.h +++ b/examples/Ethernet_RP2040/defines.h @@ -86,8 +86,6 @@ //#define USE_UIP_ETHERNET true #define USE_UIP_ETHERNET false -// Note: To rename ESP628266 Ethernet lib files to Ethernet_ESP8266.h and Ethernet_ESP8266.cpp -// In order to USE_ETHERNET_ESP8266 #if ( !defined(USE_UIP_ETHERNET) || !USE_UIP_ETHERNET ) // To override the default CS/SS pin. Don't use unless you know exactly which pin to use @@ -97,13 +95,12 @@ // Only one if the following to be true #define USE_ETHERNET_GENERIC true - #define USE_ETHERNET_ESP8266 false #define USE_ETHERNET_ENC false #define USE_CUSTOM_ETHERNET false //////////////////////////// - #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ESP8266 || USE_ETHERNET_ENC ) + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) #ifdef USE_CUSTOM_ETHERNET #undef USE_CUSTOM_ETHERNET #endif @@ -172,7 +169,6 @@ ////////////////////////////////////////// - #include #ifndef SHIELD_TYPE diff --git a/examples/Ethernet_SAMD/Ethernet_SAMD.ino b/examples/Ethernet_SAMD/Ethernet_SAMD.ino index 9602d0a5..b5465666 100644 --- a/examples/Ethernet_SAMD/Ethernet_SAMD.ino +++ b/examples/Ethernet_SAMD/Ethernet_SAMD.ino @@ -30,18 +30,25 @@ void heartBeatPrint() localEthernetIP = Ethernet.localIP(); #if (USE_ETHERNET_GENERIC) + + #if USE_W5100 + // The linkStatus() is not working with W5100. Just using IP != 0.0.0.0 + if ( (uint32_t) localEthernetIP != 0 ) + #else linkStatus = Ethernet.link(); - ET_LOGINFO3("localEthernetIP = ", localEthernetIP, ", linkStatus = ", (linkStatus == 1) ? "LinkON" : "LinkOFF" ); + ETM_LOGINFO1("localEthernetIP = ", localEthernetIP); + + if ( ( linkStatus == 1 ) || ((uint32_t) localEthernetIP != 0) ) + #endif - if ( ( linkStatus == 1 ) && ((uint32_t) localEthernetIP != 0) ) #else // The linkStatus() is not working with W5100. Just using IP != 0.0.0.0 // Better to use ping for W5100 linkStatus = (int) Ethernet.linkStatus(); - ET_LOGINFO3("localEthernetIP = ", localEthernetIP, ", linkStatus = ", (linkStatus == LinkON) ? "LinkON" : "LinkOFF" ); - - if ( ( (linkStatus == LinkON) || !isW5500 ) && ((uint32_t) localEthernetIP != 0) ) + ETM_LOGINFO1("localEthernetIP = ", localEthernetIP); + + if ( ( (linkStatus == LinkON) || !isW5500 ) || ((uint32_t) localEthernetIP != 0) ) #endif { Serial.print(F("H")); @@ -52,6 +59,9 @@ void heartBeatPrint() if (num == 80) { Serial.println(); + + ethernet_manager.printMacAddress(); + num = 1; } else if (num++ % 10 == 0) @@ -82,8 +92,6 @@ void initEthernet() ET_LOGWARN(F("======== USE_NATIVE_ETHERNET ========")); #elif USE_ETHERNET_GENERIC ET_LOGWARN(F("=========== USE_ETHERNET_GENERIC ===========")); -#elif USE_ETHERNET_ESP8266 - ET_LOGWARN(F("=========== USE_ETHERNET_ESP8266 ===========")); #elif USE_ETHERNET_ENC ET_LOGWARN(F("=========== USE_ETHERNET_ENC ===========")); #else @@ -260,6 +268,19 @@ void setup() ethernet_manager.setCORSHeader("Your Access-Control-Allow-Origin"); #endif + ////////////////////////////////////////////// + +#define USING_CUSTOM_MAC_ADDRESS false + +#if USING_CUSTOM_MAC_ADDRESS + // To use your specified macAddress + byte newMacAddress[6] = { 0xFE, 0xED, 0xDE, 0xAD, 0xBE, 0xEF }; + + ethernet_manager.setMacAddress(newMacAddress); +#endif + + ////////////////////////////////////////////// + ethernet_manager.begin(); ////////////////////////////////////////////// diff --git a/examples/Ethernet_SAMD/defines.h b/examples/Ethernet_SAMD/defines.h index d569e0ae..28eb8c72 100644 --- a/examples/Ethernet_SAMD/defines.h +++ b/examples/Ethernet_SAMD/defines.h @@ -80,11 +80,27 @@ #if defined(ETHERNET_USE_SAMD) // For SAMD - // Default pin 10 to SS/CS - #define USE_THIS_SS_PIN 10 + // Default pin SS/CS,if no SS pin, use pin 10 + #if defined(PIN_SPI_MOSI) + //#warning Using SS pin + #define USE_THIS_SS_PIN 10 //SS + #else + #define USE_THIS_SS_PIN 10 + #endif #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) #define BOARD_TYPE "SAMD Zero" + + // Default to use W5100. Must change to false for W5500, W5100S, for faster SPI clock + // Must use true for SAMD21, such as Zero, SAMD_FEATHER_M0_EXPRESS, etc. + #define USE_W5100 true + + // Use this for ARDUINO_SAMD_ZERO, etc. if can't print to terminal with Serial.print + #if defined(SERIAL_PORT_USBVIRTUAL) + #define Serial SERIAL_PORT_USBVIRTUAL + #warning Using SAMD Zero SerialUSB + #endif + #elif defined(ARDUINO_SAMD_MKR1000) #define BOARD_TYPE "SAMD MKR1000" #elif defined(ARDUINO_SAMD_MKRWIFI1010) @@ -226,6 +242,7 @@ #endif #elif ( defined(CORE_TEENSY) ) + #error Teensy not supported // Default pin 10 to SS/CS #define USE_THIS_SS_PIN 10 @@ -335,8 +352,6 @@ //#define USE_UIP_ETHERNET true #define USE_UIP_ETHERNET false -// Note: To rename ESP628266 Ethernet lib files to Ethernet_ESP8266.h and Ethernet_ESP8266.cpp -// In order to USE_ETHERNET_ESP8266 #if ( !defined(USE_UIP_ETHERNET) || !USE_UIP_ETHERNET ) // To override the default CS/SS pin. Don't use unless you know exactly which pin to use @@ -346,11 +361,10 @@ // Only one if the following to be true #define USE_ETHERNET_GENERIC true - #define USE_ETHERNET_ESP8266 false #define USE_ETHERNET_ENC false #define USE_CUSTOM_ETHERNET false - #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ESP8266 || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET ) + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET ) #ifdef USE_CUSTOM_ETHERNET #undef USE_CUSTOM_ETHERNET #endif @@ -375,12 +389,7 @@ #include "Ethernet_Generic.h" #warning Using Ethernet_Generic lib - - #elif USE_ETHERNET_ESP8266 - #include "Ethernet_ESP8266.h" - #warning Using Ethernet_ESP8266 lib - #define SHIELD_TYPE "W5x00 using Ethernet_ESP8266 Library" - + #elif USE_ETHERNET_ENC #include "EthernetENC.h" #warning Using EthernetENC lib diff --git a/examples/Ethernet_SAM_DUE/Ethernet_SAM_DUE.ino b/examples/Ethernet_SAM_DUE/Ethernet_SAM_DUE.ino index 5acaff7c..6e50aaec 100644 --- a/examples/Ethernet_SAM_DUE/Ethernet_SAM_DUE.ino +++ b/examples/Ethernet_SAM_DUE/Ethernet_SAM_DUE.ino @@ -30,18 +30,25 @@ void heartBeatPrint() localEthernetIP = Ethernet.localIP(); #if (USE_ETHERNET_GENERIC) + + #if USE_W5100 + // The linkStatus() is not working with W5100. Just using IP != 0.0.0.0 + if ( (uint32_t) localEthernetIP != 0 ) + #else linkStatus = Ethernet.link(); - ET_LOGINFO3("localEthernetIP = ", localEthernetIP, ", linkStatus = ", (linkStatus == 1) ? "LinkON" : "LinkOFF" ); + ETM_LOGINFO1("localEthernetIP = ", localEthernetIP); + + if ( ( linkStatus == 1 ) || ((uint32_t) localEthernetIP != 0) ) + #endif - if ( ( linkStatus == 1 ) && ((uint32_t) localEthernetIP != 0) ) #else // The linkStatus() is not working with W5100. Just using IP != 0.0.0.0 // Better to use ping for W5100 linkStatus = (int) Ethernet.linkStatus(); - ET_LOGINFO3("localEthernetIP = ", localEthernetIP, ", linkStatus = ", (linkStatus == LinkON) ? "LinkON" : "LinkOFF" ); - - if ( ( (linkStatus == LinkON) || !isW5500 ) && ((uint32_t) localEthernetIP != 0) ) + ETM_LOGINFO1("localEthernetIP = ", localEthernetIP); + + if ( ( (linkStatus == LinkON) || !isW5500 ) || ((uint32_t) localEthernetIP != 0) ) #endif { Serial.print(F("H")); @@ -52,6 +59,9 @@ void heartBeatPrint() if (num == 80) { Serial.println(); + + ethernet_manager.printMacAddress(); + num = 1; } else if (num++ % 10 == 0) @@ -77,25 +87,23 @@ void check_status() void initEthernet() { #if ( defined(USE_UIP_ETHERNET) && USE_UIP_ETHERNET ) - ET_LOGWARN(F("======== USE_UIP_ETHERNET ========")); + ETM_LOGWARN(F("======== USE_UIP_ETHERNET ========")); #elif USE_NATIVE_ETHERNET - ET_LOGWARN(F("======== USE_NATIVE_ETHERNET ========")); + ETM_LOGWARN(F("======== USE_NATIVE_ETHERNET ========")); #elif USE_ETHERNET_GENERIC - ET_LOGWARN(F("=========== USE_ETHERNET_GENERIC ===========")); -#elif USE_ETHERNET_ESP8266 - ET_LOGWARN(F("=========== USE_ETHERNET_ESP8266 ===========")); + ETM_LOGWARN(F("=========== USE_ETHERNET_GENERIC ===========")); #elif USE_ETHERNET_ENC - ET_LOGWARN(F("=========== USE_ETHERNET_ENC ===========")); + ETM_LOGWARN(F("=========== USE_ETHERNET_ENC ===========")); #else - ET_LOGWARN(F("=========================")); + ETM_LOGWARN(F("=========================")); #endif - ET_LOGWARN(F("Default SPI pinout:")); - ET_LOGWARN1(F("MOSI:"), MOSI); - ET_LOGWARN1(F("MISO:"), MISO); - ET_LOGWARN1(F("SCK:"), SCK); - ET_LOGWARN1(F("SS:"), SS); - ET_LOGWARN(F("=========================")); + ETM_LOGWARN(F("Default SPI pinout:")); + ETM_LOGWARN1(F("MOSI:"), MOSI); + ETM_LOGWARN1(F("MISO:"), MISO); + ETM_LOGWARN1(F("SCK:"), SCK); + ETM_LOGWARN1(F("SS:"), SS); + ETM_LOGWARN(F("=========================")); #if defined(ESP8266) @@ -111,7 +119,7 @@ void initEthernet() #define USE_THIS_SS_PIN D2 // For ESP8266 #endif - ET_LOGWARN1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN); + ETM_LOGWARN1(F("ESP8266 setCsPin:"), USE_THIS_SS_PIN); #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) // For ESP8266 @@ -160,7 +168,7 @@ void initEthernet() #endif #endif - ET_LOGWARN1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN); + ETM_LOGWARN1(F("ESP32 setCsPin:"), USE_THIS_SS_PIN); // For other boards, to change if necessary #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC ) @@ -186,9 +194,9 @@ void initEthernet() #endif #if defined(BOARD_NAME) - ET_LOGWARN3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN); + ETM_LOGWARN3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN); #else - ET_LOGWARN1(F("Unknown board setCsPin:"), USE_THIS_SS_PIN); + ETM_LOGWARN1(F("Unknown board setCsPin:"), USE_THIS_SS_PIN); #endif // For other boards, to change if necessary @@ -209,20 +217,20 @@ void initEthernet() // Just info to know how to connect correctly #if defined(CUR_PIN_MISO) - ET_LOGWARN(F("Currently Used SPI pinout:")); - ET_LOGWARN1(F("MOSI:"), CUR_PIN_MOSI); - ET_LOGWARN1(F("MISO:"), CUR_PIN_MISO); - ET_LOGWARN1(F("SCK:"), CUR_PIN_SCK); - ET_LOGWARN1(F("SS:"), CUR_PIN_SS); + ETM_LOGWARN(F("Currently Used SPI pinout:")); + ETM_LOGWARN1(F("MOSI:"), CUR_PIN_MOSI); + ETM_LOGWARN1(F("MISO:"), CUR_PIN_MISO); + ETM_LOGWARN1(F("SCK:"), CUR_PIN_SCK); + ETM_LOGWARN1(F("SS:"), CUR_PIN_SS); #else - ET_LOGWARN(F("Currently Used SPI pinout:")); - ET_LOGWARN1(F("MOSI:"), MOSI); - ET_LOGWARN1(F("MISO:"), MISO); - ET_LOGWARN1(F("SCK:"), SCK); - ET_LOGWARN1(F("SS:"), SS); + ETM_LOGWARN(F("Currently Used SPI pinout:")); + ETM_LOGWARN1(F("MOSI:"), MOSI); + ETM_LOGWARN1(F("MISO:"), MISO); + ETM_LOGWARN1(F("SCK:"), SCK); + ETM_LOGWARN1(F("SS:"), SS); #endif - ET_LOGWARN(F("=========================")); + ETM_LOGWARN(F("=========================")); } #if USING_CUSTOMS_STYLE @@ -260,6 +268,19 @@ void setup() ethernet_manager.setCORSHeader("Your Access-Control-Allow-Origin"); #endif + ////////////////////////////////////////////// + +#define USING_CUSTOM_MAC_ADDRESS false + +#if USING_CUSTOM_MAC_ADDRESS + // To use your specified macAddress + byte newMacAddress[6] = { 0xFE, 0xED, 0xDE, 0xAD, 0xBE, 0xEF }; + + ethernet_manager.setMacAddress(newMacAddress); +#endif + + ////////////////////////////////////////////// + ethernet_manager.begin(); ////////////////////////////////////////////// diff --git a/examples/Ethernet_SAM_DUE/defines.h b/examples/Ethernet_SAM_DUE/defines.h index d569e0ae..7baab45e 100644 --- a/examples/Ethernet_SAM_DUE/defines.h +++ b/examples/Ethernet_SAM_DUE/defines.h @@ -21,8 +21,9 @@ #define DEBUG_ETHERNET_WEBSERVER_PORT Serial // Debug Level from 0 to 4 -#define _ETHERNET_WEBSERVER_LOGLEVEL_ 2 -#define _ETHERNET_MANAGER_LOGLEVEL_ 2 +#define _ETG_LOGLEVEL_ 4 +#define _ETHERNET_WEBSERVER_LOGLEVEL_ 4 +#define _ETHERNET_MANAGER_LOGLEVEL_ 4 #define DRD_GENERIC_DEBUG true @@ -80,11 +81,27 @@ #if defined(ETHERNET_USE_SAMD) // For SAMD - // Default pin 10 to SS/CS - #define USE_THIS_SS_PIN 10 + // Default pin SS/CS,if no SS pin, use pin 10 + #if defined(PIN_SPI_MOSI) + //#warning Using SS pin + #define USE_THIS_SS_PIN 10 //SS + #else + #define USE_THIS_SS_PIN 10 + #endif #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) #define BOARD_TYPE "SAMD Zero" + + // Default to use W5100. Must change to false for W5500, W5100S, for faster SPI clock + // Must use true for SAMD21, such as Zero, SAMD_FEATHER_M0_EXPRESS, etc. + #define USE_W5100 true + + // Use this for ARDUINO_SAMD_ZERO, etc. if can't print to terminal with Serial.print + #if defined(SERIAL_PORT_USBVIRTUAL) + #define Serial SERIAL_PORT_USBVIRTUAL + #warning Using SAMD Zero SerialUSB + #endif + #elif defined(ARDUINO_SAMD_MKR1000) #define BOARD_TYPE "SAMD MKR1000" #elif defined(ARDUINO_SAMD_MKRWIFI1010) @@ -226,6 +243,7 @@ #endif #elif ( defined(CORE_TEENSY) ) + #error Teensy not supported // Default pin 10 to SS/CS #define USE_THIS_SS_PIN 10 @@ -335,8 +353,6 @@ //#define USE_UIP_ETHERNET true #define USE_UIP_ETHERNET false -// Note: To rename ESP628266 Ethernet lib files to Ethernet_ESP8266.h and Ethernet_ESP8266.cpp -// In order to USE_ETHERNET_ESP8266 #if ( !defined(USE_UIP_ETHERNET) || !USE_UIP_ETHERNET ) // To override the default CS/SS pin. Don't use unless you know exactly which pin to use @@ -346,11 +362,10 @@ // Only one if the following to be true #define USE_ETHERNET_GENERIC true - #define USE_ETHERNET_ESP8266 false #define USE_ETHERNET_ENC false #define USE_CUSTOM_ETHERNET false - #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ESP8266 || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET ) + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET ) #ifdef USE_CUSTOM_ETHERNET #undef USE_CUSTOM_ETHERNET #endif @@ -375,12 +390,7 @@ #include "Ethernet_Generic.h" #warning Using Ethernet_Generic lib - - #elif USE_ETHERNET_ESP8266 - #include "Ethernet_ESP8266.h" - #warning Using Ethernet_ESP8266 lib - #define SHIELD_TYPE "W5x00 using Ethernet_ESP8266 Library" - + #elif USE_ETHERNET_ENC #include "EthernetENC.h" #warning Using EthernetENC lib diff --git a/examples/Ethernet_Teensy/Ethernet_Teensy.ino b/examples/Ethernet_Teensy/Ethernet_Teensy.ino index 0cd1f06c..02142b27 100644 --- a/examples/Ethernet_Teensy/Ethernet_Teensy.ino +++ b/examples/Ethernet_Teensy/Ethernet_Teensy.ino @@ -30,18 +30,25 @@ void heartBeatPrint() localEthernetIP = Ethernet.localIP(); #if (USE_ETHERNET_GENERIC) + + #if USE_W5100 + // The linkStatus() is not working with W5100. Just using IP != 0.0.0.0 + if ( (uint32_t) localEthernetIP != 0 ) + #else linkStatus = Ethernet.link(); - ET_LOGINFO3("localEthernetIP = ", localEthernetIP, ", linkStatus = ", (linkStatus == 1) ? "LinkON" : "LinkOFF" ); + ETM_LOGINFO1("localEthernetIP = ", localEthernetIP); + + if ( ( linkStatus == 1 ) || ((uint32_t) localEthernetIP != 0) ) + #endif - if ( ( linkStatus == 1 ) && ((uint32_t) localEthernetIP != 0) ) #else // The linkStatus() is not working with W5100. Just using IP != 0.0.0.0 // Better to use ping for W5100 linkStatus = (int) Ethernet.linkStatus(); - ET_LOGINFO3("localEthernetIP = ", localEthernetIP, ", linkStatus = ", (linkStatus == LinkON) ? "LinkON" : "LinkOFF" ); - - if ( ( (linkStatus == LinkON) || !isW5500 ) && ((uint32_t) localEthernetIP != 0) ) + ETM_LOGINFO1("localEthernetIP = ", localEthernetIP); + + if ( ( (linkStatus == LinkON) || !isW5500 ) || ((uint32_t) localEthernetIP != 0) ) #endif { Serial.print(F("H")); @@ -52,6 +59,9 @@ void heartBeatPrint() if (num == 80) { Serial.println(); + + ethernet_manager.printMacAddress(); + num = 1; } else if (num++ % 10 == 0) @@ -82,8 +92,6 @@ void initEthernet() ET_LOGWARN(F("======== USE_NATIVE_ETHERNET ========")); #elif USE_ETHERNET_GENERIC ET_LOGWARN(F("=========== USE_ETHERNET_GENERIC ===========")); -#elif USE_ETHERNET_ESP8266 - ET_LOGWARN(F("=========== USE_ETHERNET_ESP8266 ===========")); #elif USE_ETHERNET_ENC ET_LOGWARN(F("=========== USE_ETHERNET_ENC ===========")); #else diff --git a/examples/Ethernet_Teensy/defines.h b/examples/Ethernet_Teensy/defines.h index 0ac6ed2c..56cad852 100644 --- a/examples/Ethernet_Teensy/defines.h +++ b/examples/Ethernet_Teensy/defines.h @@ -57,7 +57,6 @@ #define USE_UIP_ETHERNET false #define USE_ETHERNET_GENERIC false -#define USE_ETHERNET_ESP8266 false #define USE_ETHERNET_ENC false #define USE_CUSTOM_ETHERNET false diff --git a/examples/Ethernet_WT32_ETH01/Ethernet_WT32_ETH01.ino b/examples/Ethernet_WT32_ETH01/Ethernet_WT32_ETH01.ino index ab12d6af..3de012a7 100644 --- a/examples/Ethernet_WT32_ETH01/Ethernet_WT32_ETH01.ino +++ b/examples/Ethernet_WT32_ETH01/Ethernet_WT32_ETH01.ino @@ -20,7 +20,7 @@ IPAddress localEthernetIP; void heartBeatPrint() { - static int num = 1; + static int num = 1; localEthernetIP = ETH.localIP(); @@ -66,19 +66,19 @@ void WiFiEvent(WiFiEvent_t event) #if ( ( defined(ESP_ARDUINO_VERSION_MAJOR) && (ESP_ARDUINO_VERSION_MAJOR >= 2) ) && ( ARDUINO_ESP32_GIT_VER != 0x46d5afb1 ) ) //#warning Using ESP32 core v2.0.0+ // Core v2.0.0+ - switch (event) + switch (event) { - case ARDUINO_EVENT_ETH_START: + case SYSTEM_EVENT_ETH_START: ETM_LOGERROR(F("ETH Started")); //set eth hostname here ETH.setHostname("WT32-ETH01"); break; - case ARDUINO_EVENT_ETH_CONNECTED: + case SYSTEM_EVENT_ETH_CONNECTED: ETM_LOGERROR(F("ETH Connected")); break; - case ARDUINO_EVENT_ETH_GOT_IP: - if (!ethernet_manager.ethernetConnected) + case SYSTEM_EVENT_ETH_GOT_IP: + if (!ethernet_manager.isEthernetConnected()) { ETM_LOGERROR3(F("ETH MAC:"), ETH.macAddress(), F(", IPv4:"), ETH.localIP()); @@ -91,19 +91,19 @@ void WiFiEvent(WiFiEvent_t event) ETM_LOGERROR1(F("HALF_DUPLEX, Link Speed (Mbps)"), ETH.linkSpeed()); } - ethernet_manager.ethernetConnected = true; + ethernet_manager.setEthernetConnected(); } break; - case ARDUINO_EVENT_ETH_DISCONNECTED: + case SYSTEM_EVENT_ETH_DISCONNECTED: ETM_LOGERROR(F("ETH Disconnected")); - ethernet_manager.ethernetConnected = false; + ethernet_manager.setEthernetDisconnected(); break; - case ARDUINO_EVENT_ETH_STOP: + case SYSTEM_EVENT_ETH_STOP: ETM_LOGERROR(F("\nETH Stopped")); - ethernet_manager.ethernetConnected = false; + ethernet_manager.setEthernetDisconnected(); break; default: @@ -127,7 +127,7 @@ void WiFiEvent(WiFiEvent_t event) break; case SYSTEM_EVENT_ETH_GOT_IP: - if (!ethernet_manager.ethernetConnected) + if (!ethernet_manager.isEthernetConnected()) { ETM_LOGERROR3(F("ETH MAC:"), ETH.macAddress(), F(", IPv4:"), ETH.localIP()); @@ -140,19 +140,19 @@ void WiFiEvent(WiFiEvent_t event) ETM_LOGERROR1(F("HALF_DUPLEX, Link Speed (Mbps)"), ETH.linkSpeed()); } - ethernet_manager.ethernetConnected = true; + ethernet_manager.setEthernetConnected(); } break; case SYSTEM_EVENT_ETH_DISCONNECTED: ETM_LOGERROR(F("ETH Disconnected")); - ethernet_manager.ethernetConnected = false; + ethernet_manager.setEthernetDisconnected(); break; case SYSTEM_EVENT_ETH_STOP: ETM_LOGERROR(F("\nETH Stopped")); - ethernet_manager.ethernetConnected = false; + ethernet_manager.setEthernetDisconnected(); break; default: @@ -165,10 +165,10 @@ void setup() { // Debug console Serial.begin(115200); - while (!Serial); + //while (!Serial); // Using this if Serial debugging is not necessary or not using Serial port - //while (!Serial && (millis() < 3000)); + while (!Serial && (millis() < 5000)); Serial.print("\nStart Ethernet_WT32_ETH01 on "); Serial.println(BOARD_NAME); Serial.print("Ethernet Shield type : "); Serial.println(SHIELD_TYPE); diff --git a/examples/Ethernet_WT32_ETH01/defines.h b/examples/Ethernet_WT32_ETH01/defines.h index f7553f2c..44a14831 100644 --- a/examples/Ethernet_WT32_ETH01/defines.h +++ b/examples/Ethernet_WT32_ETH01/defines.h @@ -13,407 +13,12 @@ #ifndef defines_h #define defines_h -#if ( defined(ARDUINO_AVR_ADK) || defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560) ) - #error This code is designed to run on SAMD, SAM-DUE, Teensy platform, ESP8266, ESP32 not AVR Mega! Please check your Tools->Board setting. -#endif - -/* Comment this out to disable prints and save space */ -#define DEBUG_ETHERNET_WEBSERVER_PORT Serial - // Debug Level from 0 to 4 -#define _ETHERNET_WEBSERVER_LOGLEVEL_ 0 -#define _ETHERNET_MANAGER_LOGLEVEL_ 2 - -#define DRD_GENERIC_DEBUG true - -// For ESP32/ESP8266 -#define DOUBLERESETDETECTOR_DEBUG true - -#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ - || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ - || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ - || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ - || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) - #if defined(ETHERNET_USE_SAMD) - #undef ETHERNET_USE_SAMD - #endif - #define ETHERNET_USE_SAMD true - #define USE_DYNAMIC_PARAMETERS true -#endif - -#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ - defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ - defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) - #if defined(ETHERNET_USE_NRF52) - #undef ETHERNET_USE_NRF528XX - #endif - #define ETHERNET_USE_NRF528XX true - #define USE_DYNAMIC_PARAMETERS true -#endif - -#if ( defined(NANO_RP2040_CONNECT) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ - defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) - // For RPI Pico - #if defined(ETHERNET_USE_RPIPICO) - #undef ETHERNET_USE_RPIPICO - #endif - #define ETHERNET_USE_RPIPICO true - #define USE_DYNAMIC_PARAMETERS true -#endif - -#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) - #if defined(ETHERNET_USE_SAM_DUE) - #undef ETHERNET_USE_SAM_DUE - #endif - #define ETHERNET_USE_SAM_DUE true - #define USE_DYNAMIC_PARAMETERS true -#endif - -#if ( defined(CORE_TEENSY) && !( defined(__MKL26Z64__) || defined(__AVR_AT90USB1286__) || defined(__AVR_ATmega32U4__) ) ) - // Don't support Teensy 2.x, LC - #if defined(ETHERNET_USE_TEENSY) - #undef ETHERNET_USE_TEENSY - #endif - #define ETHERNET_USE_TEENSY true - #define USE_DYNAMIC_PARAMETERS true -#endif - -#if defined(ETHERNET_USE_SAMD) - // For SAMD - // Default pin 10 to SS/CS - #define USE_THIS_SS_PIN 10 - - #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) - #define BOARD_TYPE "SAMD Zero" - #elif defined(ARDUINO_SAMD_MKR1000) - #define BOARD_TYPE "SAMD MKR1000" - #elif defined(ARDUINO_SAMD_MKRWIFI1010) - #define BOARD_TYPE "SAMD MKRWIFI1010" - #elif defined(ARDUINO_SAMD_NANO_33_IOT) - #define BOARD_TYPE "SAMD NANO_33_IOT" - #elif defined(ARDUINO_SAMD_MKRFox1200) - #define BOARD_TYPE "SAMD MKRFox1200" - #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) - #define BOARD_TYPE "SAMD MKRWAN13X0" - #elif defined(ARDUINO_SAMD_MKRGSM1400) - #define BOARD_TYPE "SAMD MKRGSM1400" - #elif defined(ARDUINO_SAMD_MKRNB1500) - #define BOARD_TYPE "SAMD MKRNB1500" - #elif defined(ARDUINO_SAMD_MKRVIDOR4000) - #define BOARD_TYPE "SAMD MKRVIDOR4000" - #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) - #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" - #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) - #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" - #elif defined(ADAFRUIT_METRO_M0_EXPRESS) - #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" - #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) - #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" - #elif defined(ADAFRUIT_GEMMA_M0) - #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" - #elif defined(ADAFRUIT_TRINKET_M0) - #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" - #elif defined(ADAFRUIT_ITSYBITSY_M0) - #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" - #elif defined(ARDUINO_SAMD_HALLOWING_M0) - #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" - #elif defined(ADAFRUIT_METRO_M4_EXPRESS) - #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" - #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) - #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" - #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) - #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" - #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) - #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" - #define USE_THIS_SS_PIN 10 - #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) - #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" - #elif defined(ADAFRUIT_PYPORTAL) - #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" - #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) - #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" - #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) - #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" - #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) - #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" - #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) - #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" - #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) - #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" - #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) - #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" - #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) - #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" - #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) - #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" - #elif defined(SEEED_WIO_TERMINAL) - #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" - #elif defined(SEEED_FEMTO_M0) - #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" - #elif defined(SEEED_XIAO_M0) - #define BOARD_TYPE "SAMD SEEED_XIAO_M0" - #ifdef USE_THIS_SS_PIN - #undef USE_THIS_SS_PIN - #endif - #define USE_THIS_SS_PIN A1 - #warning define SEEED_XIAO_M0 USE_THIS_SS_PIN == A1 - #elif defined(Wio_Lite_MG126) - #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" - #elif defined(WIO_GPS_BOARD) - #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" - #elif defined(SEEEDUINO_ZERO) - #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" - #elif defined(SEEEDUINO_LORAWAN) - #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" - #elif defined(SEEED_GROVE_UI_WIRELESS) - #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" - #elif defined(__SAMD21E18A__) - #define BOARD_TYPE "SAMD21E18A" - #elif defined(__SAMD21G18A__) - #define BOARD_TYPE "SAMD21G18A" - #elif defined(__SAMD51G19A__) - #define BOARD_TYPE "SAMD51G19A" - #elif defined(__SAMD51J19A__) - #define BOARD_TYPE "SAMD51J19A" - #elif defined(__SAMD51J20A__) - #define BOARD_TYPE "SAMD51J20A" - #elif defined(__SAM3X8E__) - #define BOARD_TYPE "SAM3X8E" - #elif defined(__CPU_ARC__) - #define BOARD_TYPE "CPU_ARC" - #elif defined(__SAMD51__) - #define BOARD_TYPE "SAMD51" - #else - #define BOARD_TYPE "SAMD Unknown" - #endif +#define _ETHERNET_WEBSERVER_LOGLEVEL_ 3 -#elif (ETHERNET_USE_SAM_DUE) - // Default pin 10 to SS/CS - #define USE_THIS_SS_PIN 10 - #define BOARD_TYPE "SAM DUE" +#define ETHERNET_USE_WT32_ETH01 true -#elif (ETHERNET_USE_NRF528XX) - // Default pin 10 to SS/CS - #define USE_THIS_SS_PIN 10 - - #if defined(NRF52840_FEATHER) - #define BOARD_TYPE "NRF52840_FEATHER" - #elif defined(NRF52832_FEATHER) - #define BOARD_TYPE "NRF52832_FEATHER" - #elif defined(NRF52840_FEATHER_SENSE) - #define BOARD_TYPE "NRF52840_FEATHER_SENSE" - #elif defined(NRF52840_ITSYBITSY) - #define BOARD_TYPE "NRF52840_ITSYBITSY" - #define USE_THIS_SS_PIN 10 // For other boards - #elif defined(NRF52840_CIRCUITPLAY) - #define BOARD_TYPE "NRF52840_CIRCUITPLAY" - #elif defined(NRF52840_CLUE) - #define BOARD_TYPE "NRF52840_CLUE" - #elif defined(NRF52840_METRO) - #define BOARD_TYPE "NRF52840_METRO" - #elif defined(NRF52840_PCA10056) - #define BOARD_TYPE "NRF52840_PCA10056" - #elif defined(NINA_B302_ublox) - #define BOARD_TYPE "NINA_B302_ublox" - #elif defined(NINA_B112_ublox) - #define BOARD_TYPE "NINA_B112_ublox" - #elif defined(PARTICLE_XENON) - #define BOARD_TYPE "PARTICLE_XENON" - #elif defined(ARDUINO_NRF52_ADAFRUIT) - #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" - #else - #define BOARD_TYPE "nRF52 Unknown" - #endif - -#elif ( defined(CORE_TEENSY) ) - // Default pin 10 to SS/CS - #define USE_THIS_SS_PIN 10 - - #if defined(__IMXRT1062__) - // For Teensy 4.1/4.0 - #if defined(ARDUINO_TEENSY41) - #define BOARD_TYPE "TEENSY 4.1" - // Use true for NativeEthernet Library, false if using other Ethernet libraries - #define USE_NATIVE_ETHERNET true - #elif defined(ARDUINO_TEENSY40) - #define BOARD_TYPE "TEENSY 4.0" - #else - #define BOARD_TYPE "TEENSY 4.x" - #endif - #elif defined(__MK66FX1M0__) - #define BOARD_TYPE "Teensy 3.6" - #elif defined(__MK64FX512__) - #define BOARD_TYPE "Teensy 3.5" - #elif defined(__MKL26Z64__) - #define BOARD_TYPE "Teensy LC" - #elif defined(__MK20DX256__) - #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) - #elif defined(__MK20DX128__) - #define BOARD_TYPE "Teensy 3.0" - #elif defined(__AVR_AT90USB1286__) - #error Teensy 2.0++ not supported yet - #elif defined(__AVR_ATmega32U4__) - #error Teensy 2.0 not supported yet - #else - // For Other Boards - #define BOARD_TYPE "Unknown Teensy Board" - #endif - -#elif ( defined(ESP8266) ) - // For ESP8266 - #warning Use ESP8266 architecture - #include - #define ETHERNET_USE_ESP8266 - #define BOARD_TYPE ARDUINO_BOARD //"ESP8266" - -#elif ( defined(ESP32) ) - // For ESP32 - #warning Use ESP32 architecture - #define ETHERNET_USE_ESP32 - #define BOARD_TYPE ARDUINO_BOARD //"ESP32" - - #define W5500_RST_PORT 21 - -#elif (ETHERNET_USE_RP2040) - - // Default pin 5 (in Mbed) or 17 to SS/CS - #if defined(ARDUINO_ARCH_MBED) - // For RPI Pico using Arduino Mbed RP2040 core - // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 - #define USE_THIS_SS_PIN 5 - - #if ( defined(NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ - defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) - // Only undef known BOARD_NAME to use better one - #undef BOARD_NAME - #endif - - #if defined(ARDUINO_RASPBERRY_PI_PICO) - #define BOARD_NAME "MBED RASPBERRY_PI_PICO" - #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) - #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" - #elif defined(ARDUINO_GENERIC_RP2040) - #define BOARD_NAME "MBED GENERIC_RP2040" - #elif defined(NANO_RP2040_CONNECT) - #define BOARD_NAME "MBED NANO_RP2040_CONNECT" - #else - // Use default BOARD_NAME if exists - #if !defined(BOARD_NAME) - #define BOARD_NAME "MBED Unknown RP2040" - #endif - #endif - - #else - // For RPI Pico using E. Philhower RP2040 core - // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 - #define USE_THIS_SS_PIN 17 - - #endif - -#else - // For Mega - // Default pin 10 to SS/CS - #define USE_THIS_SS_PIN 10 - - // Reduce size for Mega - #define SENDCONTENT_P_BUFFER_SZ 512 - - #define BOARD_TYPE "AVR Mega" -#endif - -#ifndef BOARD_NAME - #define BOARD_NAME BOARD_TYPE -#endif - -#include - - -// Use true for ENC28J60 and UIPEthernet library (https://github.com/UIPEthernet/UIPEthernet) -// Use false for W5x00 and Ethernetx library (https://www.arduino.cc/en/Reference/Ethernet) - -//#define USE_UIP_ETHERNET true -#define USE_UIP_ETHERNET false - -// Note: To rename ESP628266 Ethernet lib files to Ethernet_ESP8266.h and Ethernet_ESP8266.cpp -// In order to USE_ETHERNET_ESP8266 -#if ( !defined(USE_UIP_ETHERNET) || !USE_UIP_ETHERNET ) - - // To override the default CS/SS pin. Don't use unless you know exactly which pin to use - // You can define here or customize for each board at same place with BOARD_TYPE - // Check @ defined(SEEED_XIAO_M0) - //#define USE_THIS_SS_PIN 22 //21 //5 //4 //2 //15 - - // Only one if the following to be true - #define USE_ETHERNET_GENERIC true - #define USE_ETHERNET_ESP8266 false - #define USE_ETHERNET_ENC false - #define USE_CUSTOM_ETHERNET false - - #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ESP8266 || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET ) - #ifdef USE_CUSTOM_ETHERNET - #undef USE_CUSTOM_ETHERNET - #endif - #define USE_CUSTOM_ETHERNET false - #endif - - #if USE_NATIVE_ETHERNET - #include "NativeEthernet.h" - #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error - #define SHIELD_TYPE "Custom Ethernet using Teensy 4.1 NativeEthernet Library" - #elif USE_ETHERNET_GENERIC - - #if USING_SPI2 - #define SHIELD_TYPE "W5x00 using Ethernet_Generic Library on SPI1" - #else - #define SHIELD_TYPE "W5x00 using Ethernet_Generic Library on SPI0/SPI" - #endif - - #define ETHERNET_LARGE_BUFFERS - - #define _ETG_LOGLEVEL_ 1 - - #include "Ethernet_Generic.h" - #warning Using Ethernet_Generic lib - - #elif USE_ETHERNET_ESP8266 - #include "Ethernet_ESP8266.h" - #warning Using Ethernet_ESP8266 lib - #define SHIELD_TYPE "W5x00 using Ethernet_ESP8266 Library" - - #elif USE_ETHERNET_ENC - #include "EthernetENC.h" - #warning Using EthernetENC lib - #define SHIELD_TYPE "ENC28J60 using EthernetENC Library" - - #elif USE_CUSTOM_ETHERNET - //#include "Ethernet_XYZ.h" - #include "EthernetENC.h" - #warning Using Custom Ethernet library. You must include a library and initialize. - #define SHIELD_TYPE "Custom Ethernet using Ethernet_XYZ Library" - - #else - #ifdef USE_ETHERNET_GENERIC - #undef USE_ETHERNET_GENERIC - #endif - #define USE_ETHERNET_GENERIC true - #include "Ethernet_Generic.h" - #warning Using default Ethernet_Generic lib - #define SHIELD_TYPE "W5x00 using default Ethernet_Generic Library" - #endif - - // Ethernet_Shield_W5200, EtherCard, EtherSia not supported - // Select just 1 of the following #include if uncomment #define USE_CUSTOM_ETHERNET - // Otherwise, standard Ethernet library will be used for W5x00 - -#elif USE_UIP_ETHERNET - #include "UIPEthernet.h" - #warning Using UIPEthernet library - #define SHIELD_TYPE "ENC28J60 using UIPEthernet Library" -#endif // #if !USE_UIP_ETHERNET - -#ifndef SHIELD_TYPE - #define SHIELD_TYPE "Unknown Ethernet shield/library" -#endif +#include ////////////////////////////////////////// @@ -426,52 +31,21 @@ // Config data Size currently is 128 bytes w/o chksum, 132 with chksum) //#define EEPROM_START 1024 -#if ( defined(ESP32) || defined(ESP8266) ) +// TODO, to add ESP32 LittleFS support +// For ESP32 +#define USE_LITTLEFS false +#define USE_SPIFFS false - #if defined(ESP8266) - - // #define USE_SPIFFS and USE_LITTLEFS false => using EEPROM for configuration data in WiFiManager - // #define USE_LITTLEFS true => using LITTLEFS for configuration data in WiFiManager - // #define USE_LITTLEFS false and USE_SPIFFS true => using SPIFFS for configuration data in WiFiManager - // Be sure to define USE_LITTLEFS and USE_SPIFFS before #include - // From ESP8266 core 2.7.1, SPIFFS will be deprecated and to be replaced by LittleFS - // Select USE_LITTLEFS (higher priority) or USE_SPIFFS - - #define USE_LITTLEFS false - #define USE_SPIFFS false - - #if USE_LITTLEFS - //LittleFS has higher priority - #define CurrentFileFS "LittleFS" - #ifdef USE_SPIFFS - #undef USE_SPIFFS - #endif - #define USE_SPIFFS false - #elif USE_SPIFFS - #define CurrentFileFS "SPIFFS" - #endif - - #else //#if defined(ESP8266) - // TODO, to add ESP32 LittleFS support - // For ESP32 - #define USE_LITTLEFS false - #define USE_SPIFFS false - - #if USE_LITTLEFS - //LittleFS has higher priority - #define CurrentFileFS "LittleFS" - #ifdef USE_SPIFFS - #undef USE_SPIFFS - #endif - #define USE_SPIFFS false - #elif USE_SPIFFS - #define CurrentFileFS "SPIFFS" - #endif - #endif //#if defined(ESP8266) - -#else //#if ( defined(ESP32) || defined(ESP8266) ) - #define USE_SPIFFS false -#endif //#if ( defined(ESP32) || defined(ESP8266) ) +#if USE_LITTLEFS + //LittleFS has higher priority + #define CurrentFileFS "LittleFS" + #ifdef USE_SPIFFS + #undef USE_SPIFFS + #endif + #define USE_SPIFFS false +#elif USE_SPIFFS + #define CurrentFileFS "SPIFFS" +#endif #if !( USE_LITTLEFS || USE_SPIFFS) @@ -504,9 +78,6 @@ #include -#define W5100_CS 10 -#define SDCARD_CS 4 - -#define ETHERNET_HOST_NAME "Generic-Ethernet" +#define ETHERNET_HOST_NAME "WT32_ETH01" #endif //defines_h diff --git a/examples/Ethernet_nRF52/Ethernet_nRF52.ino b/examples/Ethernet_nRF52/Ethernet_nRF52.ino index f7ffb5bf..3c769d68 100644 --- a/examples/Ethernet_nRF52/Ethernet_nRF52.ino +++ b/examples/Ethernet_nRF52/Ethernet_nRF52.ino @@ -30,18 +30,25 @@ void heartBeatPrint() localEthernetIP = Ethernet.localIP(); #if (USE_ETHERNET_GENERIC) + + #if USE_W5100 + // The linkStatus() is not working with W5100. Just using IP != 0.0.0.0 + if ( (uint32_t) localEthernetIP != 0 ) + #else linkStatus = Ethernet.link(); - ET_LOGINFO3("localEthernetIP = ", localEthernetIP, ", linkStatus = ", (linkStatus == 1) ? "LinkON" : "LinkOFF" ); + ETM_LOGINFO1("localEthernetIP = ", localEthernetIP); + + if ( ( linkStatus == 1 ) || ((uint32_t) localEthernetIP != 0) ) + #endif - if ( ( linkStatus == 1 ) && ((uint32_t) localEthernetIP != 0) ) #else // The linkStatus() is not working with W5100. Just using IP != 0.0.0.0 // Better to use ping for W5100 linkStatus = (int) Ethernet.linkStatus(); - ET_LOGINFO3("localEthernetIP = ", localEthernetIP, ", linkStatus = ", (linkStatus == LinkON) ? "LinkON" : "LinkOFF" ); - - if ( ( (linkStatus == LinkON) || !isW5500 ) && ((uint32_t) localEthernetIP != 0) ) + ETM_LOGINFO1("localEthernetIP = ", localEthernetIP); + + if ( ( (linkStatus == LinkON) || !isW5500 ) || ((uint32_t) localEthernetIP != 0) ) #endif { Serial.print(F("H")); @@ -52,6 +59,9 @@ void heartBeatPrint() if (num == 80) { Serial.println(); + + ethernet_manager.printMacAddress(); + num = 1; } else if (num++ % 10 == 0) @@ -82,8 +92,6 @@ void initEthernet() ET_LOGWARN(F("======== USE_NATIVE_ETHERNET ========")); #elif USE_ETHERNET_GENERIC ET_LOGWARN(F("=========== USE_ETHERNET_GENERIC ===========")); -#elif USE_ETHERNET_ESP8266 - ET_LOGWARN(F("=========== USE_ETHERNET_ESP8266 ===========")); #elif USE_ETHERNET_ENC ET_LOGWARN(F("=========== USE_ETHERNET_ENC ===========")); #else @@ -260,6 +268,19 @@ void setup() ethernet_manager.setCORSHeader("Your Access-Control-Allow-Origin"); #endif + ////////////////////////////////////////////// + +#define USING_CUSTOM_MAC_ADDRESS false + +#if USING_CUSTOM_MAC_ADDRESS + // To use your specified macAddress + byte newMacAddress[6] = { 0xFE, 0xED, 0xDE, 0xAD, 0xBE, 0xEF }; + + ethernet_manager.setMacAddress(newMacAddress); +#endif + + ////////////////////////////////////////////// + ethernet_manager.begin(); ////////////////////////////////////////////// diff --git a/examples/Ethernet_nRF52/defines.h b/examples/Ethernet_nRF52/defines.h index d569e0ae..db163203 100644 --- a/examples/Ethernet_nRF52/defines.h +++ b/examples/Ethernet_nRF52/defines.h @@ -80,11 +80,27 @@ #if defined(ETHERNET_USE_SAMD) // For SAMD - // Default pin 10 to SS/CS - #define USE_THIS_SS_PIN 10 + // Default pin SS/CS,if no SS pin, use pin 10 + #if defined(PIN_SPI_MOSI) + //#warning Using SS pin + #define USE_THIS_SS_PIN 10 //SS + #else + #define USE_THIS_SS_PIN 10 + #endif #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) #define BOARD_TYPE "SAMD Zero" + + // Default to use W5100. Must change to false for W5500, W5100S, for faster SPI clock + // Must use true for SAMD21, such as Zero, SAMD_FEATHER_M0_EXPRESS, etc. + #define USE_W5100 true + + // Use this for ARDUINO_SAMD_ZERO, etc. if can't print to terminal with Serial.print + #if defined(SERIAL_PORT_USBVIRTUAL) + #define Serial SERIAL_PORT_USBVIRTUAL + #warning Using SAMD Zero SerialUSB + #endif + #elif defined(ARDUINO_SAMD_MKR1000) #define BOARD_TYPE "SAMD MKR1000" #elif defined(ARDUINO_SAMD_MKRWIFI1010) @@ -226,6 +242,7 @@ #endif #elif ( defined(CORE_TEENSY) ) + #error Teensy not supported // Default pin 10 to SS/CS #define USE_THIS_SS_PIN 10 @@ -335,8 +352,6 @@ //#define USE_UIP_ETHERNET true #define USE_UIP_ETHERNET false -// Note: To rename ESP628266 Ethernet lib files to Ethernet_ESP8266.h and Ethernet_ESP8266.cpp -// In order to USE_ETHERNET_ESP8266 #if ( !defined(USE_UIP_ETHERNET) || !USE_UIP_ETHERNET ) // To override the default CS/SS pin. Don't use unless you know exactly which pin to use @@ -346,11 +361,10 @@ // Only one if the following to be true #define USE_ETHERNET_GENERIC true - #define USE_ETHERNET_ESP8266 false #define USE_ETHERNET_ENC false #define USE_CUSTOM_ETHERNET false - #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ESP8266 || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET ) + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET ) #ifdef USE_CUSTOM_ETHERNET #undef USE_CUSTOM_ETHERNET #endif @@ -363,24 +377,19 @@ #define SHIELD_TYPE "Custom Ethernet using Teensy 4.1 NativeEthernet Library" #elif USE_ETHERNET_GENERIC - #if USING_SPI2 - #define SHIELD_TYPE "W5x00 using Ethernet_Generic Library on SPI1" - #else - #define SHIELD_TYPE "W5x00 using Ethernet_Generic Library on SPI0/SPI" - #endif - - #define ETHERNET_LARGE_BUFFERS - - #define _ETG_LOGLEVEL_ 1 - - #include "Ethernet_Generic.h" - #warning Using Ethernet_Generic lib - - #elif USE_ETHERNET_ESP8266 - #include "Ethernet_ESP8266.h" - #warning Using Ethernet_ESP8266 lib - #define SHIELD_TYPE "W5x00 using Ethernet_ESP8266 Library" + #if USING_SPI2 + #define SHIELD_TYPE "W5x00 using Ethernet_Generic Library on SPI1" + #else + #define SHIELD_TYPE "W5x00 using Ethernet_Generic Library on SPI0/SPI" + #endif + #define ETHERNET_LARGE_BUFFERS + + #define _ETG_LOGLEVEL_ 1 + + #include "Ethernet_Generic.h" + #warning Using Ethernet_Generic lib + #elif USE_ETHERNET_ENC #include "EthernetENC.h" #warning Using EthernetENC lib diff --git a/examples/MQTT_ThingStream_Ethernet_Generic/MQTT_ThingStream_Ethernet_Generic.ino b/examples/MQTT_ThingStream_Ethernet_Generic/MQTT_ThingStream_Ethernet_Generic.ino index 29330159..574c53e3 100644 --- a/examples/MQTT_ThingStream_Ethernet_Generic/MQTT_ThingStream_Ethernet_Generic.ino +++ b/examples/MQTT_ThingStream_Ethernet_Generic/MQTT_ThingStream_Ethernet_Generic.ino @@ -121,18 +121,25 @@ void heartBeatPrint() localEthernetIP = Ethernet.localIP(); #if (USE_ETHERNET_GENERIC) + + #if USE_W5100 + // The linkStatus() is not working with W5100. Just using IP != 0.0.0.0 + if ( (uint32_t) localEthernetIP != 0 ) + #else linkStatus = Ethernet.link(); - ET_LOGINFO3("localEthernetIP = ", localEthernetIP, ", linkStatus = ", (linkStatus == 1) ? "LinkON" : "LinkOFF" ); + ETM_LOGINFO1("localEthernetIP = ", localEthernetIP); + + if ( ( linkStatus == 1 ) || ((uint32_t) localEthernetIP != 0) ) + #endif - if ( ( linkStatus == 1 ) && ((uint32_t) localEthernetIP != 0) ) #else // The linkStatus() is not working with W5100. Just using IP != 0.0.0.0 // Better to use ping for W5100 linkStatus = (int) Ethernet.linkStatus(); - ET_LOGINFO3("localEthernetIP = ", localEthernetIP, ", linkStatus = ", (linkStatus == LinkON) ? "LinkON" : "LinkOFF" ); - - if ( ( (linkStatus == LinkON) || !isW5500 ) && ((uint32_t) localEthernetIP != 0) ) + ETM_LOGINFO1("localEthernetIP = ", localEthernetIP); + + if ( ( (linkStatus == LinkON) || !isW5500 ) || ((uint32_t) localEthernetIP != 0) ) #endif { Serial.print(F("H")); @@ -143,6 +150,9 @@ void heartBeatPrint() if (num == 80) { Serial.println(); + + ethernet_manager.printMacAddress(); + num = 1; } else if (num++ % 10 == 0) @@ -173,8 +183,6 @@ void initEthernet() ET_LOGWARN(F("======== USE_NATIVE_ETHERNET ========")); #elif USE_ETHERNET_GENERIC ET_LOGWARN(F("=========== USE_ETHERNET_GENERIC ===========")); -#elif USE_ETHERNET_ESP8266 - ET_LOGWARN(F("=========== USE_ETHERNET_ESP8266 ===========")); #elif USE_ETHERNET_ENC ET_LOGWARN(F("=========== USE_ETHERNET_ENC ===========")); #else @@ -363,6 +371,19 @@ void setup() ethernet_manager.setCORSHeader("Your Access-Control-Allow-Origin"); #endif + ////////////////////////////////////////////// + +#define USING_CUSTOM_MAC_ADDRESS false + +#if USING_CUSTOM_MAC_ADDRESS + // To use your specified macAddress + byte newMacAddress[6] = { 0xFE, 0xED, 0xDE, 0xAD, 0xBE, 0xEF }; + + ethernet_manager.setMacAddress(newMacAddress); +#endif + + ////////////////////////////////////////////// + ethernet_manager.begin(); ////////////////////////////////////////////// diff --git a/examples/MQTT_ThingStream_Ethernet_Generic/defines.h b/examples/MQTT_ThingStream_Ethernet_Generic/defines.h index d569e0ae..83eae49a 100644 --- a/examples/MQTT_ThingStream_Ethernet_Generic/defines.h +++ b/examples/MQTT_ThingStream_Ethernet_Generic/defines.h @@ -22,7 +22,7 @@ // Debug Level from 0 to 4 #define _ETHERNET_WEBSERVER_LOGLEVEL_ 2 -#define _ETHERNET_MANAGER_LOGLEVEL_ 2 +#define _ETHERNET_MANAGER_LOGLEVEL_ 4 #define DRD_GENERIC_DEBUG true @@ -80,11 +80,27 @@ #if defined(ETHERNET_USE_SAMD) // For SAMD - // Default pin 10 to SS/CS - #define USE_THIS_SS_PIN 10 + // Default pin SS/CS,if no SS pin, use pin 10 + #if defined(PIN_SPI_MOSI) + //#warning Using SS pin + #define USE_THIS_SS_PIN 10 //SS + #else + #define USE_THIS_SS_PIN 10 + #endif #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) #define BOARD_TYPE "SAMD Zero" + + // Default to use W5100. Must change to false for W5500, W5100S, for faster SPI clock + // Must use true for SAMD21, such as Zero, SAMD_FEATHER_M0_EXPRESS, etc. + #define USE_W5100 true + + // Use this for ARDUINO_SAMD_ZERO, etc. if can't print to terminal with Serial.print + #if defined(SERIAL_PORT_USBVIRTUAL) + #define Serial SERIAL_PORT_USBVIRTUAL + #warning Using SAMD Zero SerialUSB + #endif + #elif defined(ARDUINO_SAMD_MKR1000) #define BOARD_TYPE "SAMD MKR1000" #elif defined(ARDUINO_SAMD_MKRWIFI1010) @@ -226,6 +242,7 @@ #endif #elif ( defined(CORE_TEENSY) ) + #error Teensy not supported // Default pin 10 to SS/CS #define USE_THIS_SS_PIN 10 @@ -335,8 +352,6 @@ //#define USE_UIP_ETHERNET true #define USE_UIP_ETHERNET false -// Note: To rename ESP628266 Ethernet lib files to Ethernet_ESP8266.h and Ethernet_ESP8266.cpp -// In order to USE_ETHERNET_ESP8266 #if ( !defined(USE_UIP_ETHERNET) || !USE_UIP_ETHERNET ) // To override the default CS/SS pin. Don't use unless you know exactly which pin to use @@ -346,11 +361,10 @@ // Only one if the following to be true #define USE_ETHERNET_GENERIC true - #define USE_ETHERNET_ESP8266 false #define USE_ETHERNET_ENC false #define USE_CUSTOM_ETHERNET false - #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ESP8266 || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET ) + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET ) #ifdef USE_CUSTOM_ETHERNET #undef USE_CUSTOM_ETHERNET #endif @@ -375,11 +389,6 @@ #include "Ethernet_Generic.h" #warning Using Ethernet_Generic lib - - #elif USE_ETHERNET_ESP8266 - #include "Ethernet_ESP8266.h" - #warning Using Ethernet_ESP8266 lib - #define SHIELD_TYPE "W5x00 using Ethernet_ESP8266 Library" #elif USE_ETHERNET_ENC #include "EthernetENC.h" diff --git a/examples/MQTT_ThingStream_Ethernet_RP2040/MQTT_ThingStream_Ethernet_RP2040.ino b/examples/MQTT_ThingStream_Ethernet_RP2040/MQTT_ThingStream_Ethernet_RP2040.ino index 785c2c53..9796319e 100644 --- a/examples/MQTT_ThingStream_Ethernet_RP2040/MQTT_ThingStream_Ethernet_RP2040.ino +++ b/examples/MQTT_ThingStream_Ethernet_RP2040/MQTT_ThingStream_Ethernet_RP2040.ino @@ -121,20 +121,26 @@ void heartBeatPrint() localEthernetIP = Ethernet.localIP(); -#if ( (USE_ETHERNET2 || USE_ETHERNET3) && !(USE_NATIVE_ETHERNET) ) - // To modify Ethernet2 library +#if (USE_ETHERNET_GENERIC) + + #if USE_W5100 + // The linkStatus() is not working with W5100. Just using IP != 0.0.0.0 + if ( (uint32_t) localEthernetIP != 0 ) + #else linkStatus = Ethernet.link(); - ET_LOGINFO3("localEthernetIP = ", localEthernetIP, ", linkStatus = ", (linkStatus == 1) ? "LinkON" : "LinkOFF" ); + ETM_LOGINFO1("localEthernetIP = ", localEthernetIP); + + if ( ( linkStatus == 1 ) || ((uint32_t) localEthernetIP != 0) ) + #endif - if ( ( linkStatus == 1 ) && ((uint32_t) localEthernetIP != 0) ) #else // The linkStatus() is not working with W5100. Just using IP != 0.0.0.0 // Better to use ping for W5100 linkStatus = (int) Ethernet.linkStatus(); - ET_LOGINFO3("localEthernetIP = ", localEthernetIP, ", linkStatus = ", (linkStatus == LinkON) ? "LinkON" : "LinkOFF" ); - - if ( ( (linkStatus == LinkON) || !isW5500 ) && ((uint32_t) localEthernetIP != 0) ) + ETM_LOGINFO1("localEthernetIP = ", localEthernetIP); + + if ( ( (linkStatus == LinkON) || !isW5500 ) || ((uint32_t) localEthernetIP != 0) ) #endif { Serial.print(F("H")); @@ -145,6 +151,9 @@ void heartBeatPrint() if (num == 80) { Serial.println(); + + ethernet_manager.printMacAddress(); + num = 1; } else if (num++ % 10 == 0) @@ -175,8 +184,6 @@ void initEthernet() ET_LOGWARN(F("======== USE_NATIVE_ETHERNET ========")); #elif USE_ETHERNET_GENERIC ET_LOGWARN(F("=========== USE_ETHERNET_GENERIC ===========")); -#elif USE_ETHERNET_ESP8266 - ET_LOGWARN(F("=========== USE_ETHERNET_ESP8266 ===========")); #elif USE_ETHERNET_ENC ET_LOGWARN(F("=========== USE_ETHERNET_ENC ===========")); #else @@ -353,6 +360,19 @@ void setup() ethernet_manager.setCORSHeader("Your Access-Control-Allow-Origin"); #endif + ////////////////////////////////////////////// + +#define USING_CUSTOM_MAC_ADDRESS false + +#if USING_CUSTOM_MAC_ADDRESS + // To use your specified macAddress + byte newMacAddress[6] = { 0xFE, 0xED, 0xDE, 0xAD, 0xBE, 0xEF }; + + ethernet_manager.setMacAddress(newMacAddress); +#endif + + ////////////////////////////////////////////// + ethernet_manager.begin(); ////////////////////////////////////////////// diff --git a/examples/MQTT_ThingStream_Ethernet_RP2040/defines.h b/examples/MQTT_ThingStream_Ethernet_RP2040/defines.h index d569e0ae..884ac8d3 100644 --- a/examples/MQTT_ThingStream_Ethernet_RP2040/defines.h +++ b/examples/MQTT_ThingStream_Ethernet_RP2040/defines.h @@ -80,11 +80,27 @@ #if defined(ETHERNET_USE_SAMD) // For SAMD - // Default pin 10 to SS/CS - #define USE_THIS_SS_PIN 10 + // Default pin SS/CS,if no SS pin, use pin 10 + #if defined(PIN_SPI_MOSI) + //#warning Using SS pin + #define USE_THIS_SS_PIN 10 //SS + #else + #define USE_THIS_SS_PIN 10 + #endif #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) #define BOARD_TYPE "SAMD Zero" + + // Default to use W5100. Must change to false for W5500, W5100S, for faster SPI clock + // Must use true for SAMD21, such as Zero, SAMD_FEATHER_M0_EXPRESS, etc. + #define USE_W5100 true + + // Use this for ARDUINO_SAMD_ZERO, etc. if can't print to terminal with Serial.print + #if defined(SERIAL_PORT_USBVIRTUAL) + #define Serial SERIAL_PORT_USBVIRTUAL + #warning Using SAMD Zero SerialUSB + #endif + #elif defined(ARDUINO_SAMD_MKR1000) #define BOARD_TYPE "SAMD MKR1000" #elif defined(ARDUINO_SAMD_MKRWIFI1010) @@ -226,6 +242,7 @@ #endif #elif ( defined(CORE_TEENSY) ) + #error Teensy not supported // Default pin 10 to SS/CS #define USE_THIS_SS_PIN 10 @@ -335,8 +352,6 @@ //#define USE_UIP_ETHERNET true #define USE_UIP_ETHERNET false -// Note: To rename ESP628266 Ethernet lib files to Ethernet_ESP8266.h and Ethernet_ESP8266.cpp -// In order to USE_ETHERNET_ESP8266 #if ( !defined(USE_UIP_ETHERNET) || !USE_UIP_ETHERNET ) // To override the default CS/SS pin. Don't use unless you know exactly which pin to use @@ -346,11 +361,10 @@ // Only one if the following to be true #define USE_ETHERNET_GENERIC true - #define USE_ETHERNET_ESP8266 false #define USE_ETHERNET_ENC false #define USE_CUSTOM_ETHERNET false - #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ESP8266 || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET ) + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET ) #ifdef USE_CUSTOM_ETHERNET #undef USE_CUSTOM_ETHERNET #endif @@ -375,12 +389,7 @@ #include "Ethernet_Generic.h" #warning Using Ethernet_Generic lib - - #elif USE_ETHERNET_ESP8266 - #include "Ethernet_ESP8266.h" - #warning Using Ethernet_ESP8266 lib - #define SHIELD_TYPE "W5x00 using Ethernet_ESP8266 Library" - + #elif USE_ETHERNET_ENC #include "EthernetENC.h" #warning Using EthernetENC lib diff --git a/examples/MQTT_ThingStream_Ethernet_SAMD/MQTT_ThingStream_Ethernet_SAMD.ino b/examples/MQTT_ThingStream_Ethernet_SAMD/MQTT_ThingStream_Ethernet_SAMD.ino index 55d20181..a24091bc 100644 --- a/examples/MQTT_ThingStream_Ethernet_SAMD/MQTT_ThingStream_Ethernet_SAMD.ino +++ b/examples/MQTT_ThingStream_Ethernet_SAMD/MQTT_ThingStream_Ethernet_SAMD.ino @@ -122,18 +122,25 @@ void heartBeatPrint() localEthernetIP = Ethernet.localIP(); #if (USE_ETHERNET_GENERIC) + + #if USE_W5100 + // The linkStatus() is not working with W5100. Just using IP != 0.0.0.0 + if ( (uint32_t) localEthernetIP != 0 ) + #else linkStatus = Ethernet.link(); - ET_LOGINFO3("localEthernetIP = ", localEthernetIP, ", linkStatus = ", (linkStatus == 1) ? "LinkON" : "LinkOFF" ); + ETM_LOGINFO1("localEthernetIP = ", localEthernetIP); + + if ( ( linkStatus == 1 ) || ((uint32_t) localEthernetIP != 0) ) + #endif - if ( ( linkStatus == 1 ) && ((uint32_t) localEthernetIP != 0) ) #else // The linkStatus() is not working with W5100. Just using IP != 0.0.0.0 // Better to use ping for W5100 linkStatus = (int) Ethernet.linkStatus(); - ET_LOGINFO3("localEthernetIP = ", localEthernetIP, ", linkStatus = ", (linkStatus == LinkON) ? "LinkON" : "LinkOFF" ); - - if ( ( (linkStatus == LinkON) || !isW5500 ) && ((uint32_t) localEthernetIP != 0) ) + ETM_LOGINFO1("localEthernetIP = ", localEthernetIP); + + if ( ( (linkStatus == LinkON) || !isW5500 ) || ((uint32_t) localEthernetIP != 0) ) #endif { Serial.print(F("H")); @@ -144,6 +151,9 @@ void heartBeatPrint() if (num == 80) { Serial.println(); + + ethernet_manager.printMacAddress(); + num = 1; } else if (num++ % 10 == 0) @@ -174,8 +184,6 @@ void initEthernet() ET_LOGWARN(F("======== USE_NATIVE_ETHERNET ========")); #elif USE_ETHERNET_GENERIC ET_LOGWARN(F("=========== USE_ETHERNET_GENERIC ===========")); -#elif USE_ETHERNET_ESP8266 - ET_LOGWARN(F("=========== USE_ETHERNET_ESP8266 ===========")); #elif USE_ETHERNET_ENC ET_LOGWARN(F("=========== USE_ETHERNET_ENC ===========")); #else @@ -352,6 +360,19 @@ void setup() ethernet_manager.setCORSHeader("Your Access-Control-Allow-Origin"); #endif + ////////////////////////////////////////////// + +#define USING_CUSTOM_MAC_ADDRESS false + +#if USING_CUSTOM_MAC_ADDRESS + // To use your specified macAddress + byte newMacAddress[6] = { 0xFE, 0xED, 0xDE, 0xAD, 0xBE, 0xEF }; + + ethernet_manager.setMacAddress(newMacAddress); +#endif + + ////////////////////////////////////////////// + ethernet_manager.begin(); ////////////////////////////////////////////// diff --git a/examples/MQTT_ThingStream_Ethernet_SAMD/defines.h b/examples/MQTT_ThingStream_Ethernet_SAMD/defines.h index d569e0ae..884ac8d3 100644 --- a/examples/MQTT_ThingStream_Ethernet_SAMD/defines.h +++ b/examples/MQTT_ThingStream_Ethernet_SAMD/defines.h @@ -80,11 +80,27 @@ #if defined(ETHERNET_USE_SAMD) // For SAMD - // Default pin 10 to SS/CS - #define USE_THIS_SS_PIN 10 + // Default pin SS/CS,if no SS pin, use pin 10 + #if defined(PIN_SPI_MOSI) + //#warning Using SS pin + #define USE_THIS_SS_PIN 10 //SS + #else + #define USE_THIS_SS_PIN 10 + #endif #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) #define BOARD_TYPE "SAMD Zero" + + // Default to use W5100. Must change to false for W5500, W5100S, for faster SPI clock + // Must use true for SAMD21, such as Zero, SAMD_FEATHER_M0_EXPRESS, etc. + #define USE_W5100 true + + // Use this for ARDUINO_SAMD_ZERO, etc. if can't print to terminal with Serial.print + #if defined(SERIAL_PORT_USBVIRTUAL) + #define Serial SERIAL_PORT_USBVIRTUAL + #warning Using SAMD Zero SerialUSB + #endif + #elif defined(ARDUINO_SAMD_MKR1000) #define BOARD_TYPE "SAMD MKR1000" #elif defined(ARDUINO_SAMD_MKRWIFI1010) @@ -226,6 +242,7 @@ #endif #elif ( defined(CORE_TEENSY) ) + #error Teensy not supported // Default pin 10 to SS/CS #define USE_THIS_SS_PIN 10 @@ -335,8 +352,6 @@ //#define USE_UIP_ETHERNET true #define USE_UIP_ETHERNET false -// Note: To rename ESP628266 Ethernet lib files to Ethernet_ESP8266.h and Ethernet_ESP8266.cpp -// In order to USE_ETHERNET_ESP8266 #if ( !defined(USE_UIP_ETHERNET) || !USE_UIP_ETHERNET ) // To override the default CS/SS pin. Don't use unless you know exactly which pin to use @@ -346,11 +361,10 @@ // Only one if the following to be true #define USE_ETHERNET_GENERIC true - #define USE_ETHERNET_ESP8266 false #define USE_ETHERNET_ENC false #define USE_CUSTOM_ETHERNET false - #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ESP8266 || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET ) + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET ) #ifdef USE_CUSTOM_ETHERNET #undef USE_CUSTOM_ETHERNET #endif @@ -375,12 +389,7 @@ #include "Ethernet_Generic.h" #warning Using Ethernet_Generic lib - - #elif USE_ETHERNET_ESP8266 - #include "Ethernet_ESP8266.h" - #warning Using Ethernet_ESP8266 lib - #define SHIELD_TYPE "W5x00 using Ethernet_ESP8266 Library" - + #elif USE_ETHERNET_ENC #include "EthernetENC.h" #warning Using EthernetENC lib diff --git a/examples/MQTT_ThingStream_Ethernet_SAM_DUE/MQTT_ThingStream_Ethernet_SAM_DUE.ino b/examples/MQTT_ThingStream_Ethernet_SAM_DUE/MQTT_ThingStream_Ethernet_SAM_DUE.ino index c0ae185f..5d7b1a5f 100644 --- a/examples/MQTT_ThingStream_Ethernet_SAM_DUE/MQTT_ThingStream_Ethernet_SAM_DUE.ino +++ b/examples/MQTT_ThingStream_Ethernet_SAM_DUE/MQTT_ThingStream_Ethernet_SAM_DUE.ino @@ -122,18 +122,25 @@ void heartBeatPrint() localEthernetIP = Ethernet.localIP(); #if (USE_ETHERNET_GENERIC) + + #if USE_W5100 + // The linkStatus() is not working with W5100. Just using IP != 0.0.0.0 + if ( (uint32_t) localEthernetIP != 0 ) + #else linkStatus = Ethernet.link(); - ET_LOGINFO3("localEthernetIP = ", localEthernetIP, ", linkStatus = ", (linkStatus == 1) ? "LinkON" : "LinkOFF" ); + ETM_LOGINFO1("localEthernetIP = ", localEthernetIP); + + if ( ( linkStatus == 1 ) || ((uint32_t) localEthernetIP != 0) ) + #endif - if ( ( linkStatus == 1 ) && ((uint32_t) localEthernetIP != 0) ) #else // The linkStatus() is not working with W5100. Just using IP != 0.0.0.0 // Better to use ping for W5100 linkStatus = (int) Ethernet.linkStatus(); - ET_LOGINFO3("localEthernetIP = ", localEthernetIP, ", linkStatus = ", (linkStatus == LinkON) ? "LinkON" : "LinkOFF" ); - - if ( ( (linkStatus == LinkON) || !isW5500 ) && ((uint32_t) localEthernetIP != 0) ) + ETM_LOGINFO1("localEthernetIP = ", localEthernetIP); + + if ( ( (linkStatus == LinkON) || !isW5500 ) || ((uint32_t) localEthernetIP != 0) ) #endif { Serial.print(F("H")); @@ -144,6 +151,9 @@ void heartBeatPrint() if (num == 80) { Serial.println(); + + ethernet_manager.printMacAddress(); + num = 1; } else if (num++ % 10 == 0) @@ -174,8 +184,6 @@ void initEthernet() ET_LOGWARN(F("======== USE_NATIVE_ETHERNET ========")); #elif USE_ETHERNET_GENERIC ET_LOGWARN(F("=========== USE_ETHERNET_GENERIC ===========")); -#elif USE_ETHERNET_ESP8266 - ET_LOGWARN(F("=========== USE_ETHERNET_ESP8266 ===========")); #elif USE_ETHERNET_ENC ET_LOGWARN(F("=========== USE_ETHERNET_ENC ===========")); #else @@ -352,6 +360,19 @@ void setup() ethernet_manager.setCORSHeader("Your Access-Control-Allow-Origin"); #endif + ////////////////////////////////////////////// + +#define USING_CUSTOM_MAC_ADDRESS false + +#if USING_CUSTOM_MAC_ADDRESS + // To use your specified macAddress + byte newMacAddress[6] = { 0xFE, 0xED, 0xDE, 0xAD, 0xBE, 0xEF }; + + ethernet_manager.setMacAddress(newMacAddress); +#endif + + ////////////////////////////////////////////// + ethernet_manager.begin(); ////////////////////////////////////////////// diff --git a/examples/MQTT_ThingStream_Ethernet_SAM_DUE/defines.h b/examples/MQTT_ThingStream_Ethernet_SAM_DUE/defines.h index d569e0ae..6d4eeaf3 100644 --- a/examples/MQTT_ThingStream_Ethernet_SAM_DUE/defines.h +++ b/examples/MQTT_ThingStream_Ethernet_SAM_DUE/defines.h @@ -80,11 +80,27 @@ #if defined(ETHERNET_USE_SAMD) // For SAMD - // Default pin 10 to SS/CS - #define USE_THIS_SS_PIN 10 + // Default pin SS/CS,if no SS pin, use pin 10 + #if defined(PIN_SPI_MOSI) + //#warning Using SS pin + #define USE_THIS_SS_PIN 10 //SS + #else + #define USE_THIS_SS_PIN 10 + #endif #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) #define BOARD_TYPE "SAMD Zero" + + // Default to use W5100. Must change to false for W5500, W5100S, for faster SPI clock + // Must use true for SAMD21, such as Zero, SAMD_FEATHER_M0_EXPRESS, etc. + #define USE_W5100 true + + // Use this for ARDUINO_SAMD_ZERO, etc. if can't print to terminal with Serial.print + #if defined(SERIAL_PORT_USBVIRTUAL) + #define Serial SERIAL_PORT_USBVIRTUAL + #warning Using SAMD Zero SerialUSB + #endif + #elif defined(ARDUINO_SAMD_MKR1000) #define BOARD_TYPE "SAMD MKR1000" #elif defined(ARDUINO_SAMD_MKRWIFI1010) @@ -226,6 +242,7 @@ #endif #elif ( defined(CORE_TEENSY) ) + #error Teensy not supported // Default pin 10 to SS/CS #define USE_THIS_SS_PIN 10 @@ -335,8 +352,6 @@ //#define USE_UIP_ETHERNET true #define USE_UIP_ETHERNET false -// Note: To rename ESP628266 Ethernet lib files to Ethernet_ESP8266.h and Ethernet_ESP8266.cpp -// In order to USE_ETHERNET_ESP8266 #if ( !defined(USE_UIP_ETHERNET) || !USE_UIP_ETHERNET ) // To override the default CS/SS pin. Don't use unless you know exactly which pin to use @@ -346,11 +361,10 @@ // Only one if the following to be true #define USE_ETHERNET_GENERIC true - #define USE_ETHERNET_ESP8266 false #define USE_ETHERNET_ENC false #define USE_CUSTOM_ETHERNET false - #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ESP8266 || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET ) + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET ) #ifdef USE_CUSTOM_ETHERNET #undef USE_CUSTOM_ETHERNET #endif @@ -376,11 +390,6 @@ #include "Ethernet_Generic.h" #warning Using Ethernet_Generic lib - #elif USE_ETHERNET_ESP8266 - #include "Ethernet_ESP8266.h" - #warning Using Ethernet_ESP8266 lib - #define SHIELD_TYPE "W5x00 using Ethernet_ESP8266 Library" - #elif USE_ETHERNET_ENC #include "EthernetENC.h" #warning Using EthernetENC lib diff --git a/examples/MQTT_ThingStream_Ethernet_Teensy/MQTT_ThingStream_Ethernet_Teensy.ino b/examples/MQTT_ThingStream_Ethernet_Teensy/MQTT_ThingStream_Ethernet_Teensy.ino index a2d93846..a2709074 100644 --- a/examples/MQTT_ThingStream_Ethernet_Teensy/MQTT_ThingStream_Ethernet_Teensy.ino +++ b/examples/MQTT_ThingStream_Ethernet_Teensy/MQTT_ThingStream_Ethernet_Teensy.ino @@ -122,18 +122,25 @@ void heartBeatPrint() localEthernetIP = Ethernet.localIP(); #if (USE_ETHERNET_GENERIC) + + #if USE_W5100 + // The linkStatus() is not working with W5100. Just using IP != 0.0.0.0 + if ( (uint32_t) localEthernetIP != 0 ) + #else linkStatus = Ethernet.link(); - ET_LOGINFO3("localEthernetIP = ", localEthernetIP, ", linkStatus = ", (linkStatus == 1) ? "LinkON" : "LinkOFF" ); + ETM_LOGINFO1("localEthernetIP = ", localEthernetIP); + + if ( ( linkStatus == 1 ) || ((uint32_t) localEthernetIP != 0) ) + #endif - if ( ( linkStatus == 1 ) && ((uint32_t) localEthernetIP != 0) ) #else // The linkStatus() is not working with W5100. Just using IP != 0.0.0.0 // Better to use ping for W5100 linkStatus = (int) Ethernet.linkStatus(); - ET_LOGINFO3("localEthernetIP = ", localEthernetIP, ", linkStatus = ", (linkStatus == LinkON) ? "LinkON" : "LinkOFF" ); - - if ( ( (linkStatus == LinkON) || !isW5500 ) && ((uint32_t) localEthernetIP != 0) ) + ETM_LOGINFO1("localEthernetIP = ", localEthernetIP); + + if ( ( (linkStatus == LinkON) || !isW5500 ) || ((uint32_t) localEthernetIP != 0) ) #endif { Serial.print(F("H")); @@ -144,6 +151,9 @@ void heartBeatPrint() if (num == 80) { Serial.println(); + + ethernet_manager.printMacAddress(); + num = 1; } else if (num++ % 10 == 0) @@ -174,8 +184,6 @@ void initEthernet() ET_LOGWARN(F("======== USE_NATIVE_ETHERNET ========")); #elif USE_ETHERNET_GENERIC ET_LOGWARN(F("=========== USE_ETHERNET_GENERIC ===========")); -#elif USE_ETHERNET_ESP8266 - ET_LOGWARN(F("=========== USE_ETHERNET_ESP8266 ===========")); #elif USE_ETHERNET_ENC ET_LOGWARN(F("=========== USE_ETHERNET_ENC ===========")); #else diff --git a/examples/MQTT_ThingStream_Ethernet_Teensy/defines.h b/examples/MQTT_ThingStream_Ethernet_Teensy/defines.h index 0ac6ed2c..56cad852 100644 --- a/examples/MQTT_ThingStream_Ethernet_Teensy/defines.h +++ b/examples/MQTT_ThingStream_Ethernet_Teensy/defines.h @@ -57,7 +57,6 @@ #define USE_UIP_ETHERNET false #define USE_ETHERNET_GENERIC false -#define USE_ETHERNET_ESP8266 false #define USE_ETHERNET_ENC false #define USE_CUSTOM_ETHERNET false diff --git a/examples/MQTT_ThingStream_Ethernet_WT32_ETH01/MQTT_ThingStream_Ethernet_WT32_ETH01.ino b/examples/MQTT_ThingStream_Ethernet_WT32_ETH01/MQTT_ThingStream_Ethernet_WT32_ETH01.ino index 9b459979..bcb09f59 100644 --- a/examples/MQTT_ThingStream_Ethernet_WT32_ETH01/MQTT_ThingStream_Ethernet_WT32_ETH01.ino +++ b/examples/MQTT_ThingStream_Ethernet_WT32_ETH01/MQTT_ThingStream_Ethernet_WT32_ETH01.ino @@ -170,7 +170,7 @@ void WiFiEvent(WiFiEvent_t event) break; case SYSTEM_EVENT_ETH_GOT_IP: - if (!ethernet_manager.ethernetConnected) + if (!ethernet_manager.isEthernetConnected()) { ETM_LOGERROR3(F("ETH MAC:"), ETH.macAddress(), F(", IPv4:"), ETH.localIP()); @@ -183,19 +183,19 @@ void WiFiEvent(WiFiEvent_t event) ETM_LOGERROR1(F("HALF_DUPLEX, Link Speed (Mbps)"), ETH.linkSpeed()); } - ethernet_manager.ethernetConnected = true; + ethernet_manager.setEthernetConnected(); } break; case SYSTEM_EVENT_ETH_DISCONNECTED: ETM_LOGERROR(F("ETH Disconnected")); - ethernet_manager.ethernetConnected = false; + ethernet_manager.setEthernetDisconnected(); break; case SYSTEM_EVENT_ETH_STOP: ETM_LOGERROR(F("\nETH Stopped")); - ethernet_manager.ethernetConnected = false; + ethernet_manager.setEthernetDisconnected(); break; default: @@ -207,10 +207,10 @@ void setup() { // Debug console Serial.begin(115200); - while (!Serial); + //while (!Serial); // Using this if Serial debugging is not necessary or not using Serial port - //while (!Serial && (millis() < 3000)); + while (!Serial && (millis() < 5000)); Serial.print("\nStart MQTT_ThingStream_Ethernet_WT32_ETH01 on "); Serial.println(BOARD_NAME); Serial.print("Ethernet Shield type : "); Serial.println(SHIELD_TYPE); diff --git a/examples/MQTT_ThingStream_Ethernet_WT32_ETH01/defines.h b/examples/MQTT_ThingStream_Ethernet_WT32_ETH01/defines.h index f7553f2c..44a14831 100644 --- a/examples/MQTT_ThingStream_Ethernet_WT32_ETH01/defines.h +++ b/examples/MQTT_ThingStream_Ethernet_WT32_ETH01/defines.h @@ -13,407 +13,12 @@ #ifndef defines_h #define defines_h -#if ( defined(ARDUINO_AVR_ADK) || defined(ARDUINO_AVR_MEGA) || defined(ARDUINO_AVR_MEGA2560) ) - #error This code is designed to run on SAMD, SAM-DUE, Teensy platform, ESP8266, ESP32 not AVR Mega! Please check your Tools->Board setting. -#endif - -/* Comment this out to disable prints and save space */ -#define DEBUG_ETHERNET_WEBSERVER_PORT Serial - // Debug Level from 0 to 4 -#define _ETHERNET_WEBSERVER_LOGLEVEL_ 0 -#define _ETHERNET_MANAGER_LOGLEVEL_ 2 - -#define DRD_GENERIC_DEBUG true - -// For ESP32/ESP8266 -#define DOUBLERESETDETECTOR_DEBUG true - -#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \ - || defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \ - || defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \ - || defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \ - || defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) ) - #if defined(ETHERNET_USE_SAMD) - #undef ETHERNET_USE_SAMD - #endif - #define ETHERNET_USE_SAMD true - #define USE_DYNAMIC_PARAMETERS true -#endif - -#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \ - defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \ - defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) ) - #if defined(ETHERNET_USE_NRF52) - #undef ETHERNET_USE_NRF528XX - #endif - #define ETHERNET_USE_NRF528XX true - #define USE_DYNAMIC_PARAMETERS true -#endif - -#if ( defined(NANO_RP2040_CONNECT) || defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ - defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) - // For RPI Pico - #if defined(ETHERNET_USE_RPIPICO) - #undef ETHERNET_USE_RPIPICO - #endif - #define ETHERNET_USE_RPIPICO true - #define USE_DYNAMIC_PARAMETERS true -#endif - -#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) ) - #if defined(ETHERNET_USE_SAM_DUE) - #undef ETHERNET_USE_SAM_DUE - #endif - #define ETHERNET_USE_SAM_DUE true - #define USE_DYNAMIC_PARAMETERS true -#endif - -#if ( defined(CORE_TEENSY) && !( defined(__MKL26Z64__) || defined(__AVR_AT90USB1286__) || defined(__AVR_ATmega32U4__) ) ) - // Don't support Teensy 2.x, LC - #if defined(ETHERNET_USE_TEENSY) - #undef ETHERNET_USE_TEENSY - #endif - #define ETHERNET_USE_TEENSY true - #define USE_DYNAMIC_PARAMETERS true -#endif - -#if defined(ETHERNET_USE_SAMD) - // For SAMD - // Default pin 10 to SS/CS - #define USE_THIS_SS_PIN 10 - - #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) - #define BOARD_TYPE "SAMD Zero" - #elif defined(ARDUINO_SAMD_MKR1000) - #define BOARD_TYPE "SAMD MKR1000" - #elif defined(ARDUINO_SAMD_MKRWIFI1010) - #define BOARD_TYPE "SAMD MKRWIFI1010" - #elif defined(ARDUINO_SAMD_NANO_33_IOT) - #define BOARD_TYPE "SAMD NANO_33_IOT" - #elif defined(ARDUINO_SAMD_MKRFox1200) - #define BOARD_TYPE "SAMD MKRFox1200" - #elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) ) - #define BOARD_TYPE "SAMD MKRWAN13X0" - #elif defined(ARDUINO_SAMD_MKRGSM1400) - #define BOARD_TYPE "SAMD MKRGSM1400" - #elif defined(ARDUINO_SAMD_MKRNB1500) - #define BOARD_TYPE "SAMD MKRNB1500" - #elif defined(ARDUINO_SAMD_MKRVIDOR4000) - #define BOARD_TYPE "SAMD MKRVIDOR4000" - #elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) - #define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS" - #elif defined(ADAFRUIT_FEATHER_M0_EXPRESS) - #define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS" - #elif defined(ADAFRUIT_METRO_M0_EXPRESS) - #define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS" - #elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0) - #define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0" - #elif defined(ADAFRUIT_GEMMA_M0) - #define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0" - #elif defined(ADAFRUIT_TRINKET_M0) - #define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0" - #elif defined(ADAFRUIT_ITSYBITSY_M0) - #define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0" - #elif defined(ARDUINO_SAMD_HALLOWING_M0) - #define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0" - #elif defined(ADAFRUIT_METRO_M4_EXPRESS) - #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS" - #elif defined(ADAFRUIT_GRAND_CENTRAL_M4) - #define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4" - #elif defined(ADAFRUIT_FEATHER_M4_EXPRESS) - #define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS" - #elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS) - #define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS" - #define USE_THIS_SS_PIN 10 - #elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS) - #define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS" - #elif defined(ADAFRUIT_PYPORTAL) - #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL" - #elif defined(ADAFRUIT_PYPORTAL_M4_TITANO) - #define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO" - #elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS) - #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS" - #elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE) - #define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE" - #elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS) - #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS" - #elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS) - #define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS" - #elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4) - #define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4" - #elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS) - #define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS" - #elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS) - #define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS" - #elif defined(SEEED_WIO_TERMINAL) - #define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL" - #elif defined(SEEED_FEMTO_M0) - #define BOARD_TYPE "SAMD SEEED_FEMTO_M0" - #elif defined(SEEED_XIAO_M0) - #define BOARD_TYPE "SAMD SEEED_XIAO_M0" - #ifdef USE_THIS_SS_PIN - #undef USE_THIS_SS_PIN - #endif - #define USE_THIS_SS_PIN A1 - #warning define SEEED_XIAO_M0 USE_THIS_SS_PIN == A1 - #elif defined(Wio_Lite_MG126) - #define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126" - #elif defined(WIO_GPS_BOARD) - #define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD" - #elif defined(SEEEDUINO_ZERO) - #define BOARD_TYPE "SAMD SEEEDUINO_ZERO" - #elif defined(SEEEDUINO_LORAWAN) - #define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN" - #elif defined(SEEED_GROVE_UI_WIRELESS) - #define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS" - #elif defined(__SAMD21E18A__) - #define BOARD_TYPE "SAMD21E18A" - #elif defined(__SAMD21G18A__) - #define BOARD_TYPE "SAMD21G18A" - #elif defined(__SAMD51G19A__) - #define BOARD_TYPE "SAMD51G19A" - #elif defined(__SAMD51J19A__) - #define BOARD_TYPE "SAMD51J19A" - #elif defined(__SAMD51J20A__) - #define BOARD_TYPE "SAMD51J20A" - #elif defined(__SAM3X8E__) - #define BOARD_TYPE "SAM3X8E" - #elif defined(__CPU_ARC__) - #define BOARD_TYPE "CPU_ARC" - #elif defined(__SAMD51__) - #define BOARD_TYPE "SAMD51" - #else - #define BOARD_TYPE "SAMD Unknown" - #endif +#define _ETHERNET_WEBSERVER_LOGLEVEL_ 3 -#elif (ETHERNET_USE_SAM_DUE) - // Default pin 10 to SS/CS - #define USE_THIS_SS_PIN 10 - #define BOARD_TYPE "SAM DUE" +#define ETHERNET_USE_WT32_ETH01 true -#elif (ETHERNET_USE_NRF528XX) - // Default pin 10 to SS/CS - #define USE_THIS_SS_PIN 10 - - #if defined(NRF52840_FEATHER) - #define BOARD_TYPE "NRF52840_FEATHER" - #elif defined(NRF52832_FEATHER) - #define BOARD_TYPE "NRF52832_FEATHER" - #elif defined(NRF52840_FEATHER_SENSE) - #define BOARD_TYPE "NRF52840_FEATHER_SENSE" - #elif defined(NRF52840_ITSYBITSY) - #define BOARD_TYPE "NRF52840_ITSYBITSY" - #define USE_THIS_SS_PIN 10 // For other boards - #elif defined(NRF52840_CIRCUITPLAY) - #define BOARD_TYPE "NRF52840_CIRCUITPLAY" - #elif defined(NRF52840_CLUE) - #define BOARD_TYPE "NRF52840_CLUE" - #elif defined(NRF52840_METRO) - #define BOARD_TYPE "NRF52840_METRO" - #elif defined(NRF52840_PCA10056) - #define BOARD_TYPE "NRF52840_PCA10056" - #elif defined(NINA_B302_ublox) - #define BOARD_TYPE "NINA_B302_ublox" - #elif defined(NINA_B112_ublox) - #define BOARD_TYPE "NINA_B112_ublox" - #elif defined(PARTICLE_XENON) - #define BOARD_TYPE "PARTICLE_XENON" - #elif defined(ARDUINO_NRF52_ADAFRUIT) - #define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT" - #else - #define BOARD_TYPE "nRF52 Unknown" - #endif - -#elif ( defined(CORE_TEENSY) ) - // Default pin 10 to SS/CS - #define USE_THIS_SS_PIN 10 - - #if defined(__IMXRT1062__) - // For Teensy 4.1/4.0 - #if defined(ARDUINO_TEENSY41) - #define BOARD_TYPE "TEENSY 4.1" - // Use true for NativeEthernet Library, false if using other Ethernet libraries - #define USE_NATIVE_ETHERNET true - #elif defined(ARDUINO_TEENSY40) - #define BOARD_TYPE "TEENSY 4.0" - #else - #define BOARD_TYPE "TEENSY 4.x" - #endif - #elif defined(__MK66FX1M0__) - #define BOARD_TYPE "Teensy 3.6" - #elif defined(__MK64FX512__) - #define BOARD_TYPE "Teensy 3.5" - #elif defined(__MKL26Z64__) - #define BOARD_TYPE "Teensy LC" - #elif defined(__MK20DX256__) - #define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete) - #elif defined(__MK20DX128__) - #define BOARD_TYPE "Teensy 3.0" - #elif defined(__AVR_AT90USB1286__) - #error Teensy 2.0++ not supported yet - #elif defined(__AVR_ATmega32U4__) - #error Teensy 2.0 not supported yet - #else - // For Other Boards - #define BOARD_TYPE "Unknown Teensy Board" - #endif - -#elif ( defined(ESP8266) ) - // For ESP8266 - #warning Use ESP8266 architecture - #include - #define ETHERNET_USE_ESP8266 - #define BOARD_TYPE ARDUINO_BOARD //"ESP8266" - -#elif ( defined(ESP32) ) - // For ESP32 - #warning Use ESP32 architecture - #define ETHERNET_USE_ESP32 - #define BOARD_TYPE ARDUINO_BOARD //"ESP32" - - #define W5500_RST_PORT 21 - -#elif (ETHERNET_USE_RP2040) - - // Default pin 5 (in Mbed) or 17 to SS/CS - #if defined(ARDUINO_ARCH_MBED) - // For RPI Pico using Arduino Mbed RP2040 core - // SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5 - #define USE_THIS_SS_PIN 5 - - #if ( defined(NANO_RP2040_CONNECT) || defined(ARDUINO_RASPBERRY_PI_PICO) || \ - defined(ARDUINO_GENERIC_RP2040) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) ) - // Only undef known BOARD_NAME to use better one - #undef BOARD_NAME - #endif - - #if defined(ARDUINO_RASPBERRY_PI_PICO) - #define BOARD_NAME "MBED RASPBERRY_PI_PICO" - #elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) - #define BOARD_NAME "MBED ADAFRUIT_FEATHER_RP2040" - #elif defined(ARDUINO_GENERIC_RP2040) - #define BOARD_NAME "MBED GENERIC_RP2040" - #elif defined(NANO_RP2040_CONNECT) - #define BOARD_NAME "MBED NANO_RP2040_CONNECT" - #else - // Use default BOARD_NAME if exists - #if !defined(BOARD_NAME) - #define BOARD_NAME "MBED Unknown RP2040" - #endif - #endif - - #else - // For RPI Pico using E. Philhower RP2040 core - // SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17 - #define USE_THIS_SS_PIN 17 - - #endif - -#else - // For Mega - // Default pin 10 to SS/CS - #define USE_THIS_SS_PIN 10 - - // Reduce size for Mega - #define SENDCONTENT_P_BUFFER_SZ 512 - - #define BOARD_TYPE "AVR Mega" -#endif - -#ifndef BOARD_NAME - #define BOARD_NAME BOARD_TYPE -#endif - -#include - - -// Use true for ENC28J60 and UIPEthernet library (https://github.com/UIPEthernet/UIPEthernet) -// Use false for W5x00 and Ethernetx library (https://www.arduino.cc/en/Reference/Ethernet) - -//#define USE_UIP_ETHERNET true -#define USE_UIP_ETHERNET false - -// Note: To rename ESP628266 Ethernet lib files to Ethernet_ESP8266.h and Ethernet_ESP8266.cpp -// In order to USE_ETHERNET_ESP8266 -#if ( !defined(USE_UIP_ETHERNET) || !USE_UIP_ETHERNET ) - - // To override the default CS/SS pin. Don't use unless you know exactly which pin to use - // You can define here or customize for each board at same place with BOARD_TYPE - // Check @ defined(SEEED_XIAO_M0) - //#define USE_THIS_SS_PIN 22 //21 //5 //4 //2 //15 - - // Only one if the following to be true - #define USE_ETHERNET_GENERIC true - #define USE_ETHERNET_ESP8266 false - #define USE_ETHERNET_ENC false - #define USE_CUSTOM_ETHERNET false - - #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ESP8266 || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET ) - #ifdef USE_CUSTOM_ETHERNET - #undef USE_CUSTOM_ETHERNET - #endif - #define USE_CUSTOM_ETHERNET false - #endif - - #if USE_NATIVE_ETHERNET - #include "NativeEthernet.h" - #warning Using NativeEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error - #define SHIELD_TYPE "Custom Ethernet using Teensy 4.1 NativeEthernet Library" - #elif USE_ETHERNET_GENERIC - - #if USING_SPI2 - #define SHIELD_TYPE "W5x00 using Ethernet_Generic Library on SPI1" - #else - #define SHIELD_TYPE "W5x00 using Ethernet_Generic Library on SPI0/SPI" - #endif - - #define ETHERNET_LARGE_BUFFERS - - #define _ETG_LOGLEVEL_ 1 - - #include "Ethernet_Generic.h" - #warning Using Ethernet_Generic lib - - #elif USE_ETHERNET_ESP8266 - #include "Ethernet_ESP8266.h" - #warning Using Ethernet_ESP8266 lib - #define SHIELD_TYPE "W5x00 using Ethernet_ESP8266 Library" - - #elif USE_ETHERNET_ENC - #include "EthernetENC.h" - #warning Using EthernetENC lib - #define SHIELD_TYPE "ENC28J60 using EthernetENC Library" - - #elif USE_CUSTOM_ETHERNET - //#include "Ethernet_XYZ.h" - #include "EthernetENC.h" - #warning Using Custom Ethernet library. You must include a library and initialize. - #define SHIELD_TYPE "Custom Ethernet using Ethernet_XYZ Library" - - #else - #ifdef USE_ETHERNET_GENERIC - #undef USE_ETHERNET_GENERIC - #endif - #define USE_ETHERNET_GENERIC true - #include "Ethernet_Generic.h" - #warning Using default Ethernet_Generic lib - #define SHIELD_TYPE "W5x00 using default Ethernet_Generic Library" - #endif - - // Ethernet_Shield_W5200, EtherCard, EtherSia not supported - // Select just 1 of the following #include if uncomment #define USE_CUSTOM_ETHERNET - // Otherwise, standard Ethernet library will be used for W5x00 - -#elif USE_UIP_ETHERNET - #include "UIPEthernet.h" - #warning Using UIPEthernet library - #define SHIELD_TYPE "ENC28J60 using UIPEthernet Library" -#endif // #if !USE_UIP_ETHERNET - -#ifndef SHIELD_TYPE - #define SHIELD_TYPE "Unknown Ethernet shield/library" -#endif +#include ////////////////////////////////////////// @@ -426,52 +31,21 @@ // Config data Size currently is 128 bytes w/o chksum, 132 with chksum) //#define EEPROM_START 1024 -#if ( defined(ESP32) || defined(ESP8266) ) +// TODO, to add ESP32 LittleFS support +// For ESP32 +#define USE_LITTLEFS false +#define USE_SPIFFS false - #if defined(ESP8266) - - // #define USE_SPIFFS and USE_LITTLEFS false => using EEPROM for configuration data in WiFiManager - // #define USE_LITTLEFS true => using LITTLEFS for configuration data in WiFiManager - // #define USE_LITTLEFS false and USE_SPIFFS true => using SPIFFS for configuration data in WiFiManager - // Be sure to define USE_LITTLEFS and USE_SPIFFS before #include - // From ESP8266 core 2.7.1, SPIFFS will be deprecated and to be replaced by LittleFS - // Select USE_LITTLEFS (higher priority) or USE_SPIFFS - - #define USE_LITTLEFS false - #define USE_SPIFFS false - - #if USE_LITTLEFS - //LittleFS has higher priority - #define CurrentFileFS "LittleFS" - #ifdef USE_SPIFFS - #undef USE_SPIFFS - #endif - #define USE_SPIFFS false - #elif USE_SPIFFS - #define CurrentFileFS "SPIFFS" - #endif - - #else //#if defined(ESP8266) - // TODO, to add ESP32 LittleFS support - // For ESP32 - #define USE_LITTLEFS false - #define USE_SPIFFS false - - #if USE_LITTLEFS - //LittleFS has higher priority - #define CurrentFileFS "LittleFS" - #ifdef USE_SPIFFS - #undef USE_SPIFFS - #endif - #define USE_SPIFFS false - #elif USE_SPIFFS - #define CurrentFileFS "SPIFFS" - #endif - #endif //#if defined(ESP8266) - -#else //#if ( defined(ESP32) || defined(ESP8266) ) - #define USE_SPIFFS false -#endif //#if ( defined(ESP32) || defined(ESP8266) ) +#if USE_LITTLEFS + //LittleFS has higher priority + #define CurrentFileFS "LittleFS" + #ifdef USE_SPIFFS + #undef USE_SPIFFS + #endif + #define USE_SPIFFS false +#elif USE_SPIFFS + #define CurrentFileFS "SPIFFS" +#endif #if !( USE_LITTLEFS || USE_SPIFFS) @@ -504,9 +78,6 @@ #include -#define W5100_CS 10 -#define SDCARD_CS 4 - -#define ETHERNET_HOST_NAME "Generic-Ethernet" +#define ETHERNET_HOST_NAME "WT32_ETH01" #endif //defines_h diff --git a/examples/MQTT_ThingStream_Ethernet_nRF52/MQTT_ThingStream_Ethernet_nRF52.ino b/examples/MQTT_ThingStream_Ethernet_nRF52/MQTT_ThingStream_Ethernet_nRF52.ino index 974bbad9..4d13629f 100644 --- a/examples/MQTT_ThingStream_Ethernet_nRF52/MQTT_ThingStream_Ethernet_nRF52.ino +++ b/examples/MQTT_ThingStream_Ethernet_nRF52/MQTT_ThingStream_Ethernet_nRF52.ino @@ -122,18 +122,25 @@ void heartBeatPrint() localEthernetIP = Ethernet.localIP(); #if (USE_ETHERNET_GENERIC) + + #if USE_W5100 + // The linkStatus() is not working with W5100. Just using IP != 0.0.0.0 + if ( (uint32_t) localEthernetIP != 0 ) + #else linkStatus = Ethernet.link(); - ET_LOGINFO3("localEthernetIP = ", localEthernetIP, ", linkStatus = ", (linkStatus == 1) ? "LinkON" : "LinkOFF" ); + ETM_LOGINFO1("localEthernetIP = ", localEthernetIP); + + if ( ( linkStatus == 1 ) || ((uint32_t) localEthernetIP != 0) ) + #endif - if ( ( linkStatus == 1 ) && ((uint32_t) localEthernetIP != 0) ) #else // The linkStatus() is not working with W5100. Just using IP != 0.0.0.0 // Better to use ping for W5100 linkStatus = (int) Ethernet.linkStatus(); - ET_LOGINFO3("localEthernetIP = ", localEthernetIP, ", linkStatus = ", (linkStatus == LinkON) ? "LinkON" : "LinkOFF" ); - - if ( ( (linkStatus == LinkON) || !isW5500 ) && ((uint32_t) localEthernetIP != 0) ) + ETM_LOGINFO1("localEthernetIP = ", localEthernetIP); + + if ( ( (linkStatus == LinkON) || !isW5500 ) || ((uint32_t) localEthernetIP != 0) ) #endif { Serial.print(F("H")); @@ -144,6 +151,9 @@ void heartBeatPrint() if (num == 80) { Serial.println(); + + ethernet_manager.printMacAddress(); + num = 1; } else if (num++ % 10 == 0) @@ -174,8 +184,6 @@ void initEthernet() ET_LOGWARN(F("======== USE_NATIVE_ETHERNET ========")); #elif USE_ETHERNET_GENERIC ET_LOGWARN(F("=========== USE_ETHERNET_GENERIC ===========")); -#elif USE_ETHERNET_ESP8266 - ET_LOGWARN(F("=========== USE_ETHERNET_ESP8266 ===========")); #elif USE_ETHERNET_ENC ET_LOGWARN(F("=========== USE_ETHERNET_ENC ===========")); #else @@ -352,6 +360,19 @@ void setup() ethernet_manager.setCORSHeader("Your Access-Control-Allow-Origin"); #endif + ////////////////////////////////////////////// + +#define USING_CUSTOM_MAC_ADDRESS false + +#if USING_CUSTOM_MAC_ADDRESS + // To use your specified macAddress + byte newMacAddress[6] = { 0xFE, 0xED, 0xDE, 0xAD, 0xBE, 0xEF }; + + ethernet_manager.setMacAddress(newMacAddress); +#endif + + ////////////////////////////////////////////// + ethernet_manager.begin(); ////////////////////////////////////////////// diff --git a/examples/MQTT_ThingStream_Ethernet_nRF52/defines.h b/examples/MQTT_ThingStream_Ethernet_nRF52/defines.h index d569e0ae..21d607dd 100644 --- a/examples/MQTT_ThingStream_Ethernet_nRF52/defines.h +++ b/examples/MQTT_ThingStream_Ethernet_nRF52/defines.h @@ -80,11 +80,27 @@ #if defined(ETHERNET_USE_SAMD) // For SAMD - // Default pin 10 to SS/CS - #define USE_THIS_SS_PIN 10 + // Default pin SS/CS,if no SS pin, use pin 10 + #if defined(PIN_SPI_MOSI) + //#warning Using SS pin + #define USE_THIS_SS_PIN 10 //SS + #else + #define USE_THIS_SS_PIN 10 + #endif #if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) ) #define BOARD_TYPE "SAMD Zero" + + // Default to use W5100. Must change to false for W5500, W5100S, for faster SPI clock + // Must use true for SAMD21, such as Zero, SAMD_FEATHER_M0_EXPRESS, etc. + #define USE_W5100 true + + // Use this for ARDUINO_SAMD_ZERO, etc. if can't print to terminal with Serial.print + #if defined(SERIAL_PORT_USBVIRTUAL) + #define Serial SERIAL_PORT_USBVIRTUAL + #warning Using SAMD Zero SerialUSB + #endif + #elif defined(ARDUINO_SAMD_MKR1000) #define BOARD_TYPE "SAMD MKR1000" #elif defined(ARDUINO_SAMD_MKRWIFI1010) @@ -226,6 +242,7 @@ #endif #elif ( defined(CORE_TEENSY) ) + #error Teensy not supported // Default pin 10 to SS/CS #define USE_THIS_SS_PIN 10 @@ -335,8 +352,6 @@ //#define USE_UIP_ETHERNET true #define USE_UIP_ETHERNET false -// Note: To rename ESP628266 Ethernet lib files to Ethernet_ESP8266.h and Ethernet_ESP8266.cpp -// In order to USE_ETHERNET_ESP8266 #if ( !defined(USE_UIP_ETHERNET) || !USE_UIP_ETHERNET ) // To override the default CS/SS pin. Don't use unless you know exactly which pin to use @@ -346,11 +361,10 @@ // Only one if the following to be true #define USE_ETHERNET_GENERIC true - #define USE_ETHERNET_ESP8266 false #define USE_ETHERNET_ENC false #define USE_CUSTOM_ETHERNET false - #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ESP8266 || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET ) + #if ( USE_ETHERNET_GENERIC || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET ) #ifdef USE_CUSTOM_ETHERNET #undef USE_CUSTOM_ETHERNET #endif @@ -375,12 +389,7 @@ #include "Ethernet_Generic.h" #warning Using Ethernet_Generic lib - - #elif USE_ETHERNET_ESP8266 - #include "Ethernet_ESP8266.h" - #warning Using Ethernet_ESP8266 lib - #define SHIELD_TYPE "W5x00 using Ethernet_ESP8266 Library" - + #elif USE_ETHERNET_ENC #include "EthernetENC.h" #warning Using EthernetENC lib diff --git a/examples/MQTT_ThingStream_QNEthernet_Teensy/defines.h b/examples/MQTT_ThingStream_QNEthernet_Teensy/defines.h index ef25c0d7..fa3f59ec 100644 --- a/examples/MQTT_ThingStream_QNEthernet_Teensy/defines.h +++ b/examples/MQTT_ThingStream_QNEthernet_Teensy/defines.h @@ -57,7 +57,6 @@ #define USE_UIP_ETHERNET false #define USE_ETHERNET_GENERIC false -#define USE_ETHERNET_ESP8266 false #define USE_ETHERNET_ENC false #define USE_CUSTOM_ETHERNET false diff --git a/examples/QNEthernet_Teensy/defines.h b/examples/QNEthernet_Teensy/defines.h index ef25c0d7..fa3f59ec 100644 --- a/examples/QNEthernet_Teensy/defines.h +++ b/examples/QNEthernet_Teensy/defines.h @@ -57,7 +57,6 @@ #define USE_UIP_ETHERNET false #define USE_ETHERNET_GENERIC false -#define USE_ETHERNET_ESP8266 false #define USE_ETHERNET_ENC false #define USE_CUSTOM_ETHERNET false