diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8b667a0d..7a4be5db 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -15,7 +15,7 @@ If you don't find anything, please [open a new issue](https://github.com/khoih-p Please ensure to specify the following: * Arduino IDE version (e.g. 1.8.15) or Platform.io version -* Board Core Version (e.g. Arduino SAMDUE core v1.6.12, ESP8266 core v3.0.1, etc.) +* Board Core Version (e.g. Arduino SAMDUE core v1.6.12, ESP8266 core v3.0.2, Teensy core v1.54, etc.) * Contextual information (e.g. what you were trying to achieve) * Simplest possible steps to reproduce * Anything that might be relevant in your opinion, such as: @@ -28,9 +28,9 @@ Please ensure to specify the following: ``` Arduino IDE version: 1.8.15 WT32_ETH01 board -ESP32 core v1.0.6 +ESP32 core v2.0.0 OS: Ubuntu 20.04 LTS -Linux xy-Inspiron-3593 5.4.0-77-generic #86-Ubuntu SMP Thu Jun 17 02:35:03 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux +Linux xy-Inspiron-3593 5.4.0-81-generic #91-Ubuntu SMP Thu Jul 15 19:09:17 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux Context: The board couldn't autoreconnect to Local Blynk Server after router power recycling. diff --git a/README.md b/README.md index 7669a94c..8bb50c7e 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ * [Currently supported Boards](#currently-supported-boards) * [Currently supported Ethernet shields/modules](#currently-supported-ethernet-shieldsmodules) * [Changelog](#changelog) + * [Major Releases v1.6.0](#major-releases-v160) * [Major Releases v1.5.0](#major-releases-v150) * [Major Releases v1.4.0](#major-releases-v140) * [Major Releases v1.3.0](#major-releases-v130) @@ -114,6 +115,8 @@ * [13. **MQTT_ThingStream_Ethernet_SAM_DUE**](examples/MQTT_ThingStream_Ethernet_SAM_DUE) * [14. **MQTT_ThingStream_Ethernet_Teensy**](examples/MQTT_ThingStream_Ethernet_Teensy) * [15. **MQTT_ThingStream_Ethernet_WT32_ETH01**](examples/MQTT_ThingStream_Ethernet_WT32_ETH01). **New** + * [16. QNEthernet_Teensy](examples/QNEthernet_Teensy). **New** + * [17. **MQTT_ThingStream_QNEthernet_Teensy**](examples/MQTT_ThingStream_QNEthernet_Teensy). **New** * [So, how it works?](#so-how-it-works) * [Example Ethernet_Generic](#example-ethernet_generic) * [1. File Ethernet_Generic.ino](#1-file-ethernet_genericino) @@ -142,8 +145,7 @@ * [7.2. Data Saved => Exit Config Portal](#72-data-saved--exit-config-portal) * [8. MQTT_ThingStream_Ethernet_WT32_ETH01 on WT32-ETH01](#8-mqtt_thingstream_ethernet_wt32_eth01-on-wt32-eth01) * [8.1. Normal run with correct ThingStream MQTT Credentials](#81-normal-run-with-correct-thingstream-mqtt-credentials) - - + * [9. QNEthernet_Teensy on TEENSY 4.1 using QNEthernet](#9-qnethernet_teensy-on-teensy-41-using-qnethernet) * [Debug](#debug) * [Troubleshooting](#troubleshooting) * [Releases](#releases) @@ -163,7 +165,7 @@ #### Features -- This is the new library, adding to the current WiFiManager sets of libraries. It's designed to help you eliminate `hardcoding` your Credentials in **Teensy, SAM DUE, SAMD21, SAMD51, nRF52,RP2040-based, etc. boards using Ethernet shields (W5100, W5200, W5500, ENC28J60, Teensy 4.1 NativeEthernet, etc)**. It's currently **not supporting SSL**. Will support soon. +- This is the new library, adding to the current WiFiManager sets of libraries. It's designed to help you eliminate `hardcoding` your Credentials in **Teensy, SAM DUE, SAMD21, SAMD51, nRF52,RP2040-based, etc. boards using Ethernet shields (W5100, W5200, W5500, ENC28J60, Teensy 4.1 NativeEthernet/QNEthernet, etc)**. It's currently **not supporting SSL**. Will support soon. - It's not supporting UNO/Nano/Mega and other AVR boards for not enough memory. - You can update Credentials any time you need to change via Configure Portal. Data are saved in configurable locations in EEPROM, DueFlashStorage or FlashStorage @@ -219,14 +221,20 @@ This [**Ethernet_Manager** library](https://github.com/khoih-prog/Ethernet_Manag 1. W5x00 using [`Ethernet`](https://www.arduino.cc/en/Reference/Ethernet), [`EthernetLarge`](https://github.com/OPEnSLab-OSU/EthernetLarge), [`Ethernet2`](https://github.com/adafruit/Ethernet2) or [`Ethernet3`](https://github.com/sstaub/Ethernet3) library 2. ENC28J60 using [`EthernetENC`](https://github.com/jandrassy/EthernetENC) or [`UIPEthernet`](https://github.com/UIPEthernet/UIPEthernet) library -3. Teensy 4.1 NativeEthernet using [`NativeEthernet Library version stable111+`](https://github.com/vjmuzik/NativeEthernet). +3. Teensy 4.1 built-in Ethernet using [`NativeEthernet`](https://github.com/vjmuzik/NativeEthernet) library 4. LAN8720 Ethernet used in WT32_ETH01 boards +5. Teensy 4.1 built-in Ethernet using [`QNEthernet`](https://github.com/ssilverman/QNEthernet) library --- --- ## Changelog +### Major Releases v1.6.0 + +1. Add support to [QNEthernet Library](https://github.com/ssilverman/QNEthernet) for Teensy 4.1 built-in Ethernet +2. Update examples with new features + ### Major Releases v1.5.0 1. Add support to ESP32-based WT32-ETH01 (ESP32 + LAN8720) boards, using EEPROM, SPIFFS or LittleFS @@ -275,35 +283,37 @@ This [**Ethernet_Manager** library](https://github.com/khoih-prog/Ethernet_Manag ## Prerequisites 1. [`Arduino IDE 1.8.15+` for Arduino](https://www.arduino.cc/en/Main/Software) - 2. [`Teensy core v1.51`](https://www.pjrc.com/teensy/td_download.html) for Teensy (4.0, 3.6, 3.5, 3,2, 3.1, 3.0) boards and [`Teensy core v1.53+`](https://www.pjrc.com/teensy/td_download.html) for Teensy 4.1 boards using NativeEthernet. - 3. [`Arduino SAM DUE core v1.6.12+`](https://www.arduino.cc/en/Guide/ArduinoDue) for SAM DUE ARM Cortex-M3 boards. - 4. [`Arduino SAMD core 1.8.11+`](https://www.arduino.cc/en/Guide/ArduinoM0) for SAMD ARM Cortex-M0+ boards. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-samd.svg)](https://github.com/arduino/ArduinoCore-samd/releases/latest) - 5. [`Adafruit SAMD core 1.7.3+`](https://www.adafruit.com/) for SAMD ARM Cortex-M0+ and M4 boards (Nano 33 IoT, etc.). [![GitHub release](https://img.shields.io/github/release/adafruit/ArduinoCore-samd.svg)](https://github.com/adafruit/ArduinoCore-samd/releases/latest) - 6. [`Seeeduino SAMD core 1.8.1+`](https://github.com/Seeed-Studio/ArduinoCore-samd) for SAMD21/SAMD51 boards (XIAO M0, Wio Terminal, etc.). [![Latest release](https://img.shields.io/github/release/Seeed-Studio/ArduinoCore-samd.svg)](https://github.com/Seeed-Studio/ArduinoCore-samd/releases/latest/) - 7. [`Adafruit nRF52 v0.24.0+`](https://www.adafruit.com) for nRF52 boards such as Adafruit NRF52840_FEATHER, NRF52832_FEATHER, NRF52840_FEATHER_SENSE, NRF52840_ITSYBITSY, NRF52840_CIRCUITPLAY, NRF52840_CLUE, NRF52840_METRO, NRF52840_PCA10056, PARTICLE_XENON, **NINA_B302_ublox**, etc. [![GitHub release](https://img.shields.io/github/release/adafruit/Adafruit_nRF52_Arduino.svg)](https://github.com/adafruit/Adafruit_nRF52_Arduino/releases/latest) - 8. [`ESP8266 Core 3.0.1+`](https://github.com/esp8266/Arduino) for ESP8266-based boards. [![Latest release](https://img.shields.io/github/release/esp8266/Arduino.svg)](https://github.com/esp8266/Arduino/releases/latest/). To use ESP8266 core 2.7.1+ for LittleFS. - 9. [`ESP32 Core 1.0.6+`](https://github.com/espressif/arduino-esp32) for ESP32-based boards. [![Latest release](https://img.shields.io/github/release/espressif/arduino-esp32.svg)](https://github.com/espressif/arduino-esp32/releases/latest/) -10. [`ESP32S2 Core 1.0.6+`](https://github.com/espressif/arduino-esp32/tree/esp32s2) for ESP32S2-based boards. -11. [`Earle Philhower's arduino-pico core v1.9.1+`](https://github.com/earlephilhower/arduino-pico) for RP2040-based boards such as **RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, etc. [![GitHub release](https://img.shields.io/github/release/earlephilhower/arduino-pico.svg)](https://github.com/earlephilhower/arduino-pico/releases/latest) -12. [`Arduino mbed_rp2040 core 2.2.0+`](https://github.com/arduino/ArduinoCore-mbed) for Arduino (Use Arduino Board Manager) RP2040-based boards, such as **Arduino Nano RP2040 Connect, RASPBERRY_PI_PICO, etc.**. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-mbed.svg)](https://github.com/arduino/ArduinoCore-mbed/releases/latest) -13. Depending on which Ethernet card you're using: + 2. [`Arduino AVR core 1.8.3+`](https://github.com/arduino/ArduinoCore-avr) for Arduino (Use Arduino Board Manager) AVR boards. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-avr.svg)](https://github.com/arduino/ArduinoCore-avr/releases/latest) + 3. [`Teensy core v1.54+`](https://www.pjrc.com/teensy/td_download.html) for Teensy (4.1, 4.0, 3.6, 3.5, 3,2, 3.1, 3.0) boards. + 4. [`Arduino SAM DUE core v1.6.12+`](https://github.com/arduino/ArduinoCore-sam) for SAM DUE ARM Cortex-M3 boards. + 5. [`Arduino SAMD core 1.8.11+`](https://github.com/arduino/ArduinoCore-samd) for SAMD ARM Cortex-M0+ boards. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-samd.svg)](https://github.com/arduino/ArduinoCore-samd/releases/latest) + 6. [`Adafruit SAMD core 1.7.5+`](https://github.com/adafruit/ArduinoCore-samd) for SAMD ARM Cortex-M0+ and M4 boards (Nano 33 IoT, etc.). [![GitHub release](https://img.shields.io/github/release/adafruit/ArduinoCore-samd.svg)](https://github.com/adafruit/ArduinoCore-samd/releases/latest) + 7. [`Seeeduino SAMD core 1.8.1+`](https://github.com/Seeed-Studio/ArduinoCore-samd) for SAMD21/SAMD51 boards (XIAO M0, Wio Terminal, etc.). [![Latest release](https://img.shields.io/github/release/Seeed-Studio/ArduinoCore-samd.svg)](https://github.com/Seeed-Studio/ArduinoCore-samd/releases/latest/) + 8. [`Adafruit nRF52 v1.0.0+`](https://github.com/adafruit/Adafruit_nRF52_Arduino) for nRF52 boards such as Adafruit NRF52840_FEATHER, NRF52832_FEATHER, NRF52840_FEATHER_SENSE, NRF52840_ITSYBITSY, NRF52840_CIRCUITPLAY, NRF52840_CLUE, NRF52840_METRO, NRF52840_PCA10056, PARTICLE_XENON, **NINA_B302_ublox**, etc. [![GitHub release](https://img.shields.io/github/release/adafruit/Adafruit_nRF52_Arduino.svg)](https://github.com/adafruit/Adafruit_nRF52_Arduino/releases/latest) + 9. [`ESP32 Core 2.0.0+`](https://github.com/espressif/arduino-esp32) for ESP32-based boards. [![Latest release](https://img.shields.io/github/release/espressif/arduino-esp32.svg)](https://github.com/espressif/arduino-esp32/releases/latest/) +10. [`ESP8266 Core 3.0.2+`](https://github.com/esp8266/Arduino) for ESP8266-based boards. [![Latest release](https://img.shields.io/github/release/esp8266/Arduino.svg)](https://github.com/esp8266/Arduino/releases/latest/). To use ESP8266 core 2.7.1+ for LittleFS. +11. [`Arduino mbed_rp2040 core 2.4.1+`](https://github.com/arduino/ArduinoCore-mbed) for Arduino (Use Arduino Board Manager) RP2040-based boards, such as RASPBERRY_PI_PICO. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-mbed.svg)](https://github.com/arduino/ArduinoCore-mbed/releases/latest) +12. [`Earle Philhower's arduino-pico core v1.9.4+`](https://github.com/earlephilhower/arduino-pico) for RP2040-based boards such as **RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, etc. [![GitHub release](https://img.shields.io/github/release/earlephilhower/arduino-pico.svg)](https://github.com/earlephilhower/arduino-pico/releases/latest) +13. [`Functional-VLPP library v1.0.2+`](https://github.com/khoih-prog/functional-vlpp) to use server's lambda function. To install. check [![arduino-library-badge](https://www.ardu-badge.com/badge/Functional-Vlpp.svg?)](https://www.ardu-badge.com/Functional-Vlpp) +14. Depending on which Ethernet card you're using: - [`Ethernet library v2.0.0+`](https://github.com/arduino-libraries/Ethernet) for W5100, W5200 and W5500. [![GitHub release](https://img.shields.io/github/release/arduino-libraries/Ethernet.svg)](https://github.com/arduino-libraries/Ethernet/releases/latest) - [`EthernetLarge library v2.0.0+`](https://github.com/OPEnSLab-OSU/EthernetLarge) for W5100, W5200 and W5500. - [`Ethernet2 library v1.0.4+`](https://github.com/khoih-prog/Ethernet2) for W5500. [![GitHub release](https://img.shields.io/github/release/adafruit/Ethernet2.svg)](https://github.com/adafruit/Ethernet2/releases/latest) - [`Ethernet3 library v1.5.5+`](https://github.com/sstaub/Ethernet3) for W5500/WIZ550io/WIZ850io/USR-ES1 with Wiznet W5500 chip. [![GitHub release](https://img.shields.io/github/release/sstaub/Ethernet3.svg)](https://github.com/sstaub/Ethernet3/releases/latest) - [`EthernetENC library v2.0.1+`](https://github.com/jandrassy/EthernetENC) for ENC28J60. [![GitHub release](https://img.shields.io/github/release/jandrassy/EthernetENC.svg)](https://github.com/jandrassy/EthernetENC/releases/latest). **New and Better** - [`UIPEthernet library v2.0.10+`](https://github.com/UIPEthernet/UIPEthernet) for ENC28J60. [![GitHub release](https://img.shields.io/github/release/UIPEthernet/UIPEthernet.svg)](https://github.com/UIPEthernet/UIPEthernet/releases/latest) - - [`NativeEthernet Library version stable111+`](https://github.com/vjmuzik/NativeEthernet) for Teensy 4.1 built-in NativeEthernet. -14. Depending on which board you're using: + - [`NativeEthernet Library version stable111+`](https://github.com/vjmuzik/NativeEthernet) for Teensy 4.1 built-in Ethernet. + - [`QNEthernet Library version v0.4.0+`](https://github.com/ssilverman/QNEthernet) for Teensy 4.1 built-in Ethernet. **New** +15. Depending on which board you're using: - [`DueFlashStorage library v1.0.0+`](https://github.com/sebnil/DueFlashStorage) for SAM DUE. To install, check [![arduino-library-badge](https://www.ardu-badge.com/badge/DueFlashStorage.svg?)](https://www.ardu-badge.com/DueFlashStorage) - - [`FlashStorage_SAMD library v1.1.0+`](https://github.com/khoih-prog/FlashStorage_SAMD) for SAMD21 and SAMD51 boards (ZERO, MKR, NANO_33_IOT, M0, M0 Pro, AdaFruit Itsy-Bitsy M4, etc.). [![GitHub release](https://img.shields.io/github/release/khoih-prog/FlashStorage_SAMD.svg)](https://github.com/khoih-prog/FlashStorage_SAMD/releases/latest) + - [`FlashStorage_SAMD library v1.2.0+`](https://github.com/khoih-prog/FlashStorage_SAMD) for SAMD21 and SAMD51 boards (ZERO, MKR, NANO_33_IOT, M0, M0 Pro, AdaFruit Itsy-Bitsy M4, etc.). [![GitHub release](https://img.shields.io/github/release/khoih-prog/FlashStorage_SAMD.svg)](https://github.com/khoih-prog/FlashStorage_SAMD/releases/latest) - [`Adafruit's LittleFS/InternalFS`](www.adafruit.com) for nRF52 -15. [`EthernetWebServer library v1.5.0+`](https://github.com/khoih-prog/EthernetWebServer). To install. check [![arduino-library-badge](https://www.ardu-badge.com/badge/EthernetWebServer.svg?)](https://www.ardu-badge.com/EthernetWebServer). -16. [`WebServer_WT32_ETH01 library v1.1.0+`](https://github.com/khoih-prog/WebServer_WT32_ETH01) for WT32_ETH01 boards. To install. check [![arduino-library-badge](https://www.ardu-badge.com/badge/WebServer_WT32_ETH01.svg?)](https://www.ardu-badge.com/WebServer_WT32_ETH01). -17. [`ESP_DoubleResetDetector library v1.1.1+`](https://github.com/khoih-prog/ESP_DoubleResetDetector) for ESP32 and ESP8266. To install. check [![arduino-library-badge](https://www.ardu-badge.com/badge/ESP_DoubleResetDetector.svg?)](https://www.ardu-badge.com/ESP_DoubleResetDetector). -18. [`DoubleResetDetector_Generic library v1.4.0+`](https://github.com/khoih-prog/DoubleResetDetector_Generic) for other boards (not ESP32 or ESP8266). To install. check [![arduino-library-badge](https://www.ardu-badge.com/badge/DoubleResetDetector_Generic.svg?)](https://www.ardu-badge.com/DoubleResetDetector_Generic). -19. [`Functional-VLPP library v1.0.2+`](https://github.com/khoih-prog/functional-vlpp) to use server's lambda function. To install. check [![arduino-library-badge](https://www.ardu-badge.com/badge/Functional-Vlpp.svg?)](https://www.ardu-badge.com/Functional-Vlpp) -20. [`LittleFS_esp32 v1.0.6+`](https://github.com/lorol/LITTLEFS) for ESP32-based boards using LittleFS. To install, check [![arduino-library-badge](https://www.ardu-badge.com/badge/LittleFS_esp32.svg?)](https://www.ardu-badge.com/LittleFS_esp32). **Notice**: This [`LittleFS_esp32 library`](https://github.com/lorol/LITTLEFS) has been integrated to Arduino [esp32 core v1.0.6](https://github.com/espressif/arduino-esp32/tree/master/libraries/LITTLEFS). +16. [`EthernetWebServer library v1.5.0+`](https://github.com/khoih-prog/EthernetWebServer). To install. check [![arduino-library-badge](https://www.ardu-badge.com/badge/EthernetWebServer.svg?)](https://www.ardu-badge.com/EthernetWebServer). +17. [`WebServer_WT32_ETH01 library v1.2.0+`](https://github.com/khoih-prog/WebServer_WT32_ETH01) for WT32_ETH01 boards. To install. check [![arduino-library-badge](https://www.ardu-badge.com/badge/WebServer_WT32_ETH01.svg?)](https://www.ardu-badge.com/WebServer_WT32_ETH01). +18. [`ESP_DoubleResetDetector library v1.1.1+`](https://github.com/khoih-prog/ESP_DoubleResetDetector) for ESP32 and ESP8266. To install. check [![arduino-library-badge](https://www.ardu-badge.com/badge/ESP_DoubleResetDetector.svg?)](https://www.ardu-badge.com/ESP_DoubleResetDetector). +19. [`DoubleResetDetector_Generic library v1.6.0+`](https://github.com/khoih-prog/DoubleResetDetector_Generic) for other boards (not ESP32 or ESP8266). To install. check [![arduino-library-badge](https://www.ardu-badge.com/badge/DoubleResetDetector_Generic.svg?)](https://www.ardu-badge.com/DoubleResetDetector_Generic). +20. [`Functional-VLPP library v1.0.2+`](https://github.com/khoih-prog/functional-vlpp) to use server's lambda function. To install. check [![arduino-library-badge](https://www.ardu-badge.com/badge/Functional-Vlpp.svg?)](https://www.ardu-badge.com/Functional-Vlpp) +21. [`LittleFS_esp32 v1.0.6+`](https://github.com/lorol/LITTLEFS) for ESP32-based boards using LittleFS. To install, check [![arduino-library-badge](https://www.ardu-badge.com/badge/LittleFS_esp32.svg?)](https://www.ardu-badge.com/LittleFS_esp32). **Notice**: This [`LittleFS_esp32 library`](https://github.com/lorol/LITTLEFS) has been integrated to Arduino [esp32 core v1.0.6](https://github.com/espressif/arduino-esp32/tree/master/libraries/LITTLEFS). --- @@ -337,16 +347,16 @@ The best way is to use `Arduino Library Manager`. Search for `Ethernet_Manager`, #### 1. For Adafruit nRF52840 and nRF52832 boards -**To be able to compile, run and automatically detect and display BOARD_NAME on nRF52840/nRF52832 boards**, you have to copy the whole [nRF52 0.21.1](Packages_Patches/adafruit/hardware/nrf52/0.21.1) directory into Adafruit nRF52 directory (~/.arduino15/packages/adafruit/hardware/nrf52/0.21.1). +**To be able to compile, run and automatically detect and display BOARD_NAME on nRF52840/nRF52832 boards**, you have to copy the whole [nRF52 1.0.0](Packages_Patches/adafruit/hardware/nrf52/1.0.0) directory into Adafruit nRF52 directory (~/.arduino15/packages/adafruit/hardware/nrf52/1.0.0). -Supposing the Adafruit nRF52 version is 0.21.1. These files must be copied into the directory: -- `~/.arduino15/packages/adafruit/hardware/nrf52/0.21.1/platform.txt` -- `~/.arduino15/packages/adafruit/hardware/nrf52/0.21.1/boards.txt` -- `~/.arduino15/packages/adafruit/hardware/nrf52/0.21.1/variants/NINA_B302_ublox/variant.h` -- `~/.arduino15/packages/adafruit/hardware/nrf52/0.21.1/variants/NINA_B302_ublox/variant.cpp` -- `~/.arduino15/packages/adafruit/hardware/nrf52/0.21.1/variants/NINA_B112_ublox/variant.h` -- `~/.arduino15/packages/adafruit/hardware/nrf52/0.21.1/variants/NINA_B112_ublox/variant.cpp` -- **`~/.arduino15/packages/adafruit/hardware/nrf52/0.21.1/cores/nRF5/Udp.h`** +Supposing the Adafruit nRF52 version is 1.0.0. These files must be copied into the directory: +- `~/.arduino15/packages/adafruit/hardware/nrf52/1.0.0/platform.txt` +- `~/.arduino15/packages/adafruit/hardware/nrf52/1.0.0/boards.txt` +- `~/.arduino15/packages/adafruit/hardware/nrf52/1.0.0/variants/NINA_B302_ublox/variant.h` +- `~/.arduino15/packages/adafruit/hardware/nrf52/1.0.0/variants/NINA_B302_ublox/variant.cpp` +- `~/.arduino15/packages/adafruit/hardware/nrf52/1.0.0/variants/NINA_B112_ublox/variant.h` +- `~/.arduino15/packages/adafruit/hardware/nrf52/1.0.0/variants/NINA_B112_ublox/variant.cpp` +- **`~/.arduino15/packages/adafruit/hardware/nrf52/1.0.0/cores/nRF5/Udp.h`** Whenever a new version is installed, remember to copy these files into the new version directory. For example, new version is x.yy.z These files must be copied into the directory: @@ -432,11 +442,11 @@ Whenever the above-mentioned compiler error issue is fixed with the new Arduino #### 5. For Adafruit SAMD boards - ***To be able to automatically detect and display BOARD_NAME on Adafruit SAMD (Itsy-Bitsy M4, etc) boards***, you have to copy the file [Adafruit SAMD platform.txt](Packages_Patches/adafruit/hardware/samd/1.7.2) into Adafruit samd directory (~/.arduino15/packages/adafruit/hardware/samd/1.7.2). + ***To be able to automatically detect and display BOARD_NAME on Adafruit SAMD (Itsy-Bitsy M4, etc) boards***, you have to copy the file [Adafruit SAMD platform.txt](Packages_Patches/adafruit/hardware/samd/1.7.5) into Adafruit samd directory (~/.arduino15/packages/adafruit/hardware/samd/1.7.5). -Supposing the Adafruit SAMD core version is 1.7.2. This file must be copied into the directory: +Supposing the Adafruit SAMD core version is 1.7.5. This file must be copied into the directory: -- `~/.arduino15/packages/adafruit/hardware/samd/1.7.2/platform.txt` +- `~/.arduino15/packages/adafruit/hardware/samd/1.7.5/platform.txt` Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz This file must be copied into the directory: @@ -466,12 +476,12 @@ To use LAN8720 on some STM32 boards - **Discovery (DISCO_F746NG)** - **STM32F4 boards (BLACK_F407VE, BLACK_F407VG, BLACK_F407ZE, BLACK_F407ZG, BLACK_F407VE_Mini, DIYMORE_F407VGT, FK407M1)** -you have to copy the files [stm32f4xx_hal_conf_default.h](Packages_Patches/STM32/hardware/stm32/2.0.0/system/STM32F4xx) and [stm32f7xx_hal_conf_default.h](Packages_Patches/STM32/hardware/stm32/2.0.0/system/STM32F7xx) into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/2.0.0/system) to overwrite the old files. +you have to copy the files [stm32f4xx_hal_conf_default.h](Packages_Patches/STM32/hardware/stm32/1.9.0/system/STM32F4xx) and [stm32f7xx_hal_conf_default.h](Packages_Patches/STM32/hardware/stm32/1.9.0/system/STM32F7xx) into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/1.9.0/system) to overwrite the old files. -Supposing the STM32 stm32 core version is 2.0.0. These files must be copied into the directory: +Supposing the STM32 stm32 core version is 1.9.0. These files must be copied into the directory: -- `~/.arduino15/packages/STM32/hardware/stm32/2.0.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h` for STM32F4. -- `~/.arduino15/packages/STM32/hardware/stm32/2.0.0/system/STM32F7xx/stm32f7xx_hal_conf_default.h` for Nucleo-144 STM32F7. +- `~/.arduino15/packages/STM32/hardware/stm32/1.9.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h` for STM32F4. +- `~/.arduino15/packages/STM32/hardware/stm32/1.9.0/system/STM32F7xx/stm32f7xx_hal_conf_default.h` for Nucleo-144 STM32F7. Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz, theses files must be copied into the corresponding directory: @@ -482,12 +492,12 @@ theses files must be copied into the corresponding directory: #### 7.2 For STM32 boards to use Serial1 -**To use Serial1 on some STM32 boards without Serial1 definition (Nucleo-144 NUCLEO_F767ZI, Nucleo-64 NUCLEO_L053R8, etc.) boards**, you have to copy the files [STM32 variant.h](Packages_Patches/STM32/hardware/stm32/2.0.0) into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/2.0.0). You have to modify the files corresponding to your boards, this is just an illustration how to do. +**To use Serial1 on some STM32 boards without Serial1 definition (Nucleo-144 NUCLEO_F767ZI, Nucleo-64 NUCLEO_L053R8, etc.) boards**, you have to copy the files [STM32 variant.h](Packages_Patches/STM32/hardware/stm32/1.9.0) into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/1.9.0). You have to modify the files corresponding to your boards, this is just an illustration how to do. -Supposing the STM32 stm32 core version is 2.0.0. These files must be copied into the directory: +Supposing the STM32 stm32 core version is 1.9.0. These files must be copied into the directory: -- `~/.arduino15/packages/STM32/hardware/stm32/2.0.0/variants/NUCLEO_F767ZI/variant.h` for Nucleo-144 NUCLEO_F767ZI. -- `~/.arduino15/packages/STM32/hardware/stm32/2.0.0/variants/NUCLEO_L053R8/variant.h` for Nucleo-64 NUCLEO_L053R8. +- `~/.arduino15/packages/STM32/hardware/stm32/1.9.0/variants/NUCLEO_F767ZI/variant.h` for Nucleo-144 NUCLEO_F767ZI. +- `~/.arduino15/packages/STM32/hardware/stm32/1.9.0/variants/NUCLEO_L053R8/variant.h` for Nucleo-64 NUCLEO_L053R8. Whenever a new version is installed, remember to copy this file into the new version directory. For example, new version is x.yy.zz, theses files must be copied into the corresponding directory: @@ -510,7 +520,7 @@ This file must be copied into the directory: - `~/.arduino15/packages/rp2040/hardware/rp2040/x.yy.zz/platform.txt` -With core after v1.5.1, this step is not necessary anymore thanks to the PR [Add -DBOARD_NAME="{build.board}" #136](https://github.com/earlephilhower/arduino-pico/pull/136). +With core after v1.5.0, this step is not necessary anymore thanks to the PR [Add -DBOARD_NAME="{build.board}" #136](https://github.com/earlephilhower/arduino-pico/pull/136). #### 8.2 To avoid compile error relating to microsecondsToClockCycles @@ -525,7 +535,7 @@ This file must be copied to replace: - `~/.arduino15/packages/rp2040/hardware/rp2040/x.yy.zz/cores/rp2040/Arduino.h` -With core after v1.5.1, this step is not necessary anymore thanks to the PR [Add defs for compatibility #142](https://github.com/earlephilhower/arduino-pico/pull/142). +With core after v1.5.0, this step is not necessary anymore thanks to the PR [Add defs for compatibility #142](https://github.com/earlephilhower/arduino-pico/pull/142). --- @@ -922,80 +932,209 @@ The end of `LittleFS` is set at the end of RP2040 Flash, currently 2MB The easiest way is to use -``` +```cpp #define USE_ETHERNET_WRAPPER true ``` then select **one and only one** Ethernet library to use as follows: -- Standard Ethernet library is used by default, in the sketch, just be sure to comment out or leave these #defines to be false : +- Standard W5x00 Ethernet library is used by default, in the sketch, just be sure to comment out or leave these #defines to be false : -``` -//#define USE_UIP_ETHERNET true -#define USE_UIP_ETHERNET false +```cpp +#define USE_UIP_ETHERNET false - // Only one if the following to be true - #define USE_ETHERNET true - #define USE_ETHERNET2 false - #define USE_ETHERNET3 false - #define USE_ETHERNET_LARGE false - #define USE_ETHERNET_ESP8266 false - #define USE_ETHERNET_ENC false - #define USE_CUSTOM_ETHERNET false +// Only one if the following to be true +#define USE_NATIVE_ETHERNET false +#define USE_QN_ETHERNET false +#define USE_ETHERNET true +#define USE_ETHERNET2 false +#define USE_ETHERNET3 false +#define USE_ETHERNET_LARGE false +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_CUSTOM_ETHERNET false ``` -- To use built-in UIPEthernet built-in or shield: +To use W5x00 Ethernet, for example using EthernetLarge library + +```cpp +#define USE_UIP_ETHERNET false +// Only one if the following to be true +#define USE_NATIVE_ETHERNET false +#define USE_QN_ETHERNET false +#define USE_ETHERNET false +#define USE_ETHERNET2 false +#define USE_ETHERNET3 false +#define USE_ETHERNET_LARGE true +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_CUSTOM_ETHERNET false ``` -#define USE_UIP_ETHERNET true -//#define USE_UIP_ETHERNET false - // Only one if the following to be true - #define USE_ETHERNET false - #define USE_ETHERNET2 false - #define USE_ETHERNET3 false - #define USE_ETHERNET_LARGE false - #define USE_ETHERNET_ESP8266 false - #define USE_ETHERNET_ENC false - #define USE_CUSTOM_ETHERNET false +- To use ENC28J60 Ethernet, using EthernetENC library (**NEW and Better**) + +```cpp +#define USE_UIP_ETHERNET false + +// Only one if the following to be true +#define USE_NATIVE_ETHERNET false +#define USE_QN_ETHERNET false +#define USE_ETHERNET false +#define USE_ETHERNET2 false +#define USE_ETHERNET3 false +#define USE_ETHERNET_LARGE false +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC true +#define USE_CUSTOM_ETHERNET false ``` -- To use any of the custom Ethernet library, such as Ethernet2, Ethernet3, EthernetLarge: +- To use ENC28J60 Ethernet, using UIPEthernet library: +```cpp +#define USE_UIP_ETHERNET true + +// Only one if the following to be true +#define USE_NATIVE_ETHERNET false +#define USE_QN_ETHERNET false +#define USE_ETHERNET false +#define USE_ETHERNET2 false +#define USE_ETHERNET3 false +#define USE_ETHERNET_LARGE false +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_CUSTOM_ETHERNET false ``` -#define USE_UIP_ETHERNET true -//#define USE_UIP_ETHERNET false - // Only one if the following to be true - #define USE_ETHERNET false - #define USE_ETHERNET2 true - #define USE_ETHERNET3 false - #define USE_ETHERNET_LARGE false - #define USE_ETHERNET_ESP8266 false - #define USE_ETHERNET_ENC false - #define USE_CUSTOM_ETHERNET false +- To use any of the Ethernet libraries, such as Ethernet2, Ethernet3, EthernetLarge, EthernetENC: + +```cpp +#define USE_UIP_ETHERNET false + +// Only one if the following to be true +#define USE_NATIVE_ETHERNET false +#define USE_QN_ETHERNET false +#define USE_ETHERNET false +#define USE_ETHERNET2 false +#define USE_ETHERNET3 true +#define USE_ETHERNET_LARGE false +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_CUSTOM_ETHERNET false ``` - To use another Ethernet library For example, Ethernet_XYZ library uses **Ethernet_XYZ.h** -``` -#define USE_UIP_ETHERNET true -//#define USE_UIP_ETHERNET false - - // Only one if the following to be true - #define USE_ETHERNET false - #define USE_ETHERNET2 false - #define USE_ETHERNET3 false - #define USE_ETHERNET_LARGE false - #define USE_ETHERNET_ESP8266 false - #define USE_ETHERNET_ENC false - #define USE_CUSTOM_ETHERNET true +```cpp +#define USE_UIP_ETHERNET false + +// Only one if the following to be true +#define USE_NATIVE_ETHERNET false +#define USE_QN_ETHERNET false +#define USE_ETHERNET false +#define USE_ETHERNET2 false +#define USE_ETHERNET3 false +#define USE_ETHERNET_LARGE false +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_CUSTOM_ETHERNET true + +//Must be placed before #include +#include ... #include ``` +- Only for Teensy 4.1, to use NativeEthernet library + +``` +#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 + #define USE_QN_ETHERNET false + #elif defined(ARDUINO_TEENSY40) + #define BOARD_TYPE "TEENSY 4.0" + #else + #define BOARD_TYPE "TEENSY 4.x" + #endif + #elif defined(__MK66FX1M0__) + .... +``` + +- Only for Teensy 4.1, to use another Ethernet library, for example Ethernet3 library + +``` +#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 false + #define USE_QN_ETHERNET false + #elif defined(ARDUINO_TEENSY40) + #define BOARD_TYPE "TEENSY 4.0" + #else + #define BOARD_TYPE "TEENSY 4.x" + #endif +#elif defined(__MK66FX1M0__) + .... + +#define USE_UIP_ETHERNET false + +// Only one if the following to be true +#define USE_ETHERNET false +#define USE_ETHERNET2 false +#define USE_ETHERNET3 true +#define USE_ETHERNET_LARGE false +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_CUSTOM_ETHERNET false +``` + +- Only for Teensy 4.1, to use QNEthernet library + +``` +#if ( defined(CORE_TEENSY) && defined(__IMXRT1062__) && defined(ARDUINO_TEENSY41) ) + // For Teensy 4.1 + #define BOARD_TYPE "TEENSY 4.1" + // Use true for NativeEthernet Library, false if using other Ethernet libraries + #define USE_NATIVE_ETHERNET false + #define USE_QN_ETHERNET true +#else + #error Only Teensy 4.1 supported +#endif + +#define USE_ETHERNET_WRAPPER false + +// 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 false +#define USE_ETHERNET false +#define USE_ETHERNET2 false +#define USE_ETHERNET3 false +#define USE_ETHERNET_LARGE false +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_CUSTOM_ETHERNET false + +#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 "using NativeEthernet" +#elif USE_QN_ETHERNET + #include "QNEthernet.h" + using namespace qindesign::network; + #warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #define SHIELD_TYPE "using QNEthernet" +#endif +``` + --- #### 2. How to select another CS/SS pin to use @@ -1348,7 +1487,8 @@ Please be noted that the following **reserved names are already used in library* 13. [**MQTT_ThingStream_Ethernet_SAM_DUE**](examples/MQTT_ThingStream_Ethernet_SAM_DUE). 14. [**MQTT_ThingStream_Ethernet_Teensy**](examples/MQTT_ThingStream_Ethernet_Teensy). 15. [**MQTT_ThingStream_Ethernet_WT32_ETH01**](examples/MQTT_ThingStream_Ethernet_WT32_ETH01). **New** - +16. [QNEthernet_Teensy](examples/QNEthernet_Teensy). **New** +17. [**MQTT_ThingStream_QNEthernet_Teensy**](examples/MQTT_ThingStream_QNEthernet_Teensy). **New** --- --- @@ -2430,7 +2570,7 @@ This is the terminal output of an Adafruit NRF52840_FEATHER board with W5500 Eth ``` Start Ethernet_nRF52 on NRF52840_FEATHER Ethernet Shield type W5x00 using Ethernet2 Library -Ethernet_Manager v1.5.0 +Ethernet_Manager v1.6.0 DoubleResetDetector_Generic v1.4.0 [ETHERNET_WEBSERVER] =========== USE_ETHERNET2 =========== [ETHERNET_WEBSERVER] Default SPI pinout: @@ -2522,7 +2662,7 @@ Pubs Topics = old-mqtt-PubTopic ```cpp Start Ethernet_nRF52 on NRF52840_FEATHER Ethernet Shield type : W5x00 using Ethernet2 Library -Ethernet_Manager v1.5.0 +Ethernet_Manager v1.6.0 DoubleResetDetector_Generic v1.4.0 [ETHERNET_WEBSERVER] =========== USE_ETHERNET2 =========== [ETHERNET_WEBSERVER] Default SPI pinout: @@ -2705,7 +2845,7 @@ This is the terminal output of an SeeedStudio SAMD21 SEEED_XIAO_M0 board with W5 ``` Start Ethernet_SAMD on SEEED_XIAO_M0 Ethernet Shield type : W5x00 using Ethernet Library -Ethernet_Manager v1.5.0 +Ethernet_Manager v1.6.0 DoubleResetDetector_Generic v1.4.0 Flag read = 0xffffffff No doubleResetDetected @@ -2782,7 +2922,7 @@ This is the terminal output of an Arduino SAM DUE board with W5100 Ethernet shie ``` Start Ethernet_SAM_DUE on SAM DUE Ethernet Shield type : W5x00 using EthernetLarge Library -Ethernet_Manager v1.5.0 +Ethernet_Manager v1.6.0 DoubleResetDetector_Generic v1.4.0 Flag read = 0xd0d01234 doubleResetDetected @@ -2868,7 +3008,7 @@ If no valid config data are stored in EEPROM, it will switch to `Configuration M ``` Start MQTT_ThingStream_Ethernet_Generic using LittleFS on ESP8266_NODEMCU Ethernet Shield type : W5x00 using Ethernet2 Library -Ethernet_Manager v1.5.0 +Ethernet_Manager v1.6.0 ESP_DoubleResetDetector Version v1.1.1 ========================= Currently Used SPI pinout: @@ -2916,7 +3056,7 @@ Enter your credentials (Blynk Servers/Tokens and Port). If you prefer static IP, ``` Start MQTT_ThingStream_Ethernet_Generic using LittleFS on ESP8266_NODEMCU Ethernet Shield type : W5x00 using Ethernet2 Library -Ethernet_Manager v1.5.0 +Ethernet_Manager v1.6.0 ESP_DoubleResetDetector Version v1.1.1 ========================= Currently Used SPI pinout: @@ -2976,7 +3116,7 @@ This is the terminal output of NRF52840_FEATHER board with ENC28J60 using Ethern ``` Start MQTT_ThingStream_Ethernet_Generic on NRF52840_FEATHER Ethernet Shield type : ENC28J60 using EthernetENC Library -Ethernet_Manager v1.5.0 +Ethernet_Manager v1.6.0 DoubleResetDetector_Generic v1.4.0 LittleFS Flag read = 0xd0d01234 Flag read = 0xd0d01234 @@ -3014,7 +3154,7 @@ esp32-sniffer/12345678/ble ``` Start MQTT_ThingStream_Ethernet_Generic on NRF52840_FEATHER Ethernet Shield type : ENC28J60 using EthernetENC Library -Ethernet_Manager v1.5.0 +Ethernet_Manager v1.6.0 DoubleResetDetector_Generic v1.4.0 LittleFS Flag read = 0xd0d04321 Flag read = 0xd0d04321 @@ -3071,7 +3211,7 @@ This is the terminal output of RASPBERRY_PI_PICO board with W5x00 using Ethernet ``` Start MQTT_ThingStream_Ethernet_RP2040 on RASPBERRY_PI_PICO Ethernet Shield type : W5x00 using Ethernet Library -Ethernet_Manager v1.5.0 +Ethernet_Manager v1.6.0 DoubleResetDetector_Generic v1.4.0 [EWS] =========== USE_ETHERNET =========== [EWS] Default SPI pinout: @@ -3128,7 +3268,7 @@ esp32-sniffer/12345678/ble ``` Start MQTT_ThingStream_Ethernet_RP2040 on RASPBERRY_PI_PICO Ethernet Shield type : W5x00 using Ethernet Library -Ethernet_Manager v1.5.0 +Ethernet_Manager v1.6.0 DoubleResetDetector_Generic v1.4.0 [EWS] =========== USE_ETHERNET =========== [EWS] Default SPI pinout: @@ -3201,7 +3341,7 @@ This is the terminal output of an MBED RASPBERRY_PI_PICO board with W5500 Ethern ``` Start Ethernet_RP2040 on MBED RASPBERRY_PI_PICO Ethernet Shield type : W5x00 using EthernetLarge Library -Ethernet_Manager v1.5.0 +Ethernet_Manager v1.6.0 DoubleResetDetector_Generic v1.4.0 [EWS] =========== USE_ETHERNET_LARGE =========== [EWS] Default SPI pinout: @@ -3274,7 +3414,7 @@ HHHH[ETM] h:Updating LittleFS: /fs/etm_config.dat ``` Start Ethernet_RP2040 on MBED RASPBERRY_PI_PICO Ethernet Shield type : W5x00 using EthernetLarge Library -Ethernet_Manager v1.5.0 +Ethernet_Manager v1.6.0 DoubleResetDetector_Generic v1.4.0 [EWS] =========== USE_ETHERNET_LARGE =========== [EWS] Default SPI pinout: @@ -3344,7 +3484,7 @@ This is the terminal output of WT32-ETH01 board with LAN8720 Ethernet, running c Start MQTT_ThingStream_Ethernet_WT32_ETH01 on WT32-ETH01 Ethernet Shield type : ETH_PHY_LAN8720 WebServer_WT32_ETH01 v1.1.0 -Ethernet_Manager v1.5.0 +Ethernet_Manager v1.6.0 ESP_DoubleResetDetector v1.1.1 [ETM] Set CustomsStyle to : [ETM] Set CustomsHeadElement to : @@ -3417,6 +3557,52 @@ MQTT Message receive [esp32-sniffer/12345678/ble] Hello from MQTT_ThingStream on H ``` + +--- + +#### 9. QNEthernet_Teensy on TEENSY 4.1 using QNEthernet + +This is the terminal output of Teensy 4.1 board with built-in Ethernet, using QNEthernet Library, running [QNEthernet_Teensy](examples/QNEthernet_Teensy) example when **no doubleResetDetected**. + +``` +Starting QNEthernet_Teensy on TEENSY 4.1 using QNEthernet +Ethernet_Manager v1.6.0 +DoubleResetDetector_Generic v1.6.0 +[EWS] =========== USE_QN_ETHERNET =========== +QNEthernet using static IP + +EEPROM size = 4284, start = 0 +Flag read = 0xD0D04321 +No doubleResetDetected +SetFlag write = 0xD0D01234 +[ETM] Header= Teensy , BoardName= Teensy +[ETM] StaticIP= 192.168.2.232 +[ETM] CCSum=0x 77e ,RCSum=0x 77e +[ETM] Header= Teensy , BoardName= Teensy +[ETM] StaticIP= 192.168.2.232 +[ETM] ChkCrR:CrCCsum=0x 101b ,CrRCsum=0x 101b +[ETM] CrCCsum=0x 101b ,CrRCsum=0x 101b +[ETM] Valid Stored Dynamic Data +[ETM] ======= Start Stored Config Data ======= +[ETM] Header= Teensy , BoardName= Teensy +[ETM] StaticIP= 192.168.2.232 +[ETM] Start connectEthernet using Static IP = 192.168.2.232 +[ETM] IP: 192.168.2.222 +[ETM] begin:Ethernet Connected. +Connected! IP address: 192.168.2.222 + +Your stored Credentials : +MQTT Server = mqtt_server +Port = 1883 +MQTT UserName = mqtt_user +MQTT PWD = mqtt_pwd +Subs Topics = Subs +Pubs Topics = Pubs +Stop doubleResetDetecting +ClearFlag write = 0xD0D04321 +HHHH +``` + --- --- @@ -3448,6 +3634,11 @@ Sometimes, the library will only work if you update the board core to the latest ## Releases +### Major Releases v1.6.0 + +1. Add support to [QNEthernet Library](https://github.com/ssilverman/QNEthernet) for Teensy 4.1 built-in Ethernet +2. Update examples with new features + ### Major Releases v1.5.0 1. Add support to ESP32-based WT32-ETH01 (ESP32 + LAN8720) boards, using EEPROM, SPIFFS or LittleFS @@ -3489,6 +3680,7 @@ Sometimes, the library will only work if you update the board core to the latest 2. Provide support to W5x00, ENC28J60 and Teensy 4.1 NativeEthernet. 3. Supporting Ethernet, EthernetLarge, Ethernet2, Ethernet3, EthernetENC, UIPEthernet and Teensy NativeEthernet Libraries +--- --- #### Supported Boards @@ -3515,12 +3707,15 @@ This [**Ethernet_Manager** library](https://github.com/khoih-prog/Ethernet_Manag 11. **WT32_ETH01 boards** using ESP32-based boards and LAN8720 Ethernet +--- + #### Supported Ethernet shields/modules: 1. W5x00 using [`Ethernet`](https://www.arduino.cc/en/Reference/Ethernet), [`EthernetLarge`](https://github.com/OPEnSLab-OSU/EthernetLarge), [`Ethernet2`](https://github.com/adafruit/Ethernet2) or [`Ethernet3`](https://github.com/sstaub/Ethernet3) library 2. ENC28J60 using [`EthernetENC`](https://github.com/jandrassy/EthernetENC) or [`UIPEthernet`](https://github.com/UIPEthernet/UIPEthernet) library -3. Teensy 4.1 NativeEthernet using [`NativeEthernet Library version stable111+`](https://github.com/vjmuzik/NativeEthernet). +3. Teensy 4.1 built-in Ethernet using [`NativeEthernet`](https://github.com/vjmuzik/NativeEthernet) library 4. LAN8720 Ethernet used in WT32_ETH01 boards +5. Teensy 4.1 built-in Ethernet using [`QNEthernet`](https://github.com/ssilverman/QNEthernet) library --- --- @@ -3568,7 +3763,7 @@ Default Credentials and dynamic parameters 24. Add support to RP2040-based boards, such as **Nano RP2040 Connect**, using [**Arduino mbed OS for Nano boards**](https://github.com/arduino/ArduinoCore-mbed) and LittleFS. 25. Add support to RP2040-based boards, such as **RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040**, using [**Arduino-mbed RP2040** v2.1.0+ core](https://github.com/arduino/ArduinoCore-mbed) and LittleFS. 26. Add support to **WT32_ETH01 boards** using ESP32-based boards and LAN8720 Ethernet - +27. Add support to Teensy 4.1 built-in Ethernet using [`QNEthernet`](https://github.com/ssilverman/QNEthernet) library --- --- diff --git a/examples/AM2315_Ethernet/AM2315_Ethernet.ino b/examples/AM2315_Ethernet/AM2315_Ethernet.ino index b22606af..04aaea79 100644 --- a/examples/AM2315_Ethernet/AM2315_Ethernet.ino +++ b/examples/AM2315_Ethernet/AM2315_Ethernet.ino @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager Licensed under MIT license - Version: 1.5.0 + Version: 1.6.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 *****************************************************************************************************************************/ #include "defines.h" diff --git a/examples/Ethernet_Generic/Ethernet_Generic.ino b/examples/Ethernet_Generic/Ethernet_Generic.ino index 039e1ba9..657af19a 100644 --- a/examples/Ethernet_Generic/Ethernet_Generic.ino +++ b/examples/Ethernet_Generic/Ethernet_Generic.ino @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager Licensed under MIT license - Version: 1.5.0 + Version: 1.6.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 *****************************************************************************************************************************/ #include "defines.h" diff --git a/examples/Ethernet_RP2040/Ethernet_RP2040.ino b/examples/Ethernet_RP2040/Ethernet_RP2040.ino index bbb512cf..36f1356a 100644 --- a/examples/Ethernet_RP2040/Ethernet_RP2040.ino +++ b/examples/Ethernet_RP2040/Ethernet_RP2040.ino @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager Licensed under MIT license - Version: 1.5.0 + Version: 1.6.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 *****************************************************************************************************************************/ #include "defines.h" diff --git a/examples/Ethernet_SAMD/Ethernet_SAMD.ino b/examples/Ethernet_SAMD/Ethernet_SAMD.ino index 6e9fef68..71ed03bc 100644 --- a/examples/Ethernet_SAMD/Ethernet_SAMD.ino +++ b/examples/Ethernet_SAMD/Ethernet_SAMD.ino @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager Licensed under MIT license - Version: 1.5.0 + Version: 1.6.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 *****************************************************************************************************************************/ #include "defines.h" diff --git a/examples/Ethernet_SAM_DUE/Ethernet_SAM_DUE.ino b/examples/Ethernet_SAM_DUE/Ethernet_SAM_DUE.ino index b3991233..bc3e0dab 100644 --- a/examples/Ethernet_SAM_DUE/Ethernet_SAM_DUE.ino +++ b/examples/Ethernet_SAM_DUE/Ethernet_SAM_DUE.ino @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager Licensed under MIT license - Version: 1.5.0 + Version: 1.6.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 *****************************************************************************************************************************/ #include "defines.h" diff --git a/examples/Ethernet_Teensy/Ethernet_Teensy.ino b/examples/Ethernet_Teensy/Ethernet_Teensy.ino index e79dc8d6..d99bcb36 100644 --- a/examples/Ethernet_Teensy/Ethernet_Teensy.ino +++ b/examples/Ethernet_Teensy/Ethernet_Teensy.ino @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager Licensed under MIT license - Version: 1.5.0 + Version: 1.6.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 *****************************************************************************************************************************/ #include "defines.h" diff --git a/examples/Ethernet_WT32_ETH01/Ethernet_WT32_ETH01.ino b/examples/Ethernet_WT32_ETH01/Ethernet_WT32_ETH01.ino index a52abaa5..f059ffee 100644 --- a/examples/Ethernet_WT32_ETH01/Ethernet_WT32_ETH01.ino +++ b/examples/Ethernet_WT32_ETH01/Ethernet_WT32_ETH01.ino @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager Licensed under MIT license - Version: 1.5.0 + Version: 1.6.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 *****************************************************************************************************************************/ #include "defines.h" diff --git a/examples/Ethernet_nRF52/Ethernet_nRF52.ino b/examples/Ethernet_nRF52/Ethernet_nRF52.ino index 1763b74a..01cdda63 100644 --- a/examples/Ethernet_nRF52/Ethernet_nRF52.ino +++ b/examples/Ethernet_nRF52/Ethernet_nRF52.ino @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager Licensed under MIT license - Version: 1.5.0 + Version: 1.6.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 *****************************************************************************************************************************/ #include "defines.h" 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 ee98bc1f..67a9b6b0 100644 --- a/examples/MQTT_ThingStream_Ethernet_Generic/MQTT_ThingStream_Ethernet_Generic.ino +++ b/examples/MQTT_ThingStream_Ethernet_Generic/MQTT_ThingStream_Ethernet_Generic.ino @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager Licensed under MIT license - Version: 1.5.0 + Version: 1.6.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 *****************************************************************************************************************************/ #include "defines.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 46d6927b..16cbc450 100644 --- a/examples/MQTT_ThingStream_Ethernet_RP2040/MQTT_ThingStream_Ethernet_RP2040.ino +++ b/examples/MQTT_ThingStream_Ethernet_RP2040/MQTT_ThingStream_Ethernet_RP2040.ino @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager Licensed under MIT license - Version: 1.5.0 + Version: 1.6.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 *****************************************************************************************************************************/ #include "defines.h" 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 4a1b4127..d4f8324c 100644 --- a/examples/MQTT_ThingStream_Ethernet_SAMD/MQTT_ThingStream_Ethernet_SAMD.ino +++ b/examples/MQTT_ThingStream_Ethernet_SAMD/MQTT_ThingStream_Ethernet_SAMD.ino @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager Licensed under MIT license - Version: 1.5.0 + Version: 1.6.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 *****************************************************************************************************************************/ #include "defines.h" 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 7e2f95ee..fbc72af6 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 @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager Licensed under MIT license - Version: 1.5.0 + Version: 1.6.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 *****************************************************************************************************************************/ #include "defines.h" 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 91c59e9b..76a9eebd 100644 --- a/examples/MQTT_ThingStream_Ethernet_Teensy/MQTT_ThingStream_Ethernet_Teensy.ino +++ b/examples/MQTT_ThingStream_Ethernet_Teensy/MQTT_ThingStream_Ethernet_Teensy.ino @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager Licensed under MIT license - Version: 1.5.0 + Version: 1.6.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 *****************************************************************************************************************************/ #include "defines.h" 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 ade9ba89..137af206 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 @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager Licensed under MIT license - Version: 1.5.0 + Version: 1.6.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 *****************************************************************************************************************************/ #include "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 dcc1a14a..c9c3dbad 100644 --- a/examples/MQTT_ThingStream_Ethernet_nRF52/MQTT_ThingStream_Ethernet_nRF52.ino +++ b/examples/MQTT_ThingStream_Ethernet_nRF52/MQTT_ThingStream_Ethernet_nRF52.ino @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager Licensed under MIT license - Version: 1.5.0 + Version: 1.6.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 *****************************************************************************************************************************/ #include "defines.h" diff --git a/examples/MQTT_ThingStream_QNEthernet_Teensy/Credentials.h b/examples/MQTT_ThingStream_QNEthernet_Teensy/Credentials.h new file mode 100644 index 00000000..2378f224 --- /dev/null +++ b/examples/MQTT_ThingStream_QNEthernet_Teensy/Credentials.h @@ -0,0 +1,67 @@ +/**************************************************************************************************************************** + Credentials.h + For W5x00, LAN8720 and ENC28J60 Ethernet shields. + + Ethernet_Manager is a library for nRF52, Teensy, STM32, SAM DUE and SAMD boards, with Ethernet W5x00, LAN8720 or ENC28J60 shields, + to enable easy configuration/reconfiguration of Credentials and autoconnect/autoreconnect of Ethernet. + AVR Mega is not supported. + + Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager + Licensed under MIT license + *****************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +#include "defines.h" + +/// Start Default Config Data ////////////////// + +/* +typedef struct Configuration +{ + char header [16]; + char static_IP [16]; + char board_name [24]; + int checkSum; +} Ethernet_Configuration; +*/ + +#define TO_LOAD_DEFAULT_CONFIG_DATA true + +#if TO_LOAD_DEFAULT_CONFIG_DATA + +bool LOAD_DEFAULT_CONFIG_DATA = false; + +Ethernet_Configuration defaultConfig = +{ + //char header[16], dummy, not used +#if USE_SSL + "Eth_SSL", +#else + "Eth_NonSSL", +#endif + + // char static_IP [16]; + //"192.168.2.230", + // Use dynamic DHCP IP + "", + //char board_name [24]; + "nRF52-Ethernet", + // terminate the list + //int checkSum, dummy, not used + 0 + /////////// End Default Config Data ///////////// +}; + +#else + +bool LOAD_DEFAULT_CONFIG_DATA = false; + +Ethernet_Configuration defaultConfig; + +#endif // TO_LOAD_DEFAULT_CONFIG_DATA + +/////////// End Default Config Data ///////////// + +#endif //Credentials_h diff --git a/examples/MQTT_ThingStream_QNEthernet_Teensy/MQTT_ThingStream_QNEthernet_Teensy.ino b/examples/MQTT_ThingStream_QNEthernet_Teensy/MQTT_ThingStream_QNEthernet_Teensy.ino new file mode 100644 index 00000000..e19c6163 --- /dev/null +++ b/examples/MQTT_ThingStream_QNEthernet_Teensy/MQTT_ThingStream_QNEthernet_Teensy.ino @@ -0,0 +1,339 @@ +/**************************************************************************************************************************** + MQTT_ThingStream_QNEthernet_Teensy.ino + For W5x00, LAN8720 and ENC28J60 Ethernet shields. + + Ethernet_Manager is a library for nRF52, Teensy, STM32, SAM DUE and SAMD boards, with Ethernet W5x00, LAN8720 or ENC28J60 shields, + to enable easy configuration/reconfiguration of Credentials and autoconnect/autoreconnect of Ethernet. + AVR Mega is not supported. + + Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager + Licensed under MIT license + + Version: 1.6.0 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.0 K Hoang 14/12/2020 Initial coding. + 1.1.0 K Hoang 17/12/2020 Add support to ESP32/ESP8266. Add MQTT related examples to demo dynamic parameter usage + 1.1.1 K Hoang 28/12/2020 Suppress all possible compiler warnings + 1.2.0 K Hoang 22/02/2021 Optimize code and use better FlashStorage_SAMD and FlashStorage_STM32. + Add customs HTML header feature. Fix bug. + 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO + 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core + 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 + *****************************************************************************************************************************/ + +#include "defines.h" +#include "Credentials.h" +#include "dynamicParams.h" + +///////////// Start MQTT ThingStream /////////////// +#include + +// GOT FROM ThingsStream! + +const char *MQTT_PREFIX_TOPIC = "esp32-sniffer/"; +const char *MQTT_ANNOUNCE_TOPIC = "/status"; +const char *MQTT_CONTROL_TOPIC = "/control"; +const char *MQTT_BLE_TOPIC = "/ble"; + +String topic = MQTT_PREFIX_TOPIC + String("12345678") + MQTT_BLE_TOPIC; +String subTopic = MQTT_PREFIX_TOPIC + String("12345678") + MQTT_BLE_TOPIC; + +//////////// End MQTT ThingStream /////////////// + +Ethernet_Manager ethernet_manager; + +IPAddress localEthernetIP; + + +///////////// Start MQTT ThingStream /////////////// + +void mqtt_receive_callback(char* topic, byte* payload, unsigned int length); + +unsigned long lastMsg = 0; + +// Initialize the SSL client library +// Arguments: EthernetClient, our trust anchors + + +EthernetClient ethClient; + +PubSubClient* client = NULL; + +/* + Called whenever a payload is received from a subscribed MQTT topic +*/ +void mqtt_receive_callback(char* topic, byte* payload, unsigned int length) +{ + Serial.print("\nMQTT Message receive ["); + Serial.print(topic); + Serial.print("] "); + + for (unsigned int i = 0; i < length; i++) + { + Serial.print((char)payload[i]); + } + + Serial.println(); +} + +void reconnect() +{ + // Loop until we're reconnected + while (!client->connected()) + { + Serial.print("Attempting MQTT connection to "); + Serial.println(MQTT_SERVER); + + // Attempt to connect + + int connect_status = client->connect(MQTT_CLIENT_ID, MQTT_USER, MQTT_PASS, topic.c_str(), 2, false, ""); + + if (connect_status) + { + Serial.println("...connected"); + + // Once connected, publish an announcement... + String data = "Hello from MQTTClient_SSL on " + String(BOARD_NAME); + + client->publish(topic.c_str(), data.c_str()); + + Serial.println("Published connection message successfully!"); + + Serial.print("Subcribed to: "); + Serial.println(subTopic); + + // ... and resubscribe + client->subscribe(subTopic.c_str()); + // for loopback testing + client->subscribe(topic.c_str()); + } + else + { + Serial.print("failed, rc="); + Serial.print(client->state()); + Serial.println(" try again in 5 seconds"); + + // Wait 5 seconds before retrying + delay(5000); + } + } +} + +///////////// End MQTT ThingStream /////////////// + + +void heartBeatPrint() +{ + static int num = 1; + + if (linkStatus) + { + Serial.print(F("H")); + } + else + Serial.print(F("F")); + + if (num == 80) + { + Serial.println(); + num = 1; + } + else if (num++ % 10 == 0) + { + Serial.print(F(" ")); + } +} + +void check_status() +{ + #define STATUS_CHECK_INTERVAL 10000L + + static unsigned long checkstatus_timeout = STATUS_CHECK_INTERVAL; + + // Send status report every STATUS_REPORT_INTERVAL (60) seconds: we don't need to send updates frequently if there is no status change. + if ((millis() > checkstatus_timeout)) + { + heartBeatPrint(); + checkstatus_timeout = millis() + STATUS_CHECK_INTERVAL; + } +} + +#if USING_CUSTOMS_STYLE +const char NewCustomsStyle[] /*PROGMEM*/ = ""; +#endif + +void setup() +{ + // Debug console + Serial.begin(115200); + while (!Serial); + + Serial.print("\nStarting MQTT_ThingStream_QNEthernet_Teensy on "); Serial.print(BOARD_NAME); + Serial.print(" " ); Serial.println(SHIELD_TYPE); + Serial.println(ETHERNET_MANAGER_VERSION); + Serial.println(DOUBLERESETDETECTOR_GENERIC_VERSION); + +#if USE_NATIVE_ETHERNET + ET_LOGWARN(F("======== USE_NATIVE_ETHERNET ========")); +#elif USE_QN_ETHERNET + ET_LOGWARN(F("=========== USE_QN_ETHERNET ===========")); +#else + ET_LOGWARN(F("=========================")); +#endif + +#if USE_NATIVE_ETHERNET + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + Serial.println(F("=========================")); + + Serial.print(F("Using mac index = ")); + Serial.println(index); + + Serial.print(F("Connected! IP address: ")); + Serial.println(Ethernet.localIP()); + +#else + + #if USING_DHCP + // Start the Ethernet connection, using DHCP + Serial.println("QNEthernet using DHCP"); + #else + // Start the Ethernet connection, using static IP + Serial.println("QNEthernet using static IP"); + #endif +#endif + + ////////////////////////////////////////////// + +#if USING_CUSTOMS_STYLE + ethernet_manager.setCustomsStyle(NewCustomsStyle); +#endif + +#if USING_CUSTOMS_HEAD_ELEMENT + ethernet_manager.setCustomsHeadElement(""); +#endif + +#if USING_CORS_FEATURE + ethernet_manager.setCORSHeader("Your Access-Control-Allow-Origin"); +#endif + + ethernet_manager.begin(); + + ////////////////////////////////////////////// + + localEthernetIP = Ethernet.localIP(); + + if ( (uint32_t) localEthernetIP != 0 ) + { + Serial.print(F("Connected! IP address: ")); + Serial.println(localEthernetIP); + } + else + { + Serial.println(F("Ethernet not Connected! Please check.")); + } + + Serial.println("***************************************"); + Serial.println(topic); + Serial.println("***************************************"); +} + +#if (USE_DYNAMIC_PARAMETERS) +void displayCredentials() +{ + Serial.println("\nYour stored Credentials :"); + + for (int i = 0; i < NUM_MENU_ITEMS; i++) + { + Serial.println(String(myMenuItems[i].displayName) + " = " + myMenuItems[i].pdata); + } +} + +void displayCredentialsOnce() +{ + static bool displayedCredentials = false; + + if (!displayedCredentials) + { + for (int i = 0; i < NUM_MENU_ITEMS; i++) + { + if (!strlen(myMenuItems[i].pdata)) + { + break; + } + + if ( i == (NUM_MENU_ITEMS - 1) ) + { + displayedCredentials = true; + displayCredentials(); + } + } + } +} +#endif + +#define MQTT_PUBLISH_INTERVAL_MS 20000L + +String data = "Hello from MQTT_ThingStream on " + String(BOARD_NAME) + " with " + String(SHIELD_TYPE); +const char *pubData = data.c_str(); + +void loop() +{ + static bool inConfigMode = true; + static unsigned long currentMillis; + + + inConfigMode = ethernet_manager.run(); + + if (!inConfigMode) + { + if (!client) + { + client = new PubSubClient(MQTT_SERVER, atoi(MQTT_PORT), mqtt_receive_callback, ethClient); + + // Note - the default maximum packet size is 256 bytes. If the + // combined length of clientId, username and password exceed this use the + // following to increase the buffer size: + //client->setBufferSize(256); + } + + if (!client->connected()) + { + reconnect(); + } + + // Sending Data + currentMillis = millis(); + + if (currentMillis - lastMsg > MQTT_PUBLISH_INTERVAL_MS) + { + lastMsg = currentMillis; + + if (!client->publish(topic.c_str(), pubData)) + { + Serial.println("Message failed to send."); + } + + Serial.print("\nMQTT Message Send : " + topic + " => "); + Serial.println(data); + } + + client->loop(); + + check_status(); + + #if (USE_DYNAMIC_PARAMETERS) + displayCredentialsOnce(); + #endif + } +} diff --git a/examples/MQTT_ThingStream_QNEthernet_Teensy/defines.h b/examples/MQTT_ThingStream_QNEthernet_Teensy/defines.h new file mode 100644 index 00000000..53f143c6 --- /dev/null +++ b/examples/MQTT_ThingStream_QNEthernet_Teensy/defines.h @@ -0,0 +1,116 @@ +/**************************************************************************************************************************** + defines.h + For W5x00, LAN8720 and ENC28J60 Ethernet shields. + + Ethernet_Manager is a library for nRF52, Teensy, STM32, SAM DUE and SAMD boards, with Ethernet W5x00, LAN8720 or ENC28J60 shields, + to enable easy configuration/reconfiguration of Credentials and autoconnect/autoreconnect of Ethernet. + AVR Mega is not supported. + + Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager + Licensed under MIT license + *****************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#if ( defined(CORE_TEENSY) ) + // 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 +#else + #error This code is designed to run on Teensy platform! 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_ 2 +#define _ETHERNET_MANAGER_LOGLEVEL_ 2 + +#define DRD_GENERIC_DEBUG true + +// Default pin 10 to SS/CS +#define USE_THIS_SS_PIN 10 + +#if ( defined(CORE_TEENSY) && defined(__IMXRT1062__) && defined(ARDUINO_TEENSY41) ) + // For Teensy 4.1 + #define BOARD_TYPE "TEENSY 4.1" + // Use true for NativeEthernet Library, false if using other Ethernet libraries + #define USE_NATIVE_ETHERNET false + #define USE_QN_ETHERNET true +#else + #error Only Teensy 4.1 supported +#endif + +#ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE +#endif + +#define USE_ETHERNET_WRAPPER false + +// 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 false +#define USE_ETHERNET false +#define USE_ETHERNET2 false +#define USE_ETHERNET3 false +#define USE_ETHERNET_LARGE false +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_CUSTOM_ETHERNET false + +#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 "using NativeEthernet" +#elif USE_QN_ETHERNET + #include "QNEthernet.h" // https://github.com/ssilverman/QNEthernet + using namespace qindesign::network; + #warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #define SHIELD_TYPE "using QNEthernet" +#endif + +////////////////////////////////////////// + +// EEPROM_START + CONFIG_DATA_SIZE must be <= EEPROM_SIZE +#define EEPROM_START 0 + +///////////////////////////////////////////// + +// Add customs headers from v1.2.0 +#define USING_CUSTOMS_STYLE true +#define USING_CUSTOMS_HEAD_ELEMENT true +#define USING_CORS_FEATURE true + +///////////////////////////////////////////// + +// Config Timeout 120s (default 60s) +#define CONFIG_TIMEOUT 120000L + +#define USE_DYNAMIC_PARAMETERS true + +////////////////////////////////////////// + +#define USING_DHCP false //true + +//#if !USING_DHCP + // Set the static IP address to use if the DHCP fails to assign + IPAddress myIP(192, 168, 2, 222); + IPAddress myNetmask(255, 255, 255, 0); + IPAddress myGW(192, 168, 2, 1); + //IPAddress mydnsServer(192, 168, 2, 1); + IPAddress mydnsServer(8, 8, 8, 8); +//#endif + +////////////////////////////////////////// + +#include + +#define ETHERNET_HOST_NAME "Teensy-QNEthernet" + +#endif //defines_h diff --git a/examples/MQTT_ThingStream_QNEthernet_Teensy/dynamicParams.h b/examples/MQTT_ThingStream_QNEthernet_Teensy/dynamicParams.h new file mode 100644 index 00000000..f23150da --- /dev/null +++ b/examples/MQTT_ThingStream_QNEthernet_Teensy/dynamicParams.h @@ -0,0 +1,72 @@ +/**************************************************************************************************************************** + dynamicParams.h + For W5x00, LAN8720 and ENC28J60 Ethernet shields. + + Ethernet_Manager is a library for nRF52, Teensy, STM32, SAM DUE and SAMD boards, with Ethernet W5x00, LAN8720 or ENC28J60 shields, + to enable easy configuration/reconfiguration of Credentials and autoconnect/autoreconnect of Ethernet. + AVR Mega is not supported. + + Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager + Licensed under MIT license + *****************************************************************************************************************************/ + +#ifndef dynamicParams_h +#define dynamicParams_h + +#include "defines.h" + +// USE_DYNAMIC_PARAMETERS defined in defined.h + +/////////////// Start dynamic Credentials /////////////// + +/************************************** + #define MAX_ID_LEN 5 + #define MAX_DISPLAY_NAME_LEN 16 + + typedef struct + { + char id [MAX_ID_LEN + 1]; + char displayName [MAX_DISPLAY_NAME_LEN + 1]; + char *pdata; + uint8_t maxlen; + } MenuItem; +**************************************/ + +#if USE_DYNAMIC_PARAMETERS + + #define MAX_MQTT_SERVER_LEN 48 + char MQTT_SERVER [MAX_MQTT_SERVER_LEN + 1] = "default-mqtt-server"; + + #define MAX_MQTT_PORT_LEN 6 + char MQTT_PORT [MAX_MQTT_PORT_LEN + 1] = "1883"; + + #define MAX_MQTT_USERNAME_LEN 34 + char MQTT_USER [MAX_MQTT_USERNAME_LEN + 1] = "default-mqtt-username"; + + #define MAX_MQTT_PW_LEN 48 + char MQTT_PASS [MAX_MQTT_PW_LEN + 1] = "default-mqtt-password"; + + #define MAX_MQTT_CLIENT_ID 48 + char MQTT_CLIENT_ID [MAX_MQTT_CLIENT_ID + 1] = "default-mqtt-clientID"; + + MenuItem myMenuItems [] = + { + { "mqtt", "MQTT Server", MQTT_SERVER, MAX_MQTT_SERVER_LEN }, + { "mqpt", "Port", MQTT_PORT, MAX_MQTT_PORT_LEN }, + { "user", "MQTT UserName", MQTT_USER, MAX_MQTT_USERNAME_LEN }, + { "mqpw", "MQTT PWD", MQTT_PASS, MAX_MQTT_PW_LEN }, + { "clid", "Client ID", MQTT_CLIENT_ID, MAX_MQTT_CLIENT_ID }, + }; + + uint16_t NUM_MENU_ITEMS = sizeof(myMenuItems) / sizeof(MenuItem); //MenuItemSize; + +#else + + MenuItem myMenuItems [] = {}; + + uint16_t NUM_MENU_ITEMS = 0; +#endif + +/////// // End dynamic Credentials /////////// + +#endif //dynamicParams_h diff --git a/examples/QNEthernet_Teensy/Credentials.h b/examples/QNEthernet_Teensy/Credentials.h new file mode 100644 index 00000000..b6ecdeaf --- /dev/null +++ b/examples/QNEthernet_Teensy/Credentials.h @@ -0,0 +1,67 @@ +/**************************************************************************************************************************** + Credentials.h + For W5x00, LAN8720 and ENC28J60 Ethernet shields. + + Ethernet_Manager is a library for nRF52, Teensy, STM32, SAM DUE and SAMD boards, with Ethernet W5x00, LAN8720 or ENC28J60 shields, + to enable easy configuration/reconfiguration of Credentials and autoconnect/autoreconnect of Ethernet. + AVR Mega is not supported. + + Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager + Licensed under MIT license + *****************************************************************************************************************************/ + +#ifndef Credentials_h +#define Credentials_h + +#include "defines.h" + +/// Start Default Config Data ////////////////// + +/* +typedef struct Configuration +{ + char header [16]; + char static_IP [16]; + char board_name [24]; + int checkSum; +} Ethernet_Configuration; +*/ + +#define TO_LOAD_DEFAULT_CONFIG_DATA true + +#if TO_LOAD_DEFAULT_CONFIG_DATA + +bool LOAD_DEFAULT_CONFIG_DATA = false; + +Ethernet_Configuration defaultConfig = +{ + //char header[16], dummy, not used +#if USE_SSL + "Eth_SSL", +#else + "Eth_NonSSL", +#endif + + // char static_IP [16]; + //"192.168.2.230", + // Use dynamic DHCP IP + "", + //char board_name [24]; + "Teensy-Ethernet", + // terminate the list + //int checkSum, dummy, not used + 0 + /////////// End Default Config Data ///////////// +}; + +#else + +bool LOAD_DEFAULT_CONFIG_DATA = false; + +Ethernet_Configuration defaultConfig; + +#endif // TO_LOAD_DEFAULT_CONFIG_DATA + +/////////// End Default Config Data ///////////// + +#endif //Credentials_h diff --git a/examples/QNEthernet_Teensy/QNEthernet_Teensy.ino b/examples/QNEthernet_Teensy/QNEthernet_Teensy.ino new file mode 100644 index 00000000..476a4623 --- /dev/null +++ b/examples/QNEthernet_Teensy/QNEthernet_Teensy.ino @@ -0,0 +1,197 @@ +/**************************************************************************************************************************** + QNEthernet_Teensy.ino + For W5x00, LAN8720 and ENC28J60 Ethernet shields. + + Ethernet_Manager is a library for nRF52, Teensy, STM32, SAM DUE and SAMD boards, with Ethernet W5x00, LAN8720 or ENC28J60 shields, + to enable easy configuration/reconfiguration of Credentials and autoconnect/autoreconnect of Ethernet. + AVR Mega is not supported. + + Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager + Licensed under MIT license + + Version: 1.6.0 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.0 K Hoang 14/12/2020 Initial coding. + 1.1.0 K Hoang 17/12/2020 Add support to ESP32/ESP8266. Add MQTT related examples to demo dynamic parameter usage + 1.1.1 K Hoang 28/12/2020 Suppress all possible compiler warnings + 1.2.0 K Hoang 22/02/2021 Optimize code and use better FlashStorage_SAMD and FlashStorage_STM32. + Add customs HTML header feature. Fix bug. + 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO + 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core + 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 + *****************************************************************************************************************************/ + +#include "defines.h" +#include "Credentials.h" +#include "dynamicParams.h" + +Ethernet_Manager ethernet_manager; + +IPAddress localEthernetIP; + +void heartBeatPrint() +{ + static int num = 1; + + if (linkStatus) + { + Serial.print(F("H")); + } + else + Serial.print(F("F")); + + if (num == 80) + { + Serial.println(); + num = 1; + } + else if (num++ % 10 == 0) + { + Serial.print(F(" ")); + } +} + +void check_status() +{ + #define STATUS_CHECK_INTERVAL 10000L + + static unsigned long checkstatus_timeout = STATUS_CHECK_INTERVAL; + + // Send status report every STATUS_REPORT_INTERVAL (60) seconds: we don't need to send updates frequently if there is no status change. + if ((millis() > checkstatus_timeout)) + { + heartBeatPrint(); + checkstatus_timeout = millis() + STATUS_CHECK_INTERVAL; + } +} + +#if USING_CUSTOMS_STYLE +const char NewCustomsStyle[] /*PROGMEM*/ = ""; +#endif + +void setup() +{ + // Debug console + Serial.begin(115200); + while (!Serial); + + Serial.print("\nStarting QNEthernet_Teensy on "); Serial.print(BOARD_NAME); + Serial.print(" " ); Serial.println(SHIELD_TYPE); + Serial.println(ETHERNET_MANAGER_VERSION); + Serial.println(DOUBLERESETDETECTOR_GENERIC_VERSION); + +#if USE_NATIVE_ETHERNET + ET_LOGWARN(F("======== USE_NATIVE_ETHERNET ========")); +#elif USE_QN_ETHERNET + ET_LOGWARN(F("=========== USE_QN_ETHERNET ===========")); +#else + ET_LOGWARN(F("=========================")); +#endif + +#if USE_NATIVE_ETHERNET + + // start the ethernet connection and the server: + // Use DHCP dynamic IP and random mac + uint16_t index = millis() % NUMBER_OF_MAC; + // Use Static IP + //Ethernet.begin(mac[index], ip); + Ethernet.begin(mac[index]); + + Serial.println(F("=========================")); + + Serial.print(F("Using mac index = ")); + Serial.println(index); + + Serial.print(F("Connected! IP address: ")); + Serial.println(Ethernet.localIP()); + +#else + + #if USING_DHCP + // Start the Ethernet connection, using DHCP + Serial.println("QNEthernet using DHCP"); + #else + // Start the Ethernet connection, using static IP + Serial.println("QNEthernet using static IP"); + #endif +#endif + + ////////////////////////////////////////////// + +#if USING_CUSTOMS_STYLE + ethernet_manager.setCustomsStyle(NewCustomsStyle); +#endif + +#if USING_CUSTOMS_HEAD_ELEMENT + ethernet_manager.setCustomsHeadElement(""); +#endif + +#if USING_CORS_FEATURE + ethernet_manager.setCORSHeader("Your Access-Control-Allow-Origin"); +#endif + + ethernet_manager.begin(); + + ////////////////////////////////////////////// + + localEthernetIP = Ethernet.localIP(); + + if ( (uint32_t) localEthernetIP != 0 ) + { + Serial.print(F("Connected! IP address: ")); + Serial.println(localEthernetIP); + } + else + { + Serial.println(F("Ethernet not Connected! Please check.")); + } +} + +#if (USE_DYNAMIC_PARAMETERS) +void displayCredentials() +{ + Serial.println("\nYour stored Credentials :"); + + for (int i = 0; i < NUM_MENU_ITEMS; i++) + { + Serial.println(String(myMenuItems[i].displayName) + " = " + myMenuItems[i].pdata); + } +} + +void displayCredentialsOnce() +{ + static bool displayedCredentials = false; + + if (!displayedCredentials) + { + for (int i = 0; i < NUM_MENU_ITEMS; i++) + { + if (!strlen(myMenuItems[i].pdata)) + { + break; + } + + if ( i == (NUM_MENU_ITEMS - 1) ) + { + displayedCredentials = true; + displayCredentials(); + } + } + } +} +#endif + +void loop() +{ + ethernet_manager.run(); + + check_status(); + +#if (USE_DYNAMIC_PARAMETERS) + displayCredentialsOnce(); +#endif +} diff --git a/examples/QNEthernet_Teensy/defines.h b/examples/QNEthernet_Teensy/defines.h new file mode 100644 index 00000000..53f143c6 --- /dev/null +++ b/examples/QNEthernet_Teensy/defines.h @@ -0,0 +1,116 @@ +/**************************************************************************************************************************** + defines.h + For W5x00, LAN8720 and ENC28J60 Ethernet shields. + + Ethernet_Manager is a library for nRF52, Teensy, STM32, SAM DUE and SAMD boards, with Ethernet W5x00, LAN8720 or ENC28J60 shields, + to enable easy configuration/reconfiguration of Credentials and autoconnect/autoreconnect of Ethernet. + AVR Mega is not supported. + + Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager + Licensed under MIT license + *****************************************************************************************************************************/ + +#ifndef defines_h +#define defines_h + +#if ( defined(CORE_TEENSY) ) + // 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 +#else + #error This code is designed to run on Teensy platform! 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_ 2 +#define _ETHERNET_MANAGER_LOGLEVEL_ 2 + +#define DRD_GENERIC_DEBUG true + +// Default pin 10 to SS/CS +#define USE_THIS_SS_PIN 10 + +#if ( defined(CORE_TEENSY) && defined(__IMXRT1062__) && defined(ARDUINO_TEENSY41) ) + // For Teensy 4.1 + #define BOARD_TYPE "TEENSY 4.1" + // Use true for NativeEthernet Library, false if using other Ethernet libraries + #define USE_NATIVE_ETHERNET false + #define USE_QN_ETHERNET true +#else + #error Only Teensy 4.1 supported +#endif + +#ifndef BOARD_NAME + #define BOARD_NAME BOARD_TYPE +#endif + +#define USE_ETHERNET_WRAPPER false + +// 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 false +#define USE_ETHERNET false +#define USE_ETHERNET2 false +#define USE_ETHERNET3 false +#define USE_ETHERNET_LARGE false +#define USE_ETHERNET_ESP8266 false +#define USE_ETHERNET_ENC false +#define USE_CUSTOM_ETHERNET false + +#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 "using NativeEthernet" +#elif USE_QN_ETHERNET + #include "QNEthernet.h" // https://github.com/ssilverman/QNEthernet + using namespace qindesign::network; + #warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #define SHIELD_TYPE "using QNEthernet" +#endif + +////////////////////////////////////////// + +// EEPROM_START + CONFIG_DATA_SIZE must be <= EEPROM_SIZE +#define EEPROM_START 0 + +///////////////////////////////////////////// + +// Add customs headers from v1.2.0 +#define USING_CUSTOMS_STYLE true +#define USING_CUSTOMS_HEAD_ELEMENT true +#define USING_CORS_FEATURE true + +///////////////////////////////////////////// + +// Config Timeout 120s (default 60s) +#define CONFIG_TIMEOUT 120000L + +#define USE_DYNAMIC_PARAMETERS true + +////////////////////////////////////////// + +#define USING_DHCP false //true + +//#if !USING_DHCP + // Set the static IP address to use if the DHCP fails to assign + IPAddress myIP(192, 168, 2, 222); + IPAddress myNetmask(255, 255, 255, 0); + IPAddress myGW(192, 168, 2, 1); + //IPAddress mydnsServer(192, 168, 2, 1); + IPAddress mydnsServer(8, 8, 8, 8); +//#endif + +////////////////////////////////////////// + +#include + +#define ETHERNET_HOST_NAME "Teensy-QNEthernet" + +#endif //defines_h diff --git a/examples/QNEthernet_Teensy/dynamicParams.h b/examples/QNEthernet_Teensy/dynamicParams.h new file mode 100644 index 00000000..c1486b08 --- /dev/null +++ b/examples/QNEthernet_Teensy/dynamicParams.h @@ -0,0 +1,76 @@ +/**************************************************************************************************************************** + dynamicParams.h + For W5x00, LAN8720 and ENC28J60 Ethernet shields. + + Ethernet_Manager is a library for nRF52, Teensy, STM32, SAM DUE and SAMD boards, with Ethernet W5x00, LAN8720 or ENC28J60 shields, + to enable easy configuration/reconfiguration of Credentials and autoconnect/autoreconnect of Ethernet. + AVR Mega is not supported. + + Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager + Licensed under MIT license + *****************************************************************************************************************************/ + +#ifndef dynamicParams_h +#define dynamicParams_h + +#include "defines.h" + +// USE_DYNAMIC_PARAMETERS defined in defined.h + +/////////////// Start dynamic Credentials /////////////// + +/************************************** + #define MAX_ID_LEN 5 + #define MAX_DISPLAY_NAME_LEN 16 + + typedef struct + { + char id [MAX_ID_LEN + 1]; + char displayName [MAX_DISPLAY_NAME_LEN + 1]; + char *pdata; + uint8_t maxlen; + } MenuItem; +**************************************/ + +#if USE_DYNAMIC_PARAMETERS + + #define MAX_MQTT_SERVER_LEN 34 + char MQTT_Server [MAX_MQTT_SERVER_LEN + 1] = "default-mqtt-server"; + + #define MAX_MQTT_PORT_LEN 6 + char MQTT_Port [MAX_MQTT_PORT_LEN + 1] = "1883"; + + #define MAX_MQTT_USERNAME_LEN 34 + char MQTT_UserName [MAX_MQTT_USERNAME_LEN + 1] = "default-mqtt-username"; + + #define MAX_MQTT_PW_LEN 34 + char MQTT_PW [MAX_MQTT_PW_LEN + 1] = "default-mqtt-password"; + + #define MAX_MQTT_SUBS_TOPIC_LEN 34 + char MQTT_SubsTopic [MAX_MQTT_SUBS_TOPIC_LEN + 1] = "default-mqtt-SubTopic"; + + #define MAX_MQTT_PUB_TOPIC_LEN 34 + char MQTT_PubTopic [MAX_MQTT_PUB_TOPIC_LEN + 1] = "default-mqtt-PubTopic"; + + MenuItem myMenuItems [] = + { + { "mqtt", "MQTT Server", MQTT_Server, MAX_MQTT_SERVER_LEN }, + { "mqpt", "Port", MQTT_Port, MAX_MQTT_PORT_LEN }, + { "user", "MQTT UserName", MQTT_UserName, MAX_MQTT_USERNAME_LEN }, + { "mqpw", "MQTT PWD", MQTT_PW, MAX_MQTT_PW_LEN }, + { "subs", "Subs Topics", MQTT_SubsTopic, MAX_MQTT_SUBS_TOPIC_LEN }, + { "pubs", "Pubs Topics", MQTT_PubTopic, MAX_MQTT_PUB_TOPIC_LEN }, + }; + + uint16_t NUM_MENU_ITEMS = sizeof(myMenuItems) / sizeof(MenuItem); //MenuItemSize; + +#else + + MenuItem myMenuItems [] = {}; + + uint16_t NUM_MENU_ITEMS = 0; +#endif + +/////// // End dynamic Credentials /////////// + +#endif //dynamicParams_h diff --git a/library.json b/library.json index 3965b76f..6b5ee152 100644 --- a/library.json +++ b/library.json @@ -1,8 +1,8 @@ { "name": "Ethernet_Manager", - "version": "1.5.0", - "description": "Simple Ethernet Manager for Teensy, SAM DUE, SAMD, nRF52, ESP32 (including ESP32-S2/C3), ESP8266, RP2040-based Nano_RP2040_Connect, RASPBERRY_PI_PICO, etc. boards. Config data saved in ESP LittleFS, SPIFFS or EEPROM, nRF52 LittleFS, EEPROM, DueFlashStorage or SAMD FlashStorage. For configuring/auto(re)connecting Ethernet W5x00, ENC28J60 and NativeEthernet at runtime. Use much less memory compared to full-fledge WiFiManager. Config Portal (CP) will be auto-adjusted to match the number of dynamic custom parameters. Optional default Credentials to be autoloaded into CP to use or change instead of manually input. Credentials are saved in LittleFS, (emulated-)EEPROM, FlashStorage_SAMD or DueFlashStorage. New powerful-yet-simple-to-use feature to enable adding dynamic parameters from sketch and input using the same CP. DoubleDetectDetector as well as Virtual Switches feature permits entering CP as requested. Configurable HTML Headers, including Customs Style, Head Elements, CORS Header", - "keywords": "communication, ethernet, esp8266, esp32, esp32-s2, esp32-c3, rpi-pico, rp2040, nano-rp2040-connect, W5x00, ENC28J60, lan8720, SAM DUE, SAMD, STM32, nRF52, Credentials, config-portal, WT32-ETH01, Double-Reset, MQTT, SAMD51, DynamicParameters, dynamic-params, customs-header, Manager", + "version": "1.6.0", + "keywords": "communication, ethernet, esp8266, esp32, esp32-s2, esp32-c3, QNEthernet, rp2040, nano-rp2040-connect, W5x00, lan8720, SAM-DUE, SAMD, STM32, nRF52, Credentials, config-portal, WT32-ETH01, Double-Reset, MQTT, rpi-pico, ENC28J60, SAMD51, DynamicParameters, dynamic-params, customs-header, Manager", + "description": "Simple Ethernet Manager for Teensy, SAM DUE, SAMD, nRF52, ESP32 (including ESP32-S2/C3), ESP8266, RP2040-based Nano_RP2040_Connect, RASPBERRY_PI_PICO, etc. boards. Config data saved in ESP LittleFS, SPIFFS or EEPROM, nRF52 LittleFS, EEPROM, DueFlashStorage or SAMD FlashStorage. For configuring/auto(re)connecting Ethernet W5x00, ENC28J60 and NativeEthernet/QNEthernet at runtime. Use much less memory compared to full-fledge WiFiManager. Config Portal (CP) will be auto-adjusted to match the number of dynamic custom parameters. Optional default Credentials to be autoloaded into CP to use or change instead of manually input. Credentials are saved in LittleFS, (emulated-)EEPROM, FlashStorage_SAMD or DueFlashStorage. New powerful-yet-simple-to-use feature to enable adding dynamic parameters from sketch and input using the same CP. DoubleDetectDetector as well as Virtual Switches feature permits entering CP as requested. Configurable HTML Headers, Customs Style, Head Elements, CORS Header", "authors": { "name": "Khoi Hoang", @@ -65,6 +65,10 @@ "name": "DueFlashStorage", "version": "^1.0.0", "platforms": ["*"] + }, + { + "name": "QNEthernet", + "version": "https://github.com/ssilverman/QNEthernet" } ], "frameworks": "*", diff --git a/library.properties b/library.properties index 7f852ede..9d4d44e3 100644 --- a/library.properties +++ b/library.properties @@ -1,10 +1,10 @@ name=Ethernet_Manager -version=1.5.0 +version=1.6.0 author=Khoi Hoang license=MIT maintainer=Khoi Hoang -sentence=Simple Ethernet Manager for Teensy, SAM DUE, SAMD21, SAMD51, nRF52, ESP32 (including ESP32-S2, ESP32-C3, WT32-ETH01), ESP8266, RP2040-based Nano_RP2040_Connect, RASPBERRY_PI_PICO, etc. boards, with or without SSL, configuration data saved in ESP8266/ESP32 LittleFS, SPIFFS or EEPROM, nRF52/RP2040 LittleFS/InternalFS, EEPROM, DueFlashStorage or FlashStorage_SAMD. -paragraph=Library for configuring/auto(re)connecting Ethernet W5100/W5200/W5500, ENC28J60 and Teensy 4.1 NativeEthernet at runtime. Use much less memory compared to full-fledge WiFiManager. Config Portal will be auto-adjusted to match the number of dynamic custom parameters. Optional default Credentials to be autoloaded into Config Portal to use or change instead of manually input. Credentials are saved in LittleFS/InternalFS, (emulated-)EEPROM, FlashStorage_SAMD or DueFlashStorage. New powerful-yet-simple-to-use feature to enable adding dynamic custom parameters from sketch and input using the same Config Portal. DoubleDetectDetector as well as Virtual Switches feature permits entering Config Portal as requested. Configurable Customs HTML Headers, including Customs Style, Customs Head Elements, CORS Header. +sentence=Simple Ethernet Manager for Teensy, SAM DUE, SAMD, nRF52, ESP32 (including ESP32-S2/C3), ESP8266, RP2040-based Nano_RP2040_Connect, RASPBERRY_PI_PICO, etc. boards. Config data saved in ESP LittleFS, SPIFFS or EEPROM, nRF52 LittleFS, EEPROM, DueFlashStorage or SAMD FlashStorage. +paragraph=Library for configuring/auto(re)connecting Ethernet W5100/W5200/W5500, ENC28J60 and Teensy 4.1 NativeEthernet/QNEthernet at runtime. Use much less memory compared to full-fledge WiFiManager. Config Portal will be auto-adjusted to match the number of dynamic custom parameters. Optional default Credentials to be autoloaded into Config Portal to use or change instead of manually input. Credentials are saved in LittleFS/InternalFS, (emulated-)EEPROM, FlashStorage_SAMD or DueFlashStorage. New powerful-yet-simple-to-use feature to enable adding dynamic custom parameters from sketch and input using the same Config Portal. DoubleDetectDetector as well as Virtual Switches feature permits entering Config Portal as requested. Configurable Customs HTML Headers, including Customs Style, Customs Head Elements, CORS Header. category=Communication url=https://github.com/khoih-prog/Ethernet_Manager architectures=* diff --git a/platformio/platformio.ini b/platformio/platformio.ini index 05916480..cb410861 100644 --- a/platformio/platformio.ini +++ b/platformio/platformio.ini @@ -37,6 +37,7 @@ lib_deps = Functional-Vlpp@>=1.0.2 FlashStorage_SAMD@>=1.1.0 WebServer_WT32_ETH01@>=1.1.0 + https://github.com/ssilverman/QNEthernet ; PlatformIO 5.x ; khoih-prog/EthernetWebServer@>=1.5.0 ; khoih.prog/ESP_DoubleResetDetector@>=1.1.1 @@ -44,6 +45,7 @@ lib_deps = ; khoih-prog/Functional-Vlpp@>=1.0.2 ; khoih.prog/FlashStorage_SAMD@>=1.1.0 ; khoih.prog/WebServer_WT32_ETH01@>=1.1.0 +; https://github.com/ssilverman/QNEthernet build_flags = ; set your debug output (default=Serial) diff --git a/src/Adapters/Ethernet_DUE_Manager.h b/src/Adapters/Ethernet_DUE_Manager.h index ce0418fc..e58cd21a 100644 --- a/src/Adapters/Ethernet_DUE_Manager.h +++ b/src/Adapters/Ethernet_DUE_Manager.h @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager Licensed under MIT license - Version: 1.5.0 + Version: 1.6.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 *****************************************************************************************************************************/ #pragma once diff --git a/src/Adapters/Ethernet_ESP32_Manager.h b/src/Adapters/Ethernet_ESP32_Manager.h index 6459b9d9..86b37c85 100644 --- a/src/Adapters/Ethernet_ESP32_Manager.h +++ b/src/Adapters/Ethernet_ESP32_Manager.h @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager Licensed under MIT license - Version: 1.5.0 + Version: 1.6.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 *****************************************************************************************************************************/ #pragma once diff --git a/src/Adapters/Ethernet_ESP8266_Manager.h b/src/Adapters/Ethernet_ESP8266_Manager.h index 9433ea49..bd3834f3 100644 --- a/src/Adapters/Ethernet_ESP8266_Manager.h +++ b/src/Adapters/Ethernet_ESP8266_Manager.h @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager Licensed under MIT license - Version: 1.5.0 + Version: 1.6.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 *****************************************************************************************************************************/ #pragma once diff --git a/src/Adapters/Ethernet_MBED_RP2040_Manager.h b/src/Adapters/Ethernet_MBED_RP2040_Manager.h index 362774a9..d8b9916a 100644 --- a/src/Adapters/Ethernet_MBED_RP2040_Manager.h +++ b/src/Adapters/Ethernet_MBED_RP2040_Manager.h @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager Licensed under MIT license - Version: 1.5.0 + Version: 1.6.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 *****************************************************************************************************************************/ #pragma once diff --git a/src/Adapters/Ethernet_NRF52_Manager.h b/src/Adapters/Ethernet_NRF52_Manager.h index 5f38e6e9..f6c87582 100644 --- a/src/Adapters/Ethernet_NRF52_Manager.h +++ b/src/Adapters/Ethernet_NRF52_Manager.h @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager Licensed under MIT license - Version: 1.5.0 + Version: 1.6.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 *****************************************************************************************************************************/ #pragma once diff --git a/src/Adapters/Ethernet_RP2040_Manager.h b/src/Adapters/Ethernet_RP2040_Manager.h index 45391458..a0d120fe 100644 --- a/src/Adapters/Ethernet_RP2040_Manager.h +++ b/src/Adapters/Ethernet_RP2040_Manager.h @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager Licensed under MIT license - Version: 1.5.0 + Version: 1.6.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 *****************************************************************************************************************************/ #pragma once diff --git a/src/Adapters/Ethernet_SAMD_Manager.h b/src/Adapters/Ethernet_SAMD_Manager.h index 3f533312..807ffadb 100644 --- a/src/Adapters/Ethernet_SAMD_Manager.h +++ b/src/Adapters/Ethernet_SAMD_Manager.h @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager Licensed under MIT license - Version: 1.5.0 + Version: 1.6.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 *****************************************************************************************************************************/ #pragma once diff --git a/src/Adapters/Ethernet_Teensy_Manager.h b/src/Adapters/Ethernet_Teensy_Manager.h index 58dc02b4..042955e7 100644 --- a/src/Adapters/Ethernet_Teensy_Manager.h +++ b/src/Adapters/Ethernet_Teensy_Manager.h @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager Licensed under MIT license - Version: 1.5.0 + Version: 1.6.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 *****************************************************************************************************************************/ #pragma once diff --git a/src/Adapters/Ethernet_WT32_ETH01_Manager.h b/src/Adapters/Ethernet_WT32_ETH01_Manager.h index 23f925de..a005748e 100644 --- a/src/Adapters/Ethernet_WT32_ETH01_Manager.h +++ b/src/Adapters/Ethernet_WT32_ETH01_Manager.h @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager Licensed under MIT license - Version: 1.5.0 + Version: 1.6.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 *****************************************************************************************************************************/ #pragma once diff --git a/src/Adapters/QNEthernet_Teensy_Manager.h b/src/Adapters/QNEthernet_Teensy_Manager.h new file mode 100644 index 00000000..4c643ea1 --- /dev/null +++ b/src/Adapters/QNEthernet_Teensy_Manager.h @@ -0,0 +1,1403 @@ +/**************************************************************************************************************************** + QNEthernet_Teensy_Manager.h + For Teensy 4.1 built-in Ethernet using QNEthernet library. + + Ethernet_Manager is a library for nRF52, Teensy, STM32, SAM DUE and SAMD boards, with Ethernet W5x00, LAN8720 or ENC28J60 shields, + to enable easy configuration/reconfiguration of Credentials and autoconnect/autoreconnect of Ethernet. + AVR Mega is not supported. + + Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager + Licensed under MIT license + + Version: 1.6.0 + + Version Modified By Date Comments + ------- ----------- ---------- ----------- + 1.0.0 K Hoang 14/12/2020 Initial coding. + 1.1.0 K Hoang 17/12/2020 Add support to ESP32/ESP8266. Add MQTT related examples to demo dynamic parameter usage + 1.1.1 K Hoang 28/12/2020 Suppress all possible compiler warnings + 1.2.0 K Hoang 22/02/2021 Optimize code and use better FlashStorage_SAMD and FlashStorage_STM32. + Add customs HTML header feature. Fix bug. + 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO + 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core + 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 + *****************************************************************************************************************************/ + +#pragma once + +#ifndef QNEthernet_Teensy_Manager_h +#define QNEthernet_Teensy_Manager_h + +#if ( defined(CORE_TEENSY) && defined(__IMXRT1062__) && defined(ARDUINO_TEENSY41) ) + #if defined(ETHERNET_USE_TEENSY) + #undef ETHERNET_USE_TEENSY + #endif + #warning ETHERNET_USE_TEENSY from Ethernet_Teensy_Manager.h + #define ETHERNET_USE_TEENSY true +#else + #error This code is designed to run on Teensy 4.1 and QNEthernet Library! Please check your Tools->Board setting. +#endif + +// Increase HTTP_UPLOAD_BUFLEN to 4K, instead of default 2K in +#define HTTP_UPLOAD_BUFLEN 4096 + +//Use EEPROM +#include + +////////////////////////////////////////// + +#ifndef USING_CUSTOMS_STYLE + #define USING_CUSTOMS_STYLE false +#endif + +#ifndef USING_CUSTOMS_HEAD_ELEMENT + #define USING_CUSTOMS_HEAD_ELEMENT false +#endif + +#ifndef USING_CORS_FEATURE + #define USING_CORS_FEATURE false +#endif + +///////// NEW for DRD ///////////// +// These defines must be put before #include +// to select where to store DoubleResetDetector_Generic's variable. +// Otherwise, library will use default EEPROM storage +#define DRD_FLAG_DATA_SIZE 4 + +#ifndef DOUBLERESETDETECTOR_DEBUG + #define DOUBLERESETDETECTOR_DEBUG false +#endif + +#include //https://github.com/khoih-prog/DoubleResetDetector_Generic + +// Number of seconds after reset during which a +// subseqent reset will be considered a double reset. +#define DRD_TIMEOUT 10 + +// RTC Memory Address for the DoubleResetDetector_Generic to use +#define DRD_ADDRESS 0 + +DoubleResetDetector_Generic* drd; + +///////// NEW for DRD ///////////// + +//NEW +#define MAX_ID_LEN 5 +#define MAX_DISPLAY_NAME_LEN 16 + +typedef struct +{ + char id [MAX_ID_LEN + 1]; + char displayName [MAX_DISPLAY_NAME_LEN + 1]; + char *pdata; + uint8_t maxlen; +} MenuItem; +// + +#if USE_DYNAMIC_PARAMETERS + #warning Using Dynamic Parameters + ///NEW + extern uint16_t NUM_MENU_ITEMS; + extern MenuItem myMenuItems []; + bool *menuItemUpdated = NULL; +#else + #warning Not using Dynamic Parameters +#endif + +// Configurable items besides fixed Header +#define NUM_CONFIGURABLE_ITEMS ( 2 ) + +#define HEADER_MAX_LEN 16 +#define STATIC_IP_MAX_LEN 16 +#define BOARD_NAME_MAX_LEN 24 + +typedef struct Configuration +{ + char header [HEADER_MAX_LEN]; + char static_IP [STATIC_IP_MAX_LEN]; + char board_name [BOARD_NAME_MAX_LEN]; + int checkSum; +} Ethernet_Configuration; + +// Currently CONFIG_DATA_SIZE = ( 60 ) +uint16_t CONFIG_DATA_SIZE = sizeof(Ethernet_Configuration); + +extern bool LOAD_DEFAULT_CONFIG_DATA; +extern Ethernet_Configuration defaultConfig; + +// -- HTML page fragments + +const char ETM_HTML_HEAD_START[] /*PROGMEM*/ = "Ethernet_Teensy_Manager"; + +const char ETM_HTML_HEAD_STYLE[] /*PROGMEM*/ = ""; + +const char ETM_HTML_HEAD_END[] /*PROGMEM*/ = "
\ +
\ +
"; + +const char ETM_FLDSET_START[] /*PROGMEM*/ = "
"; +const char ETM_FLDSET_END[] /*PROGMEM*/ = "
"; +const char ETM_HTML_PARAM[] /*PROGMEM*/ = "
"; +const char ETM_HTML_BUTTON[] /*PROGMEM*/ = "
"; +const char ETM_HTML_SCRIPT[] /*PROGMEM*/ = ""; +const char ETM_HTML_END[] /*PROGMEM*/ = ""; + +////////////////////////////////////////// + +//KH Add repeatedly used const +//KH, from v1.1.0 +const char WM_HTTP_HEAD_CL[] PROGMEM = "Content-Length"; +const char WM_HTTP_HEAD_TEXT_HTML[] PROGMEM = "text/html"; +const char WM_HTTP_HEAD_TEXT_PLAIN[] PROGMEM = "text/plain"; + +const char WM_HTTP_CACHE_CONTROL[] PROGMEM = "Cache-Control"; +const char WM_HTTP_NO_STORE[] PROGMEM = "no-cache, no-store, must-revalidate"; +const char WM_HTTP_PRAGMA[] PROGMEM = "Pragma"; +const char WM_HTTP_NO_CACHE[] PROGMEM = "no-cache"; +const char WM_HTTP_EXPIRES[] PROGMEM = "Expires"; + +const char WM_HTTP_CORS[] PROGMEM = "Access-Control-Allow-Origin"; +const char WM_HTTP_CORS_ALLOW_ALL[] PROGMEM = "*"; + +////////////////////////////////////////// + +static int linkStatus = 0; + +static void link_status_callback(struct netif *netif) +{ + //linkStatus = netif_is_link_up(netif); + linkStatus = netif->flags & NETIF_FLAG_LINK_UP; + + //Serial.print("enet link status: "); + //Serial.print(linkStatus ? "up" : "down"); +} + +////////////////////////////////////////// + +class Ethernet_Manager +{ + + public: + +#ifndef LED_BUILTIN +#define LED_BUILTIN 13 +#endif + +#define LED_OFF LOW +#define LED_ON HIGH + + void begin(bool initialConfig = false) + { + //Turn OFF + pinMode(LED_BUILTIN, OUTPUT); + digitalWrite(LED_BUILTIN, LED_OFF); + + //// New DRD //// + drd = new DoubleResetDetector_Generic(DRD_TIMEOUT, DRD_ADDRESS); + bool noConfigPortal = true; + + if (drd->detectDoubleReset()) + { + ETM_LOGWARN(F("=====================")); + ETM_LOGWARN(F("DRD. Run ConfigPortal")); + ETM_LOGWARN(F("=====================")); + noConfigPortal = false; + } + + //// New DRD //// + + if (LOAD_DEFAULT_CONFIG_DATA) + { + ETM_LOGERROR(F("======= Start Default Config Data =======")); + displayConfigData(defaultConfig); + } + + hadConfigData = getConfigData(); + + connectEthernet(); + + isForcedConfigPortal = isForcedCP(); + + //// New DRD //// + // noConfigPortal when getConfigData() OK and no MRD/DRD'ed + if (hadConfigData && noConfigPortal && (!isForcedConfigPortal) ) + //// New DRD //// + { + hadConfigData = true; + + if (ethernetConnected) + { + ETM_LOGWARN(F("begin:Ethernet Connected.")); + + if (initialConfig) + { + ETM_LOGWARN(F("begin: Start ConfigPortal")); + // Start configuration mode + startConfigurationMode(); + } + + } + else + { + // Can't do anything here + ETM_LOGWARN(F("begin:Ethernet not Connected")); + // failed to connect to Ethernet, will start configuration mode + //startConfigurationMode(); + } + } + else + { + ETM_LOGERROR(isForcedConfigPortal? F("bg: isForcedConfigPortal = true") : F("bg: isForcedConfigPortal = false")); + + // If not persistent => clear the flag so that after reset. no more CP, even CP not entered and saved + if (persForcedConfigPortal) + { + ETM_LOGERROR1(F("bg:Stay forever in CP:"), isForcedConfigPortal ? F("Forced-Persistent") : (noConfigPortal ? F("No ConfigDat") : F("DRD/MRD"))); + } + else + { + ETM_LOGERROR1(F("bg:Stay forever in CP:"), isForcedConfigPortal ? F("Forced-non-Persistent") : (noConfigPortal ? F("No ConfigDat") : F("DRD/MRD"))); + clearForcedCP(); + } + + //To permit autoreset after timeout if DRD/MRD or non-persistent forced-CP + hadConfigData = isForcedConfigPortal ? true : (noConfigPortal ? false : true); + + // failed to connect to WiFi, will start configuration mode + startConfigurationMode(); + } + } + + ////////////////////////////////////////// + + // Return true if still in CP mode + bool run() + { + //static int retryTimes = 0; + + //// New DRD //// + // Call the double reset detector loop method every so often, + // so that it can recognise when the timeout expires. + // You can also call drd.stop() when you wish to no longer + // consider the next reset as a double reset. + drd->loop(); + //// New DRD //// + + // Be sure to reconnect Ethernet first + if (!ethernetConnected) + { + connectEthernet(); + } + + // Connection OK. Run CP if requested. + if (ethernetConnected) + { + // If configTimeout but user hasn't connected to configWeb => try to reconnect Blynk. + // But if user has connected to configWeb, stay there until done, then reset hardware + if ( configuration_mode && ( configTimeout == 0 || millis() < configTimeout ) ) + { + retryTimes = 0; + + if (server) + { + server->handleClient(); + } + } + else + { +#if RESET_IF_CONFIG_TIMEOUT + // If we're here but still in configuration_mode, permit running TIMES_BEFORE_RESET times before reset hardware + // to permit user another chance to config. + if ( configuration_mode && (configTimeout != 0) ) + { + if (++retryTimes <= CONFIG_TIMEOUT_RETRYTIMES_BEFORE_RESET) + { + ETM_LOGWARN1(F("run:TimeOut.Tried #"), retryTimes); + } + else + { + resetFunc(); + } + } +#endif + } + } + else if (configuration_mode) + { + configuration_mode = false; + ETM_LOGWARN(F("run:Ethernet not OK")); + + // Turn the LED_BUILTIN OFF when out of configuration mode. + digitalWrite(LED_BUILTIN, LED_OFF); + } + + return configuration_mode; + } + + ////////////////////////////////////////// + + String getBoardName() + { + return (String(Ethernet_Manager_config.board_name)); + } + + ////////////////////////////////////////// + + Ethernet_Configuration* getFullConfigData(Ethernet_Configuration *configData) + { + if (!hadConfigData) + getConfigData(); + + // Check if NULL pointer + if (configData) + memcpy(configData, &Ethernet_Manager_config, sizeof(Ethernet_Manager_config)); + + return (configData); + } + + ////////////////////////////////////////// + + void clearConfigData() + { + memset(&Ethernet_Manager_config, 0, sizeof(Ethernet_Manager_config)); + +#if USE_DYNAMIC_PARAMETERS + for (uint8_t i = 0; i < NUM_MENU_ITEMS; i++) + { + // Actual size of pdata is [maxlen + 1] + memset(myMenuItems[i].pdata, 0, myMenuItems[i].maxlen + 1); + } +#endif + + saveAllConfigData(); + } + + ////////////////////////////////////////////// + + bool isConfigDataValid() + { + return hadConfigData; + } + + ////////////////////////////////////////////// + + // Forced CP => Flag = 0xBEEFBEEF. Else => No forced CP + // Flag to be stored at (EEPROM_START + DRD_FLAG_DATA_SIZE + CONFIG_DATA_SIZE) + // to avoid corruption to current data + //#define FORCED_CONFIG_PORTAL_FLAG_DATA ( (uint32_t) 0xDEADBEEF) + //#define FORCED_PERS_CONFIG_PORTAL_FLAG_DATA ( (uint32_t) 0xBEEFDEAD) + + const uint32_t FORCED_CONFIG_PORTAL_FLAG_DATA = 0xDEADBEEF; + const uint32_t FORCED_PERS_CONFIG_PORTAL_FLAG_DATA = 0xBEEFDEAD; + + #define FORCED_CONFIG_PORTAL_FLAG_DATA_SIZE 4 + + void resetAndEnterConfigPortal() + { + persForcedConfigPortal = false; + + setForcedCP(false); + + // Delay then reset the ESP8266 after save data + delay(1000); + resetFunc(); + } + + ////////////////////////////////////////////// + + // This will keep CP forever, until you successfully enter CP, and Save data to clear the flag. + void resetAndEnterConfigPortalPersistent() + { + persForcedConfigPortal = true; + + setForcedCP(true); + + // Delay then reset the ESP8266 after save data + delay(1000); + resetFunc(); + } + + ////////////////////////////////////////////// + + void resetFunc() + { + #if defined(__IMXRT1062__) + // Teensy 4.0 + SCB_AIRCR = 0x05FA0004; //write value for restart for Teensy + #else + void(*resetFunc)() = 0; + resetFunc(); + #endif + } + + ////////////////////////////////////// + + // Add customs headers from v1.1.0 + + // New from v1.1.0, for configure CORS Header, default to WM_HTTP_CORS_ALLOW_ALL = "*" + +#if USING_CUSTOMS_STYLE + //sets a custom style, such as color + // ""; + void setCustomsStyle(const char* CustomsStyle = ETM_HTML_HEAD_STYLE) + { + ETM_HTML_HEAD_CUSTOMS_STYLE = CustomsStyle; + ETM_LOGDEBUG1(F("Set CustomsStyle to : "), ETM_HTML_HEAD_CUSTOMS_STYLE); + } + + const char* getCustomsStyle() + { + ETM_LOGDEBUG1(F("Get CustomsStyle = "), ETM_HTML_HEAD_CUSTOMS_STYLE); + return ETM_HTML_HEAD_CUSTOMS_STYLE; + } +#endif + +#if USING_CUSTOMS_HEAD_ELEMENT + //sets a custom element to add to head, like a new style tag + void setCustomsHeadElement(const char* CustomsHeadElement = NULL) + { + _CustomsHeadElement = CustomsHeadElement; + ETM_LOGDEBUG1(F("Set CustomsHeadElement to : "), _CustomsHeadElement); + } + + const char* getCustomsHeadElement() + { + ETM_LOGDEBUG1(F("Get CustomsHeadElement = "), _CustomsHeadElement); + return _CustomsHeadElement; + } +#endif + +#if USING_CORS_FEATURE + void setCORSHeader(const char* CORSHeaders = NULL) + { + _CORS_Header = CORSHeaders; + + ETM_LOGDEBUG1(F("Set CORS Header to : "), _CORS_Header); + } + + const char* getCORSHeader() + { + ETM_LOGDEBUG1(F("Get CORS Header = "), _CORS_Header); + return _CORS_Header; + } +#endif + + ////////////////////////////////////// + + + private: + + // Initialize the Ethernet server library + // with the IP address and port you want to use + // (port 80 is default for HTTP): + EthernetWebServer *server; + + bool ethernetConnected = false; + + int retryTimes = 0; + + bool configuration_mode = false; + + unsigned long configTimeout; + bool hadConfigData = false; + + bool isForcedConfigPortal = false; + bool persForcedConfigPortal = false; + + Ethernet_Configuration Ethernet_Manager_config; + + uint16_t totalDataSize = 0; + + uint8_t currentBlynkServerIndex = 255; + +///////////////////////////////////// + + // Add customs headers from v1.1.0 + +#if USING_CUSTOMS_STYLE + const char* ETM_HTML_HEAD_CUSTOMS_STYLE = NULL; +#endif + +#if USING_CUSTOMS_HEAD_ELEMENT + const char* _CustomsHeadElement = NULL; +#endif + +#if USING_CORS_FEATURE + const char* _CORS_Header = WM_HTTP_CORS_ALLOW_ALL; //"*"; +#endif + + ////////////////////////////////////// + +#define RFC952_HOSTNAME_MAXLEN 24 + + char RFC952_hostname[RFC952_HOSTNAME_MAXLEN + 1]; + + void setRFC952_hostname(const char* iHostname = "") + { + if (iHostname[0] == 0) + { + String _hostname = "nRF52-XXXXXX"; // + String(macAddress, HEX); + _hostname.toUpperCase(); + + getRFC952_hostname(_hostname.c_str()); + + } + else + { + // Prepare and store the hostname only not NULL + getRFC952_hostname(iHostname); + } + + ETM_LOGWARN1(F("Hostname="), RFC952_hostname); + } + + ////////////////////////////////////// + + char* getRFC952_hostname(const char* iHostname) + { + memset(RFC952_hostname, 0, sizeof(RFC952_hostname)); + + size_t len = ( RFC952_HOSTNAME_MAXLEN < strlen(iHostname) ) ? RFC952_HOSTNAME_MAXLEN : strlen(iHostname); + + size_t j = 0; + + for (size_t i = 0; i < len - 1; i++) + { + if ( isalnum(iHostname[i]) || iHostname[i] == '-' ) + { + RFC952_hostname[j] = iHostname[i]; + j++; + } + } + + // no '-' as last char + if ( isalnum(iHostname[len - 1]) || (iHostname[len - 1] != '-') ) + RFC952_hostname[j] = iHostname[len - 1]; + + return RFC952_hostname; + } + + ////////////////////////////////////// + + void displayConfigData(Ethernet_Configuration configData) + { + ETM_LOGWARN3(F("Header="), configData.header, + F(", BoardName="), configData.board_name); + ETM_LOGWARN1(F("StaticIP="), configData.static_IP); + +#if USE_DYNAMIC_PARAMETERS + for (uint8_t i = 0; i < NUM_MENU_ITEMS; i++) + { + ETM_LOGINFO3("i=", i, ",id=", myMenuItems[i].id); + ETM_LOGINFO1("data=", myMenuItems[i].pdata); + } +#endif + } + + ////////////////////////////////////// + +#define ETHERNET_BOARD_TYPE "Teensy" +#define WM_NO_CONFIG "blank" + + //#define EEPROM_SIZE E2END + //#define EEPROM_SIZE 512 + + //KH + // Teensy 4.0 : EEPROM_SIZE = 3824 = (255 * 15) - 1, why 1080 ??? + // Teensy++2.0, 3.5 and 3.6 : EEPROM_SIZE = 4096 + // Teensy++1.0, 3.0, 3.1 and 3.2 : EEPROM_SIZE = 2048 + // Teensy2.0 : EEPROM_SIZE = 1024 + // Teensy1.0 : EEPROM_SIZE = 512 + // Teensy LC : EEPROM_SIZE = 128 + + /* + Teensy 4.0 => EEPROM_SIZE = 3824 = (255 * 15) - 1 + #define FLASH_SECTORS 15 + #if E2END > (255*FLASH_SECTORS-1) + #error "E2END is set larger than the maximum possible EEPROM size" + #endif + ====================================================== + Teensy3.x + #if defined(__MK20DX128__) //Teensy 3.0 + #define EEPROM_MAX 2048 + #elif defined(__MK20DX256__) //Teensy 3.1 and 3.2 + #define EEPROM_MAX 2048 + #elif defined(__MK64FX512__) //Teensy 3.5 + #define EEPROM_MAX 4096 + #elif defined(__MK66FX1M0__) //Teensy 3.6 + #define EEPROM_MAX 4096 + #elif defined(__MKL26Z64__) //Teensy LC + #define EEPROM_MAX 255 + #endif + ====================================================== + Teensy 2.x + Teensy 2.0 + #if defined(__AVR_ATmega32U4__) //Teensy 2.0 + #elif defined(__AVR_AT90USB162__) //Teensy 1.0 + #elif defined(__AVR_AT90USB646__) //Teensy++ 1.0 + #elif defined(__AVR_AT90USB1286__) //Teensy++ 2.0 + */ + +#if !defined(EEPROM_SIZE) + #define EEPROM_SIZE (E2END + 1) +#endif + +// DRD_FLAG_DATA_SIZE is 4, to store DRD flag, defined in DRD +#if (EEPROM_SIZE < DRD_FLAG_DATA_SIZE + CONFIG_DATA_SIZE) + #warning EEPROM_SIZE must be > CONFIG_DATA_SIZE. Reset to 1024 + #undef EEPROM_SIZE + #define EEPROM_SIZE 1024 +#endif +//#endif + +#ifndef EEPROM_START + #define EEPROM_START 0 //define 256 in DRD + #warning EEPROM_START not defined. Set to 0 +#else + #if (EEPROM_START + DRD_FLAG_DATA_SIZE + CONFIG_DATA_SIZE + FORCED_CONFIG_PORTAL_FLAG_DATA_SIZE > EEPROM_SIZE) + #error EPROM_START + DRD_FLAG_DATA_SIZE + CONFIG_DATA_SIZE + FORCED_CONFIG_PORTAL_FLAG_DATA_SIZE > EEPROM_SIZE. Please adjust. + #endif +#endif + +// Stating positon to store Blynk8266_WM_config +#define CONFIG_EEPROM_START (EEPROM_START + DRD_FLAG_DATA_SIZE) + + int calcChecksum() + { + int checkSum = 0; + for (uint16_t index = 0; index < (sizeof(Ethernet_Manager_config) - sizeof(Ethernet_Manager_config.checkSum)); index++) + { + checkSum += * ( ( (byte*) &Ethernet_Manager_config ) + index); + } + + return checkSum; + } + + ////////////////////////////////////////////// + + void setForcedCP(bool isPersistent) + { + uint32_t readForcedConfigPortalFlag = isPersistent? FORCED_PERS_CONFIG_PORTAL_FLAG_DATA : FORCED_CONFIG_PORTAL_FLAG_DATA; + + ETM_LOGERROR(isPersistent ? F("setForcedCP Persistent") : F("setForcedCP non-Persistent")); + + EEPROM.put(CONFIG_EEPROM_START + CONFIG_DATA_SIZE, readForcedConfigPortalFlag); + } + + ////////////////////////////////////////////// + + void clearForcedCP() + { + EEPROM.put(CONFIG_EEPROM_START + CONFIG_DATA_SIZE, 0); + } + + ////////////////////////////////////////////// + + bool isForcedCP() + { + uint32_t readForcedConfigPortalFlag; + + // Return true if forced CP (0xDEADBEEF read at offset EPROM_START + DRD_FLAG_DATA_SIZE + CONFIG_DATA_SIZE) + // => set flag noForcedConfigPortal = false + EEPROM.get(CONFIG_EEPROM_START + CONFIG_DATA_SIZE, readForcedConfigPortalFlag); + + // Return true if forced CP (0xDEADBEEF read at offset EPROM_START + DRD_FLAG_DATA_SIZE + CONFIG_DATA_SIZE) + // => set flag noForcedConfigPortal = false + if (readForcedConfigPortalFlag == FORCED_CONFIG_PORTAL_FLAG_DATA) + { + persForcedConfigPortal = false; + return true; + } + else if (readForcedConfigPortalFlag == FORCED_PERS_CONFIG_PORTAL_FLAG_DATA) + { + persForcedConfigPortal = true; + return true; + } + else + { + return false; + } + } + + ////////////////////////////////////////////// + +#if USE_DYNAMIC_PARAMETERS + + bool checkDynamicData() + { + int checkSum = 0; + int readCheckSum; + + #define BUFFER_LEN 128 + char readBuffer[BUFFER_LEN + 1]; + + uint16_t offset = CONFIG_EEPROM_START + sizeof(Ethernet_Manager_config) + FORCED_CONFIG_PORTAL_FLAG_DATA_SIZE; + + // Find the longest pdata, then dynamically allocate buffer. Remember to free when done + // This is used to store tempo data to calculate checksum to see of data is valid + // We dont like to destroy myMenuItems[i].pdata with invalid data + + for (uint8_t i = 0; i < NUM_MENU_ITEMS; i++) + { + if (myMenuItems[i].maxlen > BUFFER_LEN) + { + // Size too large, abort and flag false + ETM_LOGERROR(F("ChkCrR: Error Small Buffer.")); + return false; + } + } + + for (uint8_t i = 0; i < NUM_MENU_ITEMS; i++) + { + char* _pointer = readBuffer; + + // Prepare buffer, more than enough + memset(readBuffer, 0, sizeof(readBuffer)); + + // Read more than necessary, but OK and easier to code + EEPROM.get(offset, readBuffer); + // NULL terminated + readBuffer[myMenuItems[i].maxlen] = 0; + + ETM_LOGDEBUG3(F("ChkCrR:pdata="), readBuffer, F(",len="), myMenuItems[i].maxlen); + + for (uint16_t j = 0; j < myMenuItems[i].maxlen; j++,_pointer++) + { + checkSum += *_pointer; + } + + offset += myMenuItems[i].maxlen; + } + + EEPROM.get(offset, readCheckSum); + + ETM_LOGERROR3(F("ChkCrR:CrCCsum=0x"), String(checkSum, HEX), F(",CrRCsum=0x"), String(readCheckSum, HEX)); + + if ( checkSum != readCheckSum) + { + return false; + } + + return true; + } + + ////////////////////////////////////////////// + + bool EEPROM_getDynamicData() + { + int readCheckSum; + int checkSum = 0; + uint16_t offset = CONFIG_EEPROM_START + sizeof(Ethernet_Manager_config) + FORCED_CONFIG_PORTAL_FLAG_DATA_SIZE; + + totalDataSize = sizeof(Ethernet_Manager_config) + sizeof(readCheckSum); + + for (uint8_t i = 0; i < NUM_MENU_ITEMS; i++) + { + char* _pointer = myMenuItems[i].pdata; + totalDataSize += myMenuItems[i].maxlen; + + // Actual size of pdata is [maxlen + 1] + memset(myMenuItems[i].pdata, 0, myMenuItems[i].maxlen + 1); + + for (uint16_t j = 0; j < myMenuItems[i].maxlen; j++,_pointer++,offset++) + { + *_pointer = EEPROM.read(offset); + + checkSum += *_pointer; + } + } + + EEPROM.get(offset, readCheckSum); + + ETM_LOGERROR3(F("CrCCsum=0x"), String(checkSum, HEX), F(",CrRCsum=0x"), String(readCheckSum, HEX)); + + if ( checkSum != readCheckSum) + { + return false; + } + + return true; + } + + ////////////////////////////////////////////// + + void EEPROM_putDynamicData() + { + int checkSum = 0; + uint16_t offset = CONFIG_EEPROM_START + sizeof(Ethernet_Manager_config) + FORCED_CONFIG_PORTAL_FLAG_DATA_SIZE; + + for (uint8_t i = 0; i < NUM_MENU_ITEMS; i++) + { + char* _pointer = myMenuItems[i].pdata; + + ETM_LOGDEBUG3(F("pdata="), myMenuItems[i].pdata, F(",len="), myMenuItems[i].maxlen); + + for (uint16_t j = 0; j < myMenuItems[i].maxlen; j++,_pointer++,offset++) + { + EEPROM.write(offset, *_pointer); + + checkSum += *_pointer; + } + } + + EEPROM.put(offset, checkSum); + //EEPROM.commit(); + + ETM_LOGERROR1(F("CrCCSum=0x"), String(checkSum, HEX)); + } +#endif + + ////////////////////////////////////////////// + + void NULLTerminateConfig() + { + //#define HEADER_MAX_LEN 16 + //#define STATIC_IP_MAX_LEN 16 + //#define BOARD_NAME_MAX_LEN 24 + + // NULL Terminating to be sure + Ethernet_Manager_config.header [HEADER_MAX_LEN - 1] = 0; + Ethernet_Manager_config.static_IP [STATIC_IP_MAX_LEN - 1] = 0; + Ethernet_Manager_config.board_name[BOARD_NAME_MAX_LEN - 1] = 0; + } + + ////////////////////////////////////////////// + + bool EEPROM_get() + { + EEPROM.get(CONFIG_EEPROM_START, Ethernet_Manager_config); + NULLTerminateConfig(); + + return true; + } + + ////////////////////////////////////////////// + + void EEPROM_put() + { + EEPROM.put(CONFIG_EEPROM_START, Ethernet_Manager_config); + } + + ////////////////////////////////////////////// + + void saveConfigData() + { + int calChecksum = calcChecksum(); + Ethernet_Manager_config.checkSum = calChecksum; + + ETM_LOGINFO1(F("Save,WCSum=0x"), String(calChecksum, HEX)); + + EEPROM_put(); + } + + ////////////////////////////////////////////// + + void saveAllConfigData() + { + saveConfigData(); + +#if USE_DYNAMIC_PARAMETERS + EEPROM_putDynamicData(); +#endif + } + + ////////////////////////////////////////////// + + void loadAndSaveDefaultConfigData() + { + // Load Default Config Data from Sketch + memcpy(&Ethernet_Manager_config, &defaultConfig, sizeof(Ethernet_Manager_config)); + strcpy(Ethernet_Manager_config.header, ETHERNET_BOARD_TYPE); + + // Including config and dynamic data, and assume valid + saveAllConfigData(); + + ETM_LOGDEBUG(F("======= Start Loaded Config Data =======")); + displayConfigData(Ethernet_Manager_config); + } + + ////////////////////////////////////////////// + + bool getConfigData() + { + bool dynamicDataValid = true; + + hadConfigData = false; + + EEPROM.begin(); + ETM_LOGINFO1(F("EEPROMsz:"), EEPROM_SIZE); + EEPROM.get(CONFIG_EEPROM_START, Ethernet_Manager_config); + + ETM_LOGINFO(F("======= Start Stored Config Data =======")); + displayConfigData(Ethernet_Manager_config); + + int calChecksum = calcChecksum(); + + ETM_LOGWARN3(F("CCSum=0x"), String(calChecksum, HEX), + F(",RCSum=0x"), String(Ethernet_Manager_config.checkSum, HEX)); + + if (LOAD_DEFAULT_CONFIG_DATA) + { + // Load Config Data from Sketch + loadAndSaveDefaultConfigData(); + + ETM_LOGINFO(F("======= Start Loaded Config Data =======")); + displayConfigData(Ethernet_Manager_config); + + // Don't need Config Portal anymore + return true; + } + else + { + // Load data from EEPROM + EEPROM_get(); + + ETM_LOGINFO(F("======= Start Stored Config Data =======")); + displayConfigData(Ethernet_Manager_config); + + calChecksum = calcChecksum(); + + ETM_LOGINFO3(F("CCSum=0x"), String(calChecksum, HEX), + F(",RCSum=0x"), String(Ethernet_Manager_config.checkSum, HEX)); + +#if USE_DYNAMIC_PARAMETERS + // Load stored dynamic data from EEPROM + dynamicDataValid = checkDynamicData(); +#endif + + // If checksum = 0 => FlashStorage has been cleared (by uploading new FW, etc) => force to CP + if ( (calChecksum != 0) && (calChecksum == Ethernet_Manager_config.checkSum) ) + { + if (dynamicDataValid) + { +#if USE_DYNAMIC_PARAMETERS + // CkSum verified, Now get valid config/ dynamic data + EEPROM_getDynamicData(); + + ETM_LOGERROR(F("Valid Stored Dynamic Data")); +#endif + ETM_LOGERROR(F("======= Start Stored Config Data =======")); + displayConfigData(Ethernet_Manager_config); + + // Don't need Config Portal anymore + return true; + } + else + { + // Invalid Stored config data => Config Portal + ETM_LOGERROR(F("Invalid Stored Dynamic Data. Load default from Sketch")); + + // Load Default Config Data from Sketch, better than just "blank" + loadAndSaveDefaultConfigData(); + + // Need Config Portal here as data can be just dummy + // Even if you don't open CP, you're OK on next boot if your default config data is valid + return false; + } + } + } + + if ( (strncmp(Ethernet_Manager_config.header, ETHERNET_BOARD_TYPE, strlen(ETHERNET_BOARD_TYPE)) != 0) || + (calChecksum != Ethernet_Manager_config.checkSum) || !dynamicDataValid || + ( (calChecksum == 0) && (Ethernet_Manager_config.checkSum == 0) ) ) + { + // Including Credentials CSum + ETM_LOGINFO3(F("InitEEPROM,sz="), EEPROM_SIZE, F(",Datasz="), totalDataSize); + + // doesn't have any configuration + if (LOAD_DEFAULT_CONFIG_DATA) + { + memcpy(&Ethernet_Manager_config, &defaultConfig, sizeof(Ethernet_Manager_config)); + } + else + { + memset(&Ethernet_Manager_config, 0, sizeof(Ethernet_Manager_config)); + + for (uint8_t i = 0; i < NUM_MENU_ITEMS; i++) + { + // Actual size of pdata is [maxlen + 1] + memset(myMenuItems[i].pdata, 0, myMenuItems[i].maxlen + 1); + } + + // Including Credentials CSum + ETM_LOGINFO3(F("InitEEPROM,sz="), EEPROM_SIZE, F(",Datasz="), totalDataSize); + + // doesn't have any configuration + //strcpy(Ethernet_Manager_config.static_IP, WM_NO_CONFIG); + strcpy(Ethernet_Manager_config.board_name, ETHERNET_BOARD_TYPE); + + for (uint8_t i = 0; i < NUM_MENU_ITEMS; i++) + { + strncpy(myMenuItems[i].pdata, WM_NO_CONFIG, myMenuItems[i].maxlen); + } + } + + strcpy(Ethernet_Manager_config.header, ETHERNET_BOARD_TYPE); + + for (uint8_t i = 0; i < NUM_MENU_ITEMS; i++) + { + ETM_LOGDEBUG3(F("g:myMenuItems["), i, F("]="), myMenuItems[i].pdata ); + } + + // Don't need + Ethernet_Manager_config.checkSum = 0; + + EEPROM.put(CONFIG_EEPROM_START, Ethernet_Manager_config); + EEPROM_putDynamicData(); + + return false; + } + else + { + displayConfigData(Ethernet_Manager_config); + } + + return true; + } + + // NEW + void createHTML(String& root_html_template) + { + String pitem; + + root_html_template = ETM_HTML_HEAD_START; + + #if USING_CUSTOMS_STYLE + // Using Customs style when not NULL + if (ETM_HTML_HEAD_CUSTOMS_STYLE) + root_html_template += ETM_HTML_HEAD_CUSTOMS_STYLE; + else + root_html_template += ETM_HTML_HEAD_STYLE; + #else + root_html_template += ETM_HTML_HEAD_STYLE; + #endif + + #if USING_CUSTOMS_HEAD_ELEMENT + if (_CustomsHeadElement) + root_html_template += _CustomsHeadElement; + #endif + + root_html_template += String(ETM_HTML_HEAD_END) + ETM_FLDSET_START; + +#if USE_DYNAMIC_PARAMETERS + for (uint8_t i = 0; i < NUM_MENU_ITEMS; i++) + { + pitem = String(ETM_HTML_PARAM); + + pitem.replace("{b}", myMenuItems[i].displayName); + pitem.replace("{v}", myMenuItems[i].id); + pitem.replace("{i}", myMenuItems[i].id); + + root_html_template += pitem; + } +#endif + + root_html_template += String(ETM_FLDSET_END) + ETM_HTML_BUTTON + ETM_HTML_SCRIPT; + +#if USE_DYNAMIC_PARAMETERS + for (uint8_t i = 0; i < NUM_MENU_ITEMS; i++) + { + pitem = String(ETM_HTML_SCRIPT_ITEM); + + pitem.replace("{d}", myMenuItems[i].id); + + root_html_template += pitem; + } +#endif + + root_html_template += String(ETM_HTML_SCRIPT_END) + ETM_HTML_END; + + return; + } + + ////////////////////////////////////////////// + + void serverSendHeaders() + { + ETM_LOGDEBUG3(F("serverSendHeaders:WM_HTTP_CACHE_CONTROL:"), WM_HTTP_CACHE_CONTROL, "=", WM_HTTP_NO_STORE); + server->sendHeader(WM_HTTP_CACHE_CONTROL, WM_HTTP_NO_STORE); + +#if USING_CORS_FEATURE + // New from v1.2.0, for configure CORS Header, default to WM_HTTP_CORS_ALLOW_ALL = "*" + ETM_LOGDEBUG3(F("serverSendHeaders:WM_HTTP_CORS:"), WM_HTTP_CORS, " : ", _CORS_Header); + server->sendHeader(WM_HTTP_CORS, _CORS_Header); +#endif + + ETM_LOGDEBUG3(F("serverSendHeaders:WM_HTTP_PRAGMA:"), WM_HTTP_PRAGMA, " : ", WM_HTTP_NO_CACHE); + server->sendHeader(WM_HTTP_PRAGMA, WM_HTTP_NO_CACHE); + + ETM_LOGDEBUG3(F("serverSendHeaders:WM_HTTP_EXPIRES:"), WM_HTTP_EXPIRES, " : ", "-1"); + server->sendHeader(WM_HTTP_EXPIRES, "-1"); + } + + ////////////////////////////////////////////// + + void handleRequest() + { + if (server) + { + String key = server->arg("key"); + String value = server->arg("value"); + + static int number_items_Updated = 0; + + if (key == "" && value == "") + { + // New from v1.2.0 + serverSendHeaders(); + ////// + + String result; + createHTML(result); + + ETM_LOGDEBUG1(F("h:Repl:"), result); + + // Reset configTimeout to stay here until finished. + configTimeout = 0; + + if ( RFC952_hostname[0] != 0 ) + { + // Replace only if Hostname is valid + result.replace("Ethernet_ESP32_Manager", RFC952_hostname); + } + else if ( Ethernet_Manager_config.board_name[0] != 0 ) + { + // Or replace only if board_name is valid. Otherwise, keep intact + result.replace("Ethernet_ESP32_Manager", Ethernet_Manager_config.board_name); + } + + if (hadConfigData) + { + result.replace("[[ip]]", Ethernet_Manager_config.static_IP); + result.replace("[[nm]]", Ethernet_Manager_config.board_name); + } + else + { + result.replace("[[ip]]", "0"); + result.replace("[[nm]]", ETHERNET_BOARD_TYPE); + } + +#if USE_DYNAMIC_PARAMETERS + for (uint8_t i = 0; i < NUM_MENU_ITEMS; i++) + { + String toChange = String("[[") + myMenuItems[i].id + "]]"; + result.replace(toChange, myMenuItems[i].pdata); + + ETM_LOGDEBUG3(F("h1:myMenuItems["), i, F("]="), myMenuItems[i].pdata ); + } +#endif + + ETM_LOGDEBUG1(F("h:HTML page size:"), result.length()); + ETM_LOGDEBUG1(F("h:HTML="), result); + + server->send(200, WM_HTTP_HEAD_TEXT_HTML, result); + + return; + } + + if (number_items_Updated == 0) + { + memset(&Ethernet_Manager_config, 0, sizeof(Ethernet_Manager_config)); + strcpy(Ethernet_Manager_config.header, ETHERNET_BOARD_TYPE); + } + +#if USE_DYNAMIC_PARAMETERS + if (!menuItemUpdated) + { + // Don't need to free + menuItemUpdated = new bool[NUM_MENU_ITEMS]; + + if (menuItemUpdated) + { + for (uint8_t i = 0; i < NUM_MENU_ITEMS; i++) + { + // To flag item is not yet updated + menuItemUpdated[i] = false; + } + + ETM_LOGDEBUG(F("h: Init menuItemUpdated" )); + } + else + { + ETM_LOGERROR(F("h: Error can't alloc memory for menuItemUpdated" )); + } + } +#endif + + static bool ip_Updated = false; + static bool nm_Updated = false; + + if (!ip_Updated && (key == String("ip"))) + { + ETM_LOGDEBUG(F("h:repl ip")); + ip_Updated = true; + + number_items_Updated++; + + if (strlen(value.c_str()) < sizeof(Ethernet_Manager_config.static_IP) - 1) + strcpy(Ethernet_Manager_config.static_IP, value.c_str()); + else + strncpy(Ethernet_Manager_config.static_IP, value.c_str(), sizeof(Ethernet_Manager_config.static_IP) - 1); + } + else if (!nm_Updated && (key == String("nm"))) + { + ETM_LOGDEBUG(F("h:repl nm")); + nm_Updated = true; + + number_items_Updated++; + + if (strlen(value.c_str()) < sizeof(Ethernet_Manager_config.board_name) - 1) + strcpy(Ethernet_Manager_config.board_name, value.c_str()); + else + strncpy(Ethernet_Manager_config.board_name, value.c_str(), sizeof(Ethernet_Manager_config.board_name) - 1); + } + +#if USE_DYNAMIC_PARAMETERS + else + { + for (uint8_t i = 0; i < NUM_MENU_ITEMS; i++) + { + if ( !menuItemUpdated[i] && (key == myMenuItems[i].id) ) + { + ETM_LOGDEBUG3(F("h:"), myMenuItems[i].id, F("="), value.c_str() ); + + menuItemUpdated[i] = true; + + number_items_Updated++; + + // Actual size of pdata is [maxlen + 1] + memset(myMenuItems[i].pdata, 0, myMenuItems[i].maxlen + 1); + + if ((int) strlen(value.c_str()) < myMenuItems[i].maxlen) + strcpy(myMenuItems[i].pdata, value.c_str()); + else + strncpy(myMenuItems[i].pdata, value.c_str(), myMenuItems[i].maxlen); + + break; + } + } + } +#endif + + ETM_LOGDEBUG1(F("h:items updated ="), number_items_Updated); + ETM_LOGDEBUG3(F("h:key ="), key, ", value =", value); + + server->send(200, WM_HTTP_HEAD_TEXT_HTML, "OK"); + +#if USE_DYNAMIC_PARAMETERS + if (number_items_Updated == NUM_CONFIGURABLE_ITEMS + NUM_MENU_ITEMS) +#else + if (number_items_Updated == NUM_CONFIGURABLE_ITEMS) +#endif + { + ETM_LOGERROR(F("h:Updating EEPROM. Please wait for reset")); + + saveAllConfigData(); + + // Done with CP, Clear CP Flag here if forced + if (isForcedConfigPortal) + clearForcedCP(); + + ETM_LOGWARN(F("h:Rst")); + + // Delay then reset after save data + delay(1000); + resetFunc(); + } + } // if (server) + } + + ////////////////////////////////////////////// + +#ifndef CONFIG_TIMEOUT + #warning Default CONFIG_TIMEOUT = 60s + #define CONFIG_TIMEOUT 60000L +#endif + + void startConfigurationMode() + { + // turn the LED_BUILTIN ON to tell us we are in configuration mode. + digitalWrite(LED_BUILTIN, LED_ON); + + ETM_LOGWARN1(F("CfgIP="), Ethernet.localIP() ); + + if (!server) + server = new EthernetWebServer; + + //See https://stackoverflow.com/questions/39803135/c-unresolved-overloaded-function-type?rq=1 + + if (server) + { + server->on("/", [this]() { handleRequest(); } ); + server->begin(); + } + + // If there is no saved config Data, stay in config mode forever until having config Data. + // or SSID, PW, Server,Token ="nothing" + if (hadConfigData) + { + configTimeout = millis() + CONFIG_TIMEOUT; + + ETM_LOGDEBUG3(F("s:millis() = "), millis(), F(", configTimeout = "), configTimeout); + } + else + { + configTimeout = 0; + ETM_LOGDEBUG(F("s:configTimeout = 0")); + } + + configuration_mode = true; + } + + ////////////////////////////////////////////// + + bool connectEthernet() + { + // Check go see if static IP is required + IPAddress staticIP; + + if (staticIP.fromString(Ethernet_Manager_config.static_IP)) + { + // Use static IP + ETM_LOGWARN1(F("Start connectEthernet using Static IP ="), staticIP); + + Ethernet.begin(myIP, myNetmask, myGW); + Ethernet.setDNSServerIP(mydnsServer); + } + else + { + // If static_IP ="nothing" or NULL, use DHCP dynamic IP + ETM_LOGWARN(F("Start connectEthernet using DHCP")); + + Ethernet.begin(); + } + + ethernetConnected = Ethernet.waitForLocalIP(10000); + + netif_set_link_callback(netif_default, link_status_callback); + + if (ethernetConnected) + { + ETM_LOGWARN1(F("IP:"), Ethernet.localIP()); + } + else + { + ETM_LOGWARN(F("DHCPFailed")); + } + + return ethernetConnected; + } +}; + + +#endif // QNEthernet_Teensy_Manager_h diff --git a/src/Ethernet_Manager.h b/src/Ethernet_Manager.h index f9fac90d..56696bcf 100644 --- a/src/Ethernet_Manager.h +++ b/src/Ethernet_Manager.h @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager Licensed under MIT license - Version: 1.5.0 + Version: 1.6.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 *****************************************************************************************************************************/ #pragma once @@ -28,7 +29,7 @@ #ifndef Ethernet_Manager_h #define Ethernet_Manager_h -#define ETHERNET_MANAGER_VERSION "Ethernet_Manager v1.5.0" +#define ETHERNET_MANAGER_VERSION "Ethernet_Manager v1.6.0" #if ( USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE || USE_ETHERNET_ESP8266 || USE_ETHERNET_ENC || USE_NATIVE_ETHERNET ) #ifdef USE_CUSTOM_ETHERNET @@ -47,6 +48,12 @@ #ifndef SHIELD_TYPE #define SHIELD_TYPE "Custom Ethernet using Teensy 4.1 NativeEthernet Library" #endif + #elif USE_QN_ETHERNET + #include "QNEthernet.h" + #warning Using QNEthernet lib for Teensy 4.1. Must also use Teensy Packages Patch or error + #ifndef SHIELD_TYPE + #define SHIELD_TYPE "Custom Ethernet using Teensy 4.1 QNEthernet Library" + #endif #elif USE_ETHERNET3 #include "Ethernet3.h" #warning Using Ethernet3 lib from Ethernet_Manager.h @@ -104,6 +111,9 @@ #if USE_NATIVE_ETHERNET #include #include +#elif USE_QN_ETHERNET + #include + #include #elif ETHERNET_USE_WT32_ETH01 #include #else @@ -169,7 +179,11 @@ #elif (ETHERNET_USE_SAM_DUE) #include #elif (ETHERNET_USE_TEENSY) - #include + #if USE_NATIVE_ETHERNET + #include + #elif USE_QN_ETHERNET + #include + #endif #elif ETHERNET_USE_WT32_ETH01 #include #elif (ETHERNET_USE_ESP32) diff --git a/src/Ethernet_Manager_Debug.h b/src/Ethernet_Manager_Debug.h index cd0b02fe..d5dfee85 100644 --- a/src/Ethernet_Manager_Debug.h +++ b/src/Ethernet_Manager_Debug.h @@ -9,7 +9,7 @@ Built by Khoi Hoang https://github.com/khoih-prog/Ethernet_Manager Licensed under MIT license - Version: 1.5.0 + Version: 1.6.0 Version Modified By Date Comments ------- ----------- ---------- ----------- @@ -21,6 +21,7 @@ 1.3.0 K Hoang 16/05/2021 Add support to RP2040-based boards such as RASPBERRY_PI_PICO 1.4.0 K Hoang 28/05/2021 Add support to Nano_RP2040_Connect, RASPBERRY_PI_PICO using RP2040 Arduino mbed core 1.5.0 K Hoang 06/07/2021 Add support to WT32_ETH01 (ESP32 + LAN8720) boards + 1.6.0 K Hoang 05/09/2021 Add support to QNEthernet Library for Teensy 4.1 *****************************************************************************************************************************/ #pragma once