diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 849d799..1b901c6 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -15,7 +15,8 @@ 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.19) or Platform.io version
-* Board Core Version (e.g. Arduino SAMDUE core v1.6.12, ESP32 core v2.0.2, ESP8266 core v3.0.2, ArduinoCore-mbed v3.0.1, etc.)
+* `RP2040` Core Version (e.g. RP2040 core v2.6.0)
+* `RP2040W` Board type (e.g. RASPBERRY_PI_PICO_W)
* 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:
@@ -27,13 +28,13 @@ Please ensure to specify the following:
```
Arduino IDE version: 1.8.19
-RASPBERRY_PI_PICO board
-ArduinoCore-mbed v3.0.1
+RP2040 core v2.6.0
+RASPBERRY_PI_PICO_W Module
OS: Ubuntu 20.04 LTS
-Linux xy-Inspiron-3593 5.13.0-39-generic #44~20.04.1-Ubuntu SMP Thu Mar 24 16:43:35 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
+Linux xy-Inspiron-3593 5.15.0-48-generic #54~20.04.1-Ubuntu SMP Thu Sep 1 16:17:26 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
Context:
-The board couldn't autoreconnect to Local Blynk Server after router power recycling.
+I encountered a crash while using this library
Steps to reproduce:
1. ...
diff --git a/README.md b/README.md
index a80f3eb..ad782f5 100644
--- a/README.md
+++ b/README.md
@@ -189,25 +189,25 @@ This [**MDNS_Generic library**](https://github.com/khoih-prog/MDNS_Generic) is b
1. [`Arduino IDE 1.8.19+` for Arduino](https://github.com/arduino/Arduino). [![GitHub release](https://img.shields.io/github/release/arduino/Arduino.svg)](https://github.com/arduino/Arduino/releases/latest)
2. [`Arduino AVR core 1.8.5+`](https://github.com/arduino/ArduinoCore-avr) for Arduino (Use Arduino Board Manager) for 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.56+`](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.
+ 3. [`Teensy core v1.57+`](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.13+`](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.10+`](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.2+`](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. [`Seeeduino SAMD core 1.8.3+`](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.3.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. [`ArduinoCore-mbed mbed_rp2040, mbed_nano, mbed_portenta core 3.0.1+`](https://github.com/arduino/ArduinoCore-mbed) for Arduino (Use Arduino Board Manager) **Portenta_H7, RP2040-based boards, such as Nano_RP2040_Connect, RASPBERRY_PI_PICO**. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-mbed.svg)](https://github.com/arduino/ArduinoCore-mbed/releases/latest)
-10. [`Earle Philhower's arduino-pico core v1.13.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)
-11. [`Arduino Core for STM32 v2.2.0+`](https://github.com/stm32duino/Arduino_Core_STM32) for STM32F/L/H/G/WB/MP1 boards. [![GitHub release](https://img.shields.io/github/release/stm32duino/Arduino_Core_STM32.svg)](https://github.com/stm32duino/Arduino_Core_STM32/releases/latest)
-12. [`ESP32 Core 2.0.2+`](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/)
+ 9. [`ArduinoCore-mbed mbed_rp2040, mbed_nano, mbed_portenta core 3.3.0+`](https://github.com/arduino/ArduinoCore-mbed) for Arduino (Use Arduino Board Manager) **Portenta_H7, RP2040-based boards, such as Nano_RP2040_Connect, RASPBERRY_PI_PICO**. [![GitHub release](https://img.shields.io/github/release/arduino/ArduinoCore-mbed.svg)](https://github.com/arduino/ArduinoCore-mbed/releases/latest)
+10. [`Earle Philhower's arduino-pico core v2.6.0+`](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)
+11. [`Arduino Core for STM32 v2.3.0+`](https://github.com/stm32duino/Arduino_Core_STM32) for STM32F/L/H/G/WB/MP1 boards. [![GitHub release](https://img.shields.io/github/release/stm32duino/Arduino_Core_STM32.svg)](https://github.com/stm32duino/Arduino_Core_STM32/releases/latest)
+12. [`ESP32 Core 2.0.5+`](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/)
13. Depending on which Ethernet module/shield you're using :
- - [`Ethernet_Generic library v2.0.1+`](https://github.com/khoih-prog/Ethernet_Generic) for W5100, W5200 and W5500/WIZ550io/WIZ850io/USR-ES1 with Wiznet W5500 chip. [![GitHub release](https://img.shields.io/github/release/khoih-prog/Ethernet_Generic.svg)](https://github.com/khoih-prog/Ethernet_Generic/releases/latest)
+ - [`Ethernet_Generic library v2.6.1+`](https://github.com/khoih-prog/Ethernet_Generic) for W5100, W5200 and W5500/WIZ550io/WIZ850io/USR-ES1 with Wiznet W5500 chip. [![GitHub release](https://img.shields.io/github/release/khoih-prog/Ethernet_Generic.svg)](https://github.com/khoih-prog/Ethernet_Generic/releases/latest)
-14. [`STM32Ethernet library v1.2.0+`](https://github.com/stm32duino/STM32Ethernet) for built-in LAN8742A Ethernet on (Nucleo-144, Discovery). [![GitHub release](https://img.shields.io/github/release/stm32duino/STM32Ethernet.svg)](https://github.com/stm32duino/STM32Ethernet/releases/latest). To be used with [`LwIP library v2.1.2+`](https://github.com/stm32duino/LwIP). [![GitHub release](https://img.shields.io/github/release/stm32duino/LwIP.svg)](https://github.com/stm32duino/LwIP/releases/latest). **Not yet ready** in v1.4.1
+14. [`STM32Ethernet library v1.3.0+`](https://github.com/stm32duino/STM32Ethernet) for built-in LAN8742A Ethernet on (Nucleo-144, Discovery). [![GitHub release](https://img.shields.io/github/release/stm32duino/STM32Ethernet.svg)](https://github.com/stm32duino/STM32Ethernet/releases/latest). To be used with [`LwIP library v2.1.2+`](https://github.com/stm32duino/LwIP). [![GitHub release](https://img.shields.io/github/release/stm32duino/LwIP.svg)](https://github.com/stm32duino/LwIP/releases/latest). **Not yet ready** in v1.4.1
-15. [`WiFiNINA_Generic library v1.8.14-3+`](https://github.com/khoih-prog/WiFiNINA_Generic). To install. check [![arduino-library-badge](https://www.ardu-badge.com/badge/WiFiNINA_Generic.svg?)](https://www.ardu-badge.com/WiFiNINA_Generic) if using WiFiNINA for boards such as Nano 33 IoT, nRF52, Teensy, etc.
+15. [`WiFiNINA_Generic library v1.8.14-6+`](https://github.com/khoih-prog/WiFiNINA_Generic). To install. check [![arduino-library-badge](https://www.ardu-badge.com/badge/WiFiNINA_Generic.svg?)](https://www.ardu-badge.com/WiFiNINA_Generic) if using WiFiNINA for boards such as Nano 33 IoT, nRF52, Teensy, etc.
16. [`Modified WiFi101 Library v0.16.1+`](https://github.com/khoih-prog/WiFi101) to use SAMD MKR1000, etc. boards with WiFi101.
-17. [`WiFiEspAT library v1.3.2+`](https://github.com/jandrassy/WiFiEspAT) if using ESP8288/ESP32-AT shields. [![GitHub release](https://img.shields.io/github/release/jandrassy/WiFiEspAT.svg)](https://github.com/jandrassy/WiFiEspAT/releases/latest)
+17. [`WiFiEspAT library v1.4.1+`](https://github.com/jandrassy/WiFiEspAT) if using ESP8288/ESP32-AT shields. [![GitHub release](https://img.shields.io/github/release/jandrassy/WiFiEspAT.svg)](https://github.com/jandrassy/WiFiEspAT/releases/latest)
---
---
@@ -343,13 +343,13 @@ Whenever the above-mentioned compiler error issue is fixed with the new Arduino
#### 5. For Adafruit SAMD boards
- ***To be able to compile, run and automatically detect and display BOARD_NAME on Adafruit SAMD (Itsy-Bitsy M4, etc) boards***, you have to copy the whole [Adafruit SAMD Packages_Patches](Packages_Patches/adafruit/hardware/samd/1.7.9) directory into Adafruit samd directory (~/.arduino15/packages/adafruit/hardware/samd/1.7.9).
+ ***To be able to compile, run and automatically detect and display BOARD_NAME on Adafruit SAMD (Itsy-Bitsy M4, etc) boards***, you have to copy the whole [Adafruit SAMD Packages_Patches](Packages_Patches/adafruit/hardware/samd/1.7.10) directory into Adafruit samd directory (~/.arduino15/packages/adafruit/hardware/samd/1.7.10).
-Supposing the Adafruit SAMD core version is 1.7.9. This file must be copied into the directory:
+Supposing the Adafruit SAMD core version is 1.7.10. This file must be copied into the directory:
-- `~/.arduino15/packages/adafruit/hardware/samd/1.7.9/platform.txt`
-- `~/.arduino15/packages/adafruit/hardware/samd/1.7.9/cores/arduino/Print.h`
-- `~/.arduino15/packages/adafruit/hardware/samd/1.7.9/cores/arduino/Print.cpp`
+- `~/.arduino15/packages/adafruit/hardware/samd/1.7.10/platform.txt`
+- `~/.arduino15/packages/adafruit/hardware/samd/1.7.10/cores/arduino/Print.h`
+- `~/.arduino15/packages/adafruit/hardware/samd/1.7.10/cores/arduino/Print.cpp`
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:
@@ -360,14 +360,14 @@ This file must be copied into the directory:
#### 6. For Seeeduino SAMD boards
- ***To be able to compile, run and automatically detect and display BOARD_NAME on Seeeduino SAMD (XIAO M0, Wio Terminal, etc) boards***, you have to copy the whole [Seeeduino SAMD Packages_Patches](Packages_Patches/Seeeduino/hardware/samd/1.8.2) directory into Seeeduino samd directory (~/.arduino15/packages/Seeeduino/hardware/samd/1.8.2).
+ ***To be able to compile, run and automatically detect and display BOARD_NAME on Seeeduino SAMD (XIAO M0, Wio Terminal, etc) boards***, you have to copy the whole [Seeeduino SAMD Packages_Patches](Packages_Patches/Seeeduino/hardware/samd/1.8.3) directory into Seeeduino samd directory (~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3).
-Supposing the Seeeduino SAMD core version is 1.8.2. This file must be copied into the directory:
+Supposing the Seeeduino SAMD core version is 1.8.3. This file must be copied into the directory:
-- `~/.arduino15/packages/Seeeduino/hardware/samd/1.8.2/platform.txt`
-- `~/.arduino15/packages/Seeeduino/hardware/samd/1.8.2/cores/arduino/Arduino.h`
-- `~/.arduino15/packages/Seeeduino/hardware/samd/1.8.2/cores/arduino/Print.h`
-- `~/.arduino15/packages/Seeeduino/hardware/samd/1.8.2/cores/arduino/Print.cpp`
+- `~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3/platform.txt`
+- `~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3/cores/arduino/Arduino.h`
+- `~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3/cores/arduino/Print.h`
+- `~/.arduino15/packages/Seeeduino/hardware/samd/1.8.3/cores/arduino/Print.cpp`
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:
@@ -387,12 +387,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.2.0/system/STM32F4xx) and [stm32f7xx_hal_conf_default.h](Packages_Patches/STM32/hardware/stm32/2.2.0/system/STM32F7xx) into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/2.2.0/system) to overwrite the old files.
+you have to copy the files [stm32f4xx_hal_conf_default.h](Packages_Patches/STM32/hardware/stm32/2.3.0/system/STM32F4xx) and [stm32f7xx_hal_conf_default.h](Packages_Patches/STM32/hardware/stm32/2.3.0/system/STM32F7xx) into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/2.3.0/system) to overwrite the old files.
-Supposing the STM32 stm32 core version is 2.2.0. These files must be copied into the directory:
+Supposing the STM32 stm32 core version is 2.3.0. These files must be copied into the directory:
-- `~/.arduino15/packages/STM32/hardware/stm32/2.2.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h` for STM32F4.
-- `~/.arduino15/packages/STM32/hardware/stm32/2.2.0/system/STM32F7xx/stm32f7xx_hal_conf_default.h` for Nucleo-144 STM32F7.
+- `~/.arduino15/packages/STM32/hardware/stm32/2.3.0/system/STM32F4xx/stm32f4xx_hal_conf_default.h` for STM32F4.
+- `~/.arduino15/packages/STM32/hardware/stm32/2.3.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:
@@ -403,12 +403,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.2.0) into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/2.2.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/2.3.0) into STM32 stm32 directory (~/.arduino15/packages/STM32/hardware/stm32/2.3.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.2.0. These files must be copied into the directory:
+Supposing the STM32 stm32 core version is 2.3.0. These files must be copied into the directory:
-- `~/.arduino15/packages/STM32/hardware/stm32/2.2.0/variants/STM32F7xx/F765Z(G-I)T_F767Z(G-I)T_F777ZIT/NUCLEO_F767ZI/variant.h` for Nucleo-144 NUCLEO_F767ZI.
-- `~/.arduino15/packages/STM32/hardware/stm32/2.2.0/variants/STM32L0xx/L052R(6-8)T_L053R(6-8)T_L063R8T/NUCLEO_L053R8/variant.h` for Nucleo-64 NUCLEO_L053R8.
+- `~/.arduino15/packages/STM32/hardware/stm32/2.3.0/variants/STM32F7xx/F765Z(G-I)T_F767Z(G-I)T_F777ZIT/NUCLEO_F767ZI/variant.h` for Nucleo-144 NUCLEO_F767ZI.
+- `~/.arduino15/packages/STM32/hardware/stm32/2.3.0/variants/STM32L0xx/L052R(6-8)T_L053R(6-8)T_L063R8T/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:
@@ -451,12 +451,12 @@ With core after v1.5.0, this step is not necessary anymore thanks to the PR [Add
#### 9. For Portenta_H7 boards using Arduino IDE in Linux
- **To be able to upload firmware to Portenta_H7 using Arduino IDE in Linux (Ubuntu, etc.)**, you have to copy the file [portenta_post_install.sh](Packages_Patches/arduino/hardware/mbed_portenta/3.0.0/portenta_post_install.sh) into mbed_portenta directory (~/.arduino15/packages/arduino/hardware/mbed_portenta/3.0.0/portenta_post_install.sh).
+ **To be able to upload firmware to Portenta_H7 using Arduino IDE in Linux (Ubuntu, etc.)**, you have to copy the file [portenta_post_install.sh](Packages_Patches/arduino/hardware/mbed_portenta/3.3.0/portenta_post_install.sh) into mbed_portenta directory (~/.arduino15/packages/arduino/hardware/mbed_portenta/3.3.0/portenta_post_install.sh).
Then run the following command using `sudo`
```
-$ cd ~/.arduino15/packages/arduino/hardware/mbed_portenta/3.0.0
+$ cd ~/.arduino15/packages/arduino/hardware/mbed_portenta/3.3.0
$ chmod 755 portenta_post_install.sh
$ sudo ./portenta_post_install.sh
```
@@ -469,9 +469,9 @@ This will create the file `/etc/udev/rules.d/49-portenta_h7.rules` as follows:
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="035b", GROUP="plugdev", MODE="0666"
```
-Supposing the ArduinoCore-mbed core version is 3.0.0. Now only one file must be copied into the directory:
+Supposing the ArduinoCore-mbed core version is 3.3.0. Now only one file must be copied into the directory:
-- `~/.arduino15/packages/arduino/hardware/mbed_portenta/3.0.0/portenta_post_install.sh`
+- `~/.arduino15/packages/arduino/hardware/mbed_portenta/3.3.0/portenta_post_install.sh`
Whenever a new version is installed, remember to copy this files into the new version directory. For example, new version is x.yy.zz
@@ -482,11 +482,11 @@ This file must be copied into the directory:
#### 10. For RTL8720DN boards using AmebaD core
- To avoid compile error relating to PROGMEM, you have to copy the file [Realtek AmebaD core pgmspace.h](Packages_Patches/realtek/hardware/AmebaD/3.1.2/cores/arduino/avr/pgmspace.h) into Realtek AmebaD directory (~/.arduino15/packages/realtek/hardware/AmebaD/3.1.2/cores/arduino/avr/pgmspace.h).
+ To avoid compile error relating to PROGMEM, you have to copy the file [Realtek AmebaD core pgmspace.h](Packages_Patches/realtek/hardware/AmebaD/3.1.4/cores/arduino/avr/pgmspace.h) into Realtek AmebaD directory (~/.arduino15/packages/realtek/hardware/AmebaD/3.1.4/cores/arduino/avr/pgmspace.h).
-Supposing the Realtek AmebaD core version is 3.1.2. This file must be copied into the directory:
+Supposing the Realtek AmebaD core version is 3.1.4. This file must be copied into the directory:
-- `~/.arduino15/packages/realtek/hardware/AmebaD/3.1.2/cores/arduino/avr/pgmspace.h`
+- `~/.arduino15/packages/realtek/hardware/AmebaD/3.1.4/cores/arduino/avr/pgmspace.h`
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:
@@ -496,11 +496,11 @@ This file must be copied into the directory:
#### 11. For SAMD21 and SAMD51 boards using ArduinoCore-fab-sam core
- To avoid compile error relating to SAMD21/SAMD51, you have to copy the file [ArduinoCore-fab-sam core pgmspace.h](Packages_Patches/Fab_SAM_Arduino/hardware/samd/1.6.18-alpha2/boards.txt) into `ArduinoCore-fab-sam` samd directory (~/.arduino15/packages/Fab_SAM_Arduino/hardware/samd/1.6.18-alpha2/boards.txt).
+ To avoid compile error relating to SAMD21/SAMD51, you have to copy the file [ArduinoCore-fab-sam core pgmspace.h](Packages_Patches/Fab_SAM_Arduino/hardware/samd/1.7.0/boards.txt) into `ArduinoCore-fab-sam` samd directory (~/.arduino15/packages/Fab_SAM_Arduino/hardware/samd/1.7.0/boards.txt).
-Supposing the `ArduinoCore-fab-sam` samd core version is 1.6.18-alpha2. This file must be copied into the directory:
+Supposing the `ArduinoCore-fab-sam` samd core version is 1.7.0. This file must be copied into the directory:
-- `~/.arduino15/packages/Fab_SAM_Arduino/hardware/samd/1.6.18-alpha2/boards.txt`
+- `~/.arduino15/packages/Fab_SAM_Arduino/hardware/samd/1.7.0/boards.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:
@@ -591,7 +591,7 @@ The current library implementation, using `xyz-Impl.h` instead of standard `xyz.
You can include this `.hpp` file
-```
+```cpp
// Can be included as many times as necessary, without `Multiple Definitions` Linker Error
#include "MDNS_Generic.hpp" //https://github.com/khoih-prog/MDNS_Generic
@@ -601,7 +601,7 @@ You can include this `.hpp` file
in many files. But be sure to use the following `.h` file **in just 1 `.h`, `.cpp` or `.ino` file**, which must **not be included in any other file**, to avoid `Multiple Definitions` Linker Error
-```
+```cpp
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include "MDNS_Generic.h" //https://github.com/khoih-prog/MDNS_Generic
@@ -758,7 +758,7 @@ This is terminal debug output when running [ResolvingHostNames](examples/Etherne
```
Starting ResolvingHostNames on NRF52840_FEATHER with W5x00 using Ethernet_Generic Library
-MDNS_Generic v1.4.1
+MDNS_Generic v1.4.2
[MDNS] =========== USE_ETHERNET_GENERIC ===========
[MDNS] Default SPI pinout:
[MDNS] MOSI: 25
@@ -794,7 +794,7 @@ This is terminal debug output when running [DiscoveringServices](examples/Ethern
```
Start DiscoveringServices on NRF52840_FEATHER using W5x00 using Ethernet_Generic Library
-MDNS_Generic v1.4.1
+MDNS_Generic v1.4.2
[MDNS] =========== USE_ETHERNET_GENERIC ===========
[MDNS] Default SPI pinout:
[MDNS] MOSI: 25
@@ -831,7 +831,7 @@ This is terminal debug output when running [ResolvingHostNames](examples/Etherne
```
Starting ResolvingHostNames on SEEED_XIAO_M0 with W5x00 using Ethernet_Generic Library
-MDNS_Generic v1.4.1
+MDNS_Generic v1.4.2
=========================
Default SPI pinout:
MOSI:10
@@ -867,7 +867,7 @@ This is terminal debug output when running [DiscoveringServices](examples/Ethern
```
Starting DiscoveringServices on NUCLEO_F767ZI with W5x00 using Ethernet_Generic Library
-MDNS_Generic v1.4.1
+MDNS_Generic v1.4.2
=========================
Default SPI pinout:
MOSI:11
@@ -903,7 +903,7 @@ This is terminal debug output when running [ResolvingHostNames](examples/Etherne
```
Starting ResolvingHostNames on NUCLEO_F767ZI with W5x00 using Ethernet_Generic Library
-MDNS_Generic v1.4.1
+MDNS_Generic v1.4.2
=========================
Default SPI pinout:
MOSI:11
@@ -939,7 +939,7 @@ This is terminal debug output when running [ResolvingHostNames](examples/Etherne
```
Starting ResolvingHostNames on RASPBERRY_PI_PICO with W5x00 using Ethernet_Generic Library
-MDNS_Generic v1.4.1
+MDNS_Generic v1.4.2
=========================
Default SPI pinout:
MOSI:19
@@ -975,7 +975,7 @@ This is terminal debug output when running [DiscoveringServices](examples/Ethern
```
Start DiscoveringServices on MBED RASPBERRY_PI_PICO using W5x00 using Ethernet_Generic Library
-MDNS_Generic v1.4.1
+MDNS_Generic v1.4.2
=========================
Default SPI pinout:
MOSI:19
@@ -1010,7 +1010,7 @@ This is terminal debug output when running [WiFiRegisteringServices](examples/Wi
```
Start WiFiRegisteringServices on MBED NANO_RP2040_CONNECT
-MDNS_Generic v1.4.1
+MDNS_Generic v1.4.2
Used/default SPI pinout:
MOSI:11
MISO:12
@@ -1052,7 +1052,7 @@ This is terminal debug output when running [WiFiRegisteringServices](examples/Wi
```
Start WiFiRegisteringServices on ESP32_DEV
-MDNS_Generic v1.4.1
+MDNS_Generic v1.4.2
Attempting to connect to SSID: HueNet1
SSID: HueNet1
Local IP address: 192.168.2.80
@@ -1093,7 +1093,7 @@ This is terminal debug output when running [RegisteringServices](examples/WiFi/R
```
Start RegisteringServices on NRF52840_FEATHER using W5x00 using Ethernet_Generic Library
-MDNS_Generic v1.4.1
+MDNS_Generic v1.4.2
[MDNS] =========== USE_ETHERNET_GENERIC ===========
[MDNS] Default SPI pinout:
[MDNS] MOSI: 25
@@ -1140,7 +1140,7 @@ This is terminal debug output when running [RegisteringServices](examples/WiFi/R
```
Start WiFiRegisteringServices on PORTENTA_H7_M7
-MDNS_Generic v1.4.1
+MDNS_Generic v1.4.2
Attempting to connect to SSID: HueNet1
SSID: HueNet1
Local IP address: 192.168.2.94
@@ -1182,7 +1182,7 @@ This is terminal debug output when running [RegisteringServices](examples/WiFi/R
```
Start RegisteringServices on PORTENTA_H7_M7 using Ethernet using Portenta_Ethernet Library
-MDNS_Generic v1.4.1
+MDNS_Generic v1.4.2
=========================
Default SPI pinout:
MOSI:8
@@ -1305,13 +1305,18 @@ Submit issues to: [**MDNS_Generic issues**](https://github.com/khoih-prog/MDNS_G
### Contributions and Thanks
1. Based on and modified from [TrippyLighting's EthernetBonjour](https://github.com/TrippyLighting/EthernetBonjour) and [Dario Pennisi's ArduinoMDNS](https://github.com/arduino-libraries/ArduinoMDNS)
-2. Thanks to [Zuroy](https://github.com/Zuroy) to report the issue in [Portenta H7 MDNS Library compatibility #4](https://github.com/khoih-prog/MDNS_Generic/issues/4) then post an issue on [`ArduinoCore-mbed`](https://github.com/arduino/ArduinoCore-mbed) leading to a fix in [SocketWrapper: UDP: send packet on endPacket(), not on write() #337](https://github.com/arduino/ArduinoCore-mbed/pull/337) leading to the new version v1.3.0 to provide support to **Portenta_H7** using either Murata WiFi or Vision-shield Ethernet.
+2. Thanks to [Zuroy](https://github.com/Zuroy) to report the issue in [Portenta H7 MDNS Library compatibility #4](https://github.com/khoih-prog/MDNS_Generic/issues/4) then post an issue on [`ArduinoCore-mbed`](https://github.com/arduino/ArduinoCore-mbed) leading to a fix in [SocketWrapper: UDP: send packet on endPacket(), not on write() #337](https://github.com/arduino/ArduinoCore-mbed/pull/337) leading to the new version v1.3.0 to provide support to **Portenta_H7** using either Murata WiFi or Vision-shield Ethernet
+3. Thanks to [Haroun Hajem](https://github.com/harounhajem) to report the issue in [Example code in WiFiDiscoveringServices not working on Arduino MKR WiFi 1010, found "\r\n" in serial input. #12](https://github.com/khoih-prog/MDNS_Generic/issues/12) leading to the new version v1.4.2 to fix bug
+4. Thanks to [2001herne](https://github.com/2001herne) to report the issue in [UDP Length check discards correct responses when resolving names - On Nano RP2040 Connect #13](https://github.com/khoih-prog/MDNS_Generic/issues/13) leading to the new version v1.4.2 to fix bug
+
diff --git a/changelog.md b/changelog.md
index f4d2d12..bc1a448 100644
--- a/changelog.md
+++ b/changelog.md
@@ -13,6 +13,7 @@
## Table of Contents
* [Changelog](#changelog)
+ * [Releases v1.4.2](#releases-v142)
* [Releases v1.4.1](#releases-v141)
* [Releases v1.4.0](#releases-v140)
* [Releases v1.3.1](#releases-v131)
@@ -29,6 +30,12 @@
## Changelog
+### Releases v1.4.2
+
+1. Fix bug in UDP length check and in WiFi example. Check [UDP Length check discards correct responses when resolving names - On Nano RP2040 Connect #13](https://github.com/khoih-prog/MDNS_Generic/issues/13)
+2. Fix bug in example [WiFiDiscoveringServices](https://github.com/khoih-prog/MDNS_Generic/tree/master/examples/WiFi/WiFiDiscoveringServices)
+3. Update `Packages' Patches`
+
### Releases v1.4.1
1. Use new [Ethernet_Generic library](https://github.com/khoih-prog/Ethernet_Generic) as default for W5x00.
diff --git a/examples/Ethernet/DiscoveringServices/defines.h b/examples/Ethernet/DiscoveringServices/defines.h
index b547297..cc89ad1 100644
--- a/examples/Ethernet/DiscoveringServices/defines.h
+++ b/examples/Ethernet/DiscoveringServices/defines.h
@@ -26,7 +26,7 @@
#define MDNS_DEBUG_PORT Serial
// Debug Level from 0 to 4
-#define _MDNS_LOGLEVEL_ 2
+#define _MDNS_LOGLEVEL_ 1
#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \
|| defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \
diff --git a/examples/Ethernet/ResolvingHostNames/defines.h b/examples/Ethernet/ResolvingHostNames/defines.h
index c74be3c..ecb7b27 100644
--- a/examples/Ethernet/ResolvingHostNames/defines.h
+++ b/examples/Ethernet/ResolvingHostNames/defines.h
@@ -26,7 +26,7 @@
#define MDNS_DEBUG_PORT Serial
// Debug Level from 0 to 4
-#define _MDNS_LOGLEVEL_ 2
+#define _MDNS_LOGLEVEL_ 1
#if ( defined(ARDUINO_SAMD_ZERO) || defined(ARDUINO_SAMD_MKR1000) || defined(ARDUINO_SAMD_MKRWIFI1010) \
|| defined(ARDUINO_SAMD_NANO_33_IOT) || defined(ARDUINO_SAMD_MKRFox1200) || defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) \
diff --git a/examples/WiFi/WiFiDiscoveringServices/WiFiDiscoveringServices.ino b/examples/WiFi/WiFiDiscoveringServices/WiFiDiscoveringServices.ino
index 14de299..a3f9253 100644
--- a/examples/WiFi/WiFiDiscoveringServices/WiFiDiscoveringServices.ino
+++ b/examples/WiFi/WiFiDiscoveringServices/WiFiDiscoveringServices.ino
@@ -1,23 +1,23 @@
/****************************************************************************************************************************
WiFiDiscoveringServices.ino
-
+
mDNS library to support mDNS (registering services) and DNS-SD (service discovery).
-
+
Based on and modified from https://github.com/arduino-libraries/ArduinoMDNS
Built by Khoi Hoang https://github.com/khoih-prog/MDNS_Generic
Licensed under MIT license
-
+
Original Author: Georg Kaindl (http://gkaindl.com)
-
+
This file is part of Arduino EthernetBonjour.
-
+
EthernetBonjour is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
-
+
EthernetBonjour is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License along with EthernetBonjour.
+
+ You should have received a copy of the GNU Lesser General Public License along with EthernetBonjour.
If not, see .
*****************************************************************************************************************************/
@@ -32,22 +32,22 @@
#else
#if !defined(WIFI_NETWORK_TYPE)
- // Select one, but WIFI_NETWORK_ESP
- #warning You have to select a WiFi Network here, or default will be used => possibly creating error.
-
- #define WIFI_NETWORK_TYPE NETWORK_WIFI_DEFAULT
- //#define WIFI_NETWORK_TYPE WIFI_NETWORK_WIFININA
- //#define WIFI_NETWORK_TYPE WIFI_NETWORK_WIFI101
- //#define WIFI_NETWORK_TYPE WIFI_NETWORK_ESPAT
- //#define WIFI_NETWORK_TYPE WIFI_NETWORK_ESP
- //#define WIFI_NETWORK_TYPE WIFI_NETWORK_PORTENTA_H7
+ // Select one, but WIFI_NETWORK_ESP
+ #warning You have to select a WiFi Network here, or default will be used => possibly creating error.
+
+ #define WIFI_NETWORK_TYPE NETWORK_WIFI_DEFAULT
+ //#define WIFI_NETWORK_TYPE WIFI_NETWORK_WIFININA
+ //#define WIFI_NETWORK_TYPE WIFI_NETWORK_WIFI101
+ //#define WIFI_NETWORK_TYPE WIFI_NETWORK_ESPAT
+ //#define WIFI_NETWORK_TYPE WIFI_NETWORK_ESP
+ //#define WIFI_NETWORK_TYPE WIFI_NETWORK_PORTENTA_H7
#endif
-
+
String hostname = BOARD_TYPE;
-
#endif
#if (WIFI_NETWORK_TYPE == WIFI_NETWORK_WIFININA)
+
#include
#include
#include
@@ -56,6 +56,7 @@
WiFiServer server(80);
#elif (WIFI_NETWORK_TYPE == WIFI_NETWORK_WIFI101)
+
#include
#include
#include
@@ -98,7 +99,7 @@
#else
#error You have to select an appropriate WiFi network type from the list
-
+
#endif
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
@@ -134,57 +135,45 @@ void printWifiStatus()
Serial.println(" dBm");
}
-// This function is called when a name is resolved via mMDNS/Bonjour. We set
-// this up in the setup() function above. The name you give to this callback
-// function does not matter at all, but it must take exactly these arguments
-// as below.
-// If a service is discovered, name, ipAddr, port and (if available) txtContent
-// will be set.
-// If your specified discovery timeout is reached, the function will be called
-// with name (and all successive arguments) being set to NULL.
-void serviceFound(const char* type, MDNSServiceProtocol /*proto*/,
- const char* name, IPAddress ip,
- unsigned short port,
- const char* txtContent)
+// This function is called when a name is resolved via MDNS/Bonjour. We set this up in the setup() function above. The name you give to this callback
+// function does not matter at all, but it must take exactly these arguments as below. If a service is discovered, name, ipAddr, port and (if available)
+// txtContent will be set. If your specified discovery timeout is reached, the function will be called with name (and all successive arguments) being set to NULL.
+void serviceFound(const char* type, MDNSServiceProtocol /*proto*/, const char* name, IPAddress ip,
+ unsigned short port, const char* txtContent)
{
- if (NULL == name)
+ if (NULL == name)
{
Serial.print("Finished discovering services of type ");
Serial.println(type);
- }
- else
+ }
+ else
{
- Serial.print("Found: '");
- Serial.print(name);
- Serial.print("' at ");
- Serial.print(ip);
- Serial.print(", port ");
- Serial.print(port);
- Serial.println(" (TCP)");
-
- // Check out http://www.zeroconf.org/Rendezvous/txtrecords.html for a
- // primer on the structure of TXT records. Note that the Bonjour
- // library will always return the txt content as a zero-terminated
- // string, even if the specification does not require this.
- if (txtContent)
+ Serial.print("Found: '"); Serial.print(name);
+ Serial.print("' at "); Serial.print(ip);
+ Serial.print(", port "); Serial.print(port); Serial.println(" (TCP)");
+
+ // Check out http://www.zeroconf.org/Rendezvous/txtrecords.html for a primer on the structure of TXT records. Note that the Bonjour
+ // library will always return the txt content as a zero-terminated string, even if the specification does not require this.
+ if (txtContent)
{
Serial.print("\ttxt record: ");
-
+
char buf[256];
char len = *txtContent++;
- int i = 0;
-
- while (len)
+ int i=0;
+
+ while (len)
{
i = 0;
-
+
while (len--)
buf[i++] = *txtContent++;
-
+
buf[i] = '\0';
+
Serial.print(buf);
len = *txtContent++;
-
+
if (len)
Serial.print(", ");
else
@@ -198,7 +187,7 @@ void setup()
{
//Initialize serial and wait for port to open:
Serial.begin(115200);
- while (!Serial);
+ while (!Serial && millis() < 5000);
Serial.print("\nStart WiFiDiscoveringServices on "); Serial.println(BOARD_NAME);
Serial.println(MDNS_GENERIC_VERSION);
@@ -238,18 +227,14 @@ void setup()
#endif
Serial.print("Attempting to connect to SSID: "); Serial.println(ssid);
-
+
WiFi.begin(ssid, pass);
-
+
delay(1000);
-
- // attempt to connect to Wifi network:
- while (status != WL_CONNECTED)
- {
- // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
- status = WiFi.status();
- delay(1000);
+ while (WiFi.status() != WL_CONNECTED)
+ {
+ delay(500);
}
printWifiStatus();
@@ -280,45 +265,43 @@ void setup()
}
void loop()
-{
+{
char serviceName[256];
- int length = 0;
-
+ uint8_t length = 0;
+
// read in a service name from the Arduino IDE's serial monitor.
- while (Serial.available())
+ while (Serial.available())
{
serviceName[length] = Serial.read();
- length = (length + 1) % 256;
+ length = (length+1) % 256;
delay(5);
}
+ // Terminal adds "\r\n", need to remove
+ if (length > 1)
+ length = (length - 2) % 256;
+
serviceName[length] = '\0';
-
- // You can use the "isDiscoveringService()" function to find out whether the
- // mDNS library is currently discovering service instances.
+
+ // You can use the "isDiscoveringService()" function to find out whether the Bonjour library is currently discovering service instances.
// If so, we skip this input, since we want our previous request to continue.
- if (!mdns.isDiscoveringService())
+ if (!mdns.isDiscoveringService())
{
- if (length > 0)
+ if (length > 0)
{
Serial.print("Discovering services of type '");
Serial.print(serviceName);
Serial.println("' via Multi-Cast DNS (Bonjour)...");
- // Now we tell the mDNS library to discover the service. Below, I have
- // hardcoded the TCP protocol, but you can also specify to discover UDP
- // services.
- // The last argument is a duration (in milliseconds) for which we will
- // search (specify 0 to run the discovery indefinitely).
- // Note that the library will resend the discovery message every 10
- // seconds, so if you search for longer than that, you will receive
- // duplicate instances.
+ // Now we tell the mDNS library to discover the service. Below, I have hardcoded the TCP protocol, but you can also specify to discover UDP services.
+ // The last argument is a duration (in milliseconds) for which we will search (specify 0 to run the discovery indefinitely). Note that the library
+ // will resend the discovery message every 10 seconds, so if you search for longer than that, you will receive duplicate instances.
mdns.startDiscoveringService(serviceName, MDNSServiceTCP, 5000);
- }
+ }
}
- // This actually runs the mDNS module. YOU HAVE TO CALL THIS PERIODICALLY,
+ // This actually runs the Bonjour module. YOU HAVE TO CALL THIS PERIODICALLY,
// OR NOTHING WILL WORK!
// Preferably, call it once per loop().
mdns.run();
diff --git a/examples/WiFi/WiFiRegisteringServices/WiFiRegisteringServices.ino b/examples/WiFi/WiFiRegisteringServices/WiFiRegisteringServices.ino
index f4ad5be..2f4d8fa 100644
--- a/examples/WiFi/WiFiRegisteringServices/WiFiRegisteringServices.ino
+++ b/examples/WiFi/WiFiRegisteringServices/WiFiRegisteringServices.ino
@@ -179,13 +179,9 @@ void setup()
delay(1000);
- // attempt to connect to Wifi network:
- while (status != WL_CONNECTED)
- {
- // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
- status = WiFi.status();
-
- delay(1000);
+ while (WiFi.status() != WL_CONNECTED)
+ {
+ delay(500);
}
printWifiStatus();
diff --git a/examples/WiFi/WiFiRegisteringServicesWithTxtRecord/WiFiRegisteringServicesWithTxtRecord.ino b/examples/WiFi/WiFiRegisteringServicesWithTxtRecord/WiFiRegisteringServicesWithTxtRecord.ino
index 33b7ee0..a101231 100644
--- a/examples/WiFi/WiFiRegisteringServicesWithTxtRecord/WiFiRegisteringServicesWithTxtRecord.ino
+++ b/examples/WiFi/WiFiRegisteringServicesWithTxtRecord/WiFiRegisteringServicesWithTxtRecord.ino
@@ -179,13 +179,9 @@ void setup()
delay(1000);
- // attempt to connect to Wifi network:
- while (status != WL_CONNECTED)
- {
- // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
- status = WiFi.status();
-
- delay(1000);
+ while (WiFi.status() != WL_CONNECTED)
+ {
+ delay(500);
}
printWifiStatus();
diff --git a/examples/WiFi/WiFiResolvingHostNames/WiFiResolvingHostNames.ino b/examples/WiFi/WiFiResolvingHostNames/WiFiResolvingHostNames.ino
index 4ac8429..4cd85e3 100644
--- a/examples/WiFi/WiFiResolvingHostNames/WiFiResolvingHostNames.ino
+++ b/examples/WiFi/WiFiResolvingHostNames/WiFiResolvingHostNames.ino
@@ -140,8 +140,8 @@ void printWifiStatus()
// the name resolution timed out).
void nameFound(const char* name, IPAddress ip)
{
- //if ( (ip[0] != 0) && (ip[1] != 0) && (ip[2] != 0) && (ip[3] != 0) )
- if ( (ip[0] != 0) || (ip[1] != 0) || (ip[2] != 0) || (ip[3] != 0) )
+ if ( (ip[0] != 0) && (ip[1] != 0) && (ip[2] != 0) && (ip[3] != 0) )
+ //if ( (ip[0] != 0) || (ip[1] != 0) || (ip[2] != 0) || (ip[3] != 0) )
{
Serial.print("The IP address for '");
Serial.print(name);
@@ -216,13 +216,9 @@ void setup()
delay(1000);
- // attempt to connect to Wifi network:
- while (status != WL_CONNECTED)
- {
- // Connect to WPA/WPA2 network. Change this line if using open or WEP network:
- status = WiFi.status();
-
- delay(1000);
+ while (WiFi.status() != WL_CONNECTED)
+ {
+ delay(500);
}
printWifiStatus();
diff --git a/examples/WiFi/WiFiResolvingHostNames/defines.h b/examples/WiFi/WiFiResolvingHostNames/defines.h
index 1a9ab25..b013e51 100644
--- a/examples/WiFi/WiFiResolvingHostNames/defines.h
+++ b/examples/WiFi/WiFiResolvingHostNames/defines.h
@@ -26,7 +26,7 @@
#define SYSTEM_ENDIAN _ENDIAN_BIG_
#define MDNS_DEBUG_PORT Serial
-#define _MDNS_LOGLEVEL_ 4
+#define _MDNS_LOGLEVEL_ 1
#define DEBUG_WIFININA_PORT Serial
// Debug Level from 0 to 4
diff --git a/library.json b/library.json
index a7c1786..612730f 100644
--- a/library.json
+++ b/library.json
@@ -1,6 +1,6 @@
{
"name": "MDNS_Generic",
- "version": "1.4.1",
+ "version": "1.4.2",
"keywords": "Communication, mDNS, dns-sd, mbed, apple-bonjour, Ethernet, Teensy, samd, nrf52, stm32, nano-rp2040-connect, rp2040, rpi-pico, Portenta-H7, SAM DUE, Mega, AVR, W5100, W5500, w5x00, Ethernet shield",
"description": "mDNS Library for ESP32, ESP8266, nRF52, SAMD21, SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, Portenta_H7, AVR Mega, RP2040-based boards, etc. using Ethernet W5x00, ESP WiFi, WiFiNINA or ESP8266-AT shields. Supports mDNS (Registering Services) and DNS-SD (Service Discovery). Ethernet_Generic library is used as default for W5x00",
"authors": [
@@ -34,7 +34,7 @@
{
"owner": "khoih-prog",
"name": "WiFiNINA_Generic",
- "version": ">=1.8.14-3",
+ "version": ">=1.8.14-6",
"platforms": ["*"]
},
{
@@ -44,16 +44,16 @@
{
"owner": "jandrassy",
"name": "WiFiEspAT",
- "version": ">=1.3.2",
+ "version": ">=1.4.1",
"platforms": ["*"]
},
{
"owner": "khoih-prog",
"name": "Ethernet_Generic",
- "version": "^2.0.1"
+ "version": "^2.6.1"
}
],
- "license": "MIT",
+ "license": "LGPL-3.0",
"frameworks": "*",
"platforms": "*",
"examples": "examples/*/*/*.ino",
diff --git a/library.properties b/library.properties
index 46e7390..8973e11 100644
--- a/library.properties
+++ b/library.properties
@@ -1,5 +1,5 @@
name=MDNS_Generic
-version=1.4.1
+version=1.4.2
author=Georg Kaindl , Khoi Hoang
maintainer=Khoi Hoang
sentence=mDNS Library for ESP32, ESP8266, nRF52, SAMD21, SAMD51, SAM DUE, STM32F/L/H/G/WB/MP1, Portenta_H7, AVR Mega, RP2040-based boards, etc. using Ethernet W5x00, ESP WiFi, WiFiNINA or ESP8266-AT shields
diff --git a/platformio/platformio.ini b/platformio/platformio.ini
index 8f59b6f..7d35b83 100644
--- a/platformio/platformio.ini
+++ b/platformio/platformio.ini
@@ -36,16 +36,19 @@ upload_speed = 921600
;monitor_port = COM11
; Checks for the compatibility with frameworks and dev/platforms
+; Adjust as necessary
lib_compat_mode = strict
+lib_ldf_mode = chain+
+;lib_ldf_mode = deep+
lib_deps =
; PlatformIO 4.x
-; WiFiNINA_Generic@>=1.8.14-3
-; Ethernet_Generic@>=2.0.1
+; WiFiNINA_Generic@>=1.8.14-6
+; Ethernet_Generic@>=2.6.1
; PlatformIO 5.x
- khoih-prog/WiFiNINA_Generic@>=1.8.14-3
- Ethernet_Generic@>=2.0.1
+ khoih-prog/WiFiNINA_Generic@>=1.8.14-6
+ Ethernet_Generic@>=2.6.1
build_flags =
; set your debug output (default=Serial)
diff --git a/src/MDNS_EthernetUtil_Impl.h b/src/MDNS_EthernetUtil_Impl.h
index b065a0e..3f3ffb4 100644
--- a/src/MDNS_EthernetUtil_Impl.h
+++ b/src/MDNS_EthernetUtil_Impl.h
@@ -20,17 +20,18 @@
You should have received a copy of the GNU Lesser General Public License along with EthernetBonjour.
If not, see .
- Version: 1.4.1
+ Version: 1.4.2
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 01/08/2020 Initial coding to support W5x00 using Ethernet, EthernetLarge libraries
- Supported boards: nRF52, STM32, SAMD21/SAMD51, SAM DUE, Mega
+ Supported boards: nRF52, STM32, SAMD21/SAMD51, SAM DUE, Mega
...
1.3.0 K Hoang 28/09/2021 Add support to Portenta_H7, using WiFi or Ethernet
1.3.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json`
1.4.0 K Hoang 26/01/2022 Fix `multiple-definitions` linker error
1.4.1 K Hoang 11/04/2022 Use Ethernet_Generic library as default. Support SPI1/SPI2 for RP2040/ESP32
+ 1.4.2 K Hoang 12/10/2022 Fix bugs in UDP length check and in WiFi example
*****************************************************************************************************************************/
#ifndef __MDNS_ETHERNET_UTIL_IMPL_H__
@@ -40,11 +41,15 @@
#include
+////////////////////////////////////////
+
#if defined(__ETHERNET_UTIL_BONJOUR__)
uint16_t ethutil_swaps(uint16_t i);
uint32_t ethutil_swapl(uint32_t l);
+////////////////////////////////////////
+
extern uint16_t ethutil_htons(unsigned short hostshort)
{
#if ( SYSTEM_ENDIAN == _ENDIAN_LITTLE_ )
@@ -54,6 +59,8 @@ extern uint16_t ethutil_htons(unsigned short hostshort)
#endif
}
+////////////////////////////////////////
+
extern int32_t ethutil_htonl(unsigned long hostlong)
{
#if ( SYSTEM_ENDIAN == _ENDIAN_LITTLE_ )
@@ -63,6 +70,8 @@ extern int32_t ethutil_htonl(unsigned long hostlong)
#endif
}
+////////////////////////////////////////
+
extern uint16_t ethutil_ntohs(unsigned short netshort)
{
#if ( SYSTEM_ENDIAN == _ENDIAN_LITTLE_ )
@@ -72,6 +81,8 @@ extern uint16_t ethutil_ntohs(unsigned short netshort)
#endif
}
+////////////////////////////////////////
+
extern uint32_t ethutil_ntohl(unsigned long netlong)
{
#if ( SYSTEM_ENDIAN == _ENDIAN_LITTLE_ )
@@ -81,6 +92,8 @@ extern uint32_t ethutil_ntohl(unsigned long netlong)
#endif
}
+////////////////////////////////////////
+
// #pragma mark -
// #pragma mark Private
@@ -94,6 +107,8 @@ uint16_t ethutil_swaps(uint16_t i)
return ret;
}
+////////////////////////////////////////
+
uint32_t ethutil_swapl(uint32_t l)
{
uint32_t ret = 0;
@@ -106,6 +121,8 @@ uint32_t ethutil_swapl(uint32_t l)
return ret;
}
+////////////////////////////////////////
+
#endif // __ETHERNET_UTIL_BONJOUR__
#endif // __MDNS_ETHERNET_UTIL_IMPL_H__
diff --git a/src/MDNS_Generic.h b/src/MDNS_Generic.h
index 8f0c4eb..5d531d7 100644
--- a/src/MDNS_Generic.h
+++ b/src/MDNS_Generic.h
@@ -20,17 +20,18 @@
You should have received a copy of the GNU Lesser General Public License along with EthernetBonjour.
If not, see .
- Version: 1.4.1
+ Version: 1.4.2
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 01/08/2020 Initial coding to support W5x00 using Ethernet, EthernetLarge libraries
- Supported boards: nRF52, STM32, SAMD21/SAMD51, SAM DUE, Mega
+ Supported boards: nRF52, STM32, SAMD21/SAMD51, SAM DUE, Mega
...
1.3.0 K Hoang 28/09/2021 Add support to Portenta_H7, using WiFi or Ethernet
1.3.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json`
1.4.0 K Hoang 26/01/2022 Fix `multiple-definitions` linker error
1.4.1 K Hoang 11/04/2022 Use Ethernet_Generic library as default. Support SPI1/SPI2 for RP2040/ESP32
+ 1.4.2 K Hoang 12/10/2022 Fix bugs in UDP length check and in WiFi example
*****************************************************************************************************************************/
#ifndef __MDNS_GENERIC_H__
diff --git a/src/MDNS_Generic.hpp b/src/MDNS_Generic.hpp
index 3069a30..58d90f7 100644
--- a/src/MDNS_Generic.hpp
+++ b/src/MDNS_Generic.hpp
@@ -20,42 +20,50 @@
You should have received a copy of the GNU Lesser General Public License along with EthernetBonjour.
If not, see .
- Version: 1.4.1
+ Version: 1.4.2
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 01/08/2020 Initial coding to support W5x00 using Ethernet, EthernetLarge libraries
- Supported boards: nRF52, STM32, SAMD21/SAMD51, SAM DUE, Mega
+ Supported boards: nRF52, STM32, SAMD21/SAMD51, SAM DUE, Mega
...
1.3.0 K Hoang 28/09/2021 Add support to Portenta_H7, using WiFi or Ethernet
1.3.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json`
1.4.0 K Hoang 26/01/2022 Fix `multiple-definitions` linker error
1.4.1 K Hoang 11/04/2022 Use Ethernet_Generic library as default. Support SPI1/SPI2 for RP2040/ESP32
+ 1.4.2 K Hoang 12/10/2022 Fix bugs in UDP length check and in WiFi example
*****************************************************************************************************************************/
#ifndef __MDNS_GENERIC_HPP__
#define __MDNS_GENERIC_HPP__
+////////////////////////////////////////
+
#ifndef MDNS_GENERIC_VERSION
- #define MDNS_GENERIC_VERSION "MDNS_Generic v1.4.1"
+ #define MDNS_GENERIC_VERSION "MDNS_Generic v1.4.2"
#define MDNS_GENERIC_VERSION_MAJOR 1
#define MDNS_GENERIC_VERSION_MINOR 4
- #define MDNS_GENERIC_VERSION_PATCH 1
-
-#define MDNS_GENERIC_VERSION_INT 1004001
+ #define MDNS_GENERIC_VERSION_PATCH 2
+ #define MDNS_GENERIC_VERSION_INT 1004002
#endif
+////////////////////////////////////////
+
extern "C"
{
#include
}
+////////////////////////////////////////
+
#include
#include "MDNS_Generic_Debug.h"
+////////////////////////////////////////
+
#if (_MDNS_LOGLEVEL_ > 2)
#if ( SYSTEM_ENDIAN == _ENDIAN_LITTLE_ )
#warning SYSTEM_ENDIAN == _ENDIAN_LITTLE_
@@ -64,6 +72,8 @@ extern "C"
#endif
#endif
+////////////////////////////////////////
+
typedef uint8_t byte;
typedef enum _MDNSState_t
@@ -112,8 +122,12 @@ typedef struct _MDNSServiceRecord_t
typedef void (*MDNSNameFoundCallback)(const char*, IPAddress);
typedef void (*MDNSServiceFoundCallback)(const char*, MDNSServiceProtocol_t, const char*, IPAddress, unsigned short, const char*);
+////////////////////////////////////////
+
#define NumMDNSServiceRecords (8)
+////////////////////////////////////////
+
//class MDNS
class MDNS
{
diff --git a/src/MDNS_Generic_Debug.h b/src/MDNS_Generic_Debug.h
index d3d2d20..2ff1175 100644
--- a/src/MDNS_Generic_Debug.h
+++ b/src/MDNS_Generic_Debug.h
@@ -20,17 +20,18 @@
You should have received a copy of the GNU Lesser General Public License along with EthernetBonjour.
If not, see .
- Version: 1.4.1
+ Version: 1.4.2
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 01/08/2020 Initial coding to support W5x00 using Ethernet, EthernetLarge libraries
- Supported boards: nRF52, STM32, SAMD21/SAMD51, SAM DUE, Mega
+ Supported boards: nRF52, STM32, SAMD21/SAMD51, SAM DUE, Mega
...
1.3.0 K Hoang 28/09/2021 Add support to Portenta_H7, using WiFi or Ethernet
1.3.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json`
1.4.0 K Hoang 26/01/2022 Fix `multiple-definitions` linker error
1.4.1 K Hoang 11/04/2022 Use Ethernet_Generic library as default. Support SPI1/SPI2 for RP2040/ESP32
+ 1.4.2 K Hoang 12/10/2022 Fix bugs in UDP length check and in WiFi example
*****************************************************************************************************************************/
#ifndef MDNS_Debug_H
diff --git a/src/MDNS_Generic_Impl.h b/src/MDNS_Generic_Impl.h
index 24a6863..55ba024 100644
--- a/src/MDNS_Generic_Impl.h
+++ b/src/MDNS_Generic_Impl.h
@@ -20,17 +20,18 @@
You should have received a copy of the GNU Lesser General Public License along with EthernetBonjour.
If not, see .
- Version: 1.4.1
+ Version: 1.4.2
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 01/08/2020 Initial coding to support W5x00 using Ethernet, EthernetLarge libraries
- Supported boards: nRF52, STM32, SAMD21/SAMD51, SAM DUE, Mega
+ Supported boards: nRF52, STM32, SAMD21/SAMD51, SAM DUE, Mega
...
1.3.0 K Hoang 28/09/2021 Add support to Portenta_H7, using WiFi or Ethernet
1.3.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json`
1.4.0 K Hoang 26/01/2022 Fix `multiple-definitions` linker error
1.4.1 K Hoang 11/04/2022 Use Ethernet_Generic library as default. Support SPI1/SPI2 for RP2040/ESP32
+ 1.4.2 K Hoang 12/10/2022 Fix bugs in UDP length check and in WiFi example
*****************************************************************************************************************************/
#ifndef __MDNS_GENERIC_IMPL_H__
@@ -39,6 +40,8 @@
#define HAS_SERVICE_REGISTRATION 1 // disabling saves about 1.25 kilobytes
#define HAS_NAME_BROWSING 1 // disable together with above, additionally saves about 4.3 kilobytes
+////////////////////////////////////////
+
#include
#include
@@ -50,6 +53,8 @@
#include "MDNS_EthernetUtil_Impl.h"
+////////////////////////////////////////
+
#define MDNS_DEFAULT_NAME "arduino"
#define MDNS_TLD ".local"
#define DNS_SD_SERVICE "_services._dns-sd._udp.local"
@@ -63,12 +68,16 @@
//#define _BROKEN_MALLOC_ 1
#undef _USE_MALLOC_
+////////////////////////////////////////
+
//static uint8_t mdnsMulticastIPAddr[] = { 224, 0, 0, 251 };
static IPAddress mdnsMulticastIPAddr = IPAddress(224, 0, 0, 251);
//static uint8_t mdnsHWAddr[] = { 0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb };
+////////////////////////////////////////
+
typedef enum _MDNSPacketType_t
{
MDNSPacketTypeMyIPAnswer,
@@ -79,6 +88,8 @@ typedef enum _MDNSPacketType_t
MDNSPacketTypeServiceQuery,
} MDNSPacketType_t;
+////////////////////////////////////////
+
typedef struct _DNSHeader_t
{
uint16_t xid;
@@ -98,6 +109,8 @@ typedef struct _DNSHeader_t
uint16_t additionalCount;
} __attribute__((__packed__)) DNSHeader_t;
+////////////////////////////////////////
+
typedef enum _DNSOpCode_t
{
DNSOpQuery = 0,
@@ -107,6 +120,8 @@ typedef enum _DNSOpCode_t
DNSOpUpdate = 5
} DNSOpCode_t;
+////////////////////////////////////////
+
// for some reason, I get data corruption issues with normal malloc() on arduino 0017
void* my_malloc(unsigned s)
{
@@ -122,6 +137,8 @@ void* my_malloc(unsigned s)
#endif
}
+////////////////////////////////////////
+
void my_free(void* ptr)
{
#if defined(_BROKEN_MALLOC_)
@@ -136,6 +153,9 @@ void my_free(void* ptr)
#endif
}
+////////////////////////////////////////
+////////////////////////////////////////
+
MDNS::MDNS(UDP& udp)
{
memset(&this->_mdnsData, 0, sizeof(MDNSDataInternal_t));
@@ -152,11 +172,15 @@ MDNS::MDNS(UDP& udp)
this->_lastAnnounceMillis = 0;
}
+////////////////////////////////////////
+
MDNS::~MDNS()
{
this->_udp->stop();
}
+////////////////////////////////////////
+
// return values:
// 1 on success
// 0 otherwise
@@ -178,13 +202,14 @@ int MDNS::begin(const IPAddress& ip, const char* name)
{
statusCode = this->_udp->beginMulticast(mdnsMulticastIPAddr, MDNS_SERVER_PORT);
- // KH debug
MDNS_LOGDEBUG1("::begin: UDP beginMulticast statusCode=", (statusCode == 1) ? "OK" : "Error");
}
return statusCode;
}
+////////////////////////////////////////
+
// return values:
// 1 on success
// 0 otherwise
@@ -193,6 +218,8 @@ int MDNS::begin(const IPAddress& ip)
return this->begin(ip, MDNS_DEFAULT_NAME);
}
+////////////////////////////////////////
+
// return values:
// 1 on success
// 0 otherwise
@@ -219,6 +246,8 @@ int MDNS::_initQuery(uint8_t idx, const char* name, unsigned long timeout)
return statusCode;
}
+////////////////////////////////////////
+
void MDNS::_cancelQuery(uint8_t idx)
{
if (NULL != this->_resolveNames[idx])
@@ -228,6 +257,8 @@ void MDNS::_cancelQuery(uint8_t idx)
}
}
+////////////////////////////////////////
+
// return values:
// 1 on success
// 0 otherwise
@@ -243,32 +274,41 @@ int MDNS::resolveName(const char* name, unsigned long timeout)
strcpy(n, name);
strcat(n, MDNS_TLD);
- // KH debug
MDNS_LOGINFO1("::resolveName: name=", n);
return this->_initQuery(0, n, timeout);
}
+////////////////////////////////////////
+
void MDNS::setNameResolvedCallback(MDNSNameFoundCallback newCallback)
{
this->_nameFoundCallback = newCallback;
}
+////////////////////////////////////////
+
void MDNS::cancelResolveName()
{
this->_cancelQuery(0);
}
+////////////////////////////////////////
+
int MDNS::isResolvingName()
{
return (NULL != this->_resolveNames[0]);
}
+////////////////////////////////////////
+
void MDNS::setServiceFoundCallback(MDNSServiceFoundCallback newCallback)
{
this->_serviceFoundCallback = newCallback;
}
+////////////////////////////////////////
+
// return values:
// 1 on success
// 0 otherwise
@@ -293,16 +333,22 @@ int MDNS::startDiscoveringService(const char* serviceName, MDNSServiceProtocol_t
return this->_initQuery(1, n, timeout);
}
+////////////////////////////////////////
+
void MDNS::stopDiscoveringService()
{
this->_cancelQuery(1);
}
+////////////////////////////////////////
+
int MDNS::isDiscoveringService()
{
return (NULL != this->_resolveNames[1]);
}
+////////////////////////////////////////
+
// return value:
// A DNSError_t (DNSSuccess on success, something else otherwise)
// in "int" mode: positive on success, negative on error
@@ -364,7 +410,6 @@ MDNSError_t MDNS::_sendMDNSMessage(uint32_t /*peerAddress*/, uint32_t xid, int t
this->_udp->beginPacket(mdnsMulticastIPAddr, MDNS_SERVER_PORT);
this->_udp->write((uint8_t*)dnsHeader, sizeof(DNSHeader_t));
- // KH debug
MDNS_LOGDEBUG1("::_sendMDNSMessage: xid=", dnsHeader->xid);
MDNS_LOGDEBUG1("::_sendMDNSMessage: queryCount=", dnsHeader->queryCount);
MDNS_LOGDEBUG1("::_sendMDNSMessage: answerCount=", dnsHeader->answerCount);
@@ -542,12 +587,13 @@ MDNSError_t MDNS::_sendMDNSMessage(uint32_t /*peerAddress*/, uint32_t xid, int t
my_free(dnsHeader);
#endif
- // KH debug
MDNS_LOGDEBUG1("::_sendMDNSMessage: statusCode =", statusCode);
return statusCode;
}
+////////////////////////////////////////
+
// return value:
// A DNSError_t (DNSSuccess on success, something else otherwise)
// in "int" mode: positive on success, negative on error
@@ -579,7 +625,6 @@ MDNSError_t MDNS::_processMDNSQuery()
//MDNS_LOGDEBUG1("::_processMDNSQuery: UDP parsePacket len=", udp_len);
- // KH Debug
if (udp_len != 0)
{
MDNS_LOGINFO1("::_processMDNSQuery: UDP parsePacket len=", udp_len);
@@ -605,10 +650,9 @@ MDNSError_t MDNS::_processMDNSQuery()
this->_udp->read((uint8_t*) udpBuffer, udp_len);//read _remaining UDP packet from W5100/W5200 into memory
- // KH
MDNS_LOGINFO1("::_processMDNSQuery: UDP parsePacket len=", udp_len);
-
MDNS_LOGINFO("buffer======");
+
for (int i = 0; i < udp_len; i++)
{
MDNS_LOGINFO0(String(udpBuffer[i], HEX));
@@ -620,7 +664,6 @@ MDNSError_t MDNS::_processMDNSQuery()
MDNS_LOGINFO0("\n");
MDNS_LOGINFO("=====");
- //////
ptr = (uintptr_t)udpBuffer;
@@ -691,6 +734,7 @@ MDNSError_t MDNS::_processMDNSQuery()
}
tLen = 0;
+
do
{
memcpy((uint8_t*)buf, (uint16_t*)(ptr + offset) , 1);
@@ -956,18 +1000,11 @@ MDNSError_t MDNS::_processMDNSQuery()
{
// ok, this is the IP address. report it via callback.
- memcpy((uint8_t*)buf, (uint16_t*)(ptr + offset) , 4);
-
-
- //KH, to report name Resolve only UDP packet has corect size of 48
- if (48 == udp_len)
- {
- // KH debug
- MDNS_LOGINFO1("::_processMDNSQuery: to report IP, buf =", String((uint8_t) buf[0]));
+ memcpy((uint8_t*)buf, (uint16_t*)(ptr + offset), 4);
+
+ MDNS_LOGINFO1("::_processMDNSQuery: to report IP, buf =", String((uint8_t) buf[0]));
- this->_finishedResolvingName((char*)this->_resolveNames[0], (const byte*)buf);
- }
-
+ this->_finishedResolvingName((char*)this->_resolveNames[0], (const byte*)buf);
}
else if (1 == j)
{
@@ -1155,7 +1192,8 @@ MDNSError_t MDNS::_processMDNSQuery()
}
// if we can't find a matching IP, we try to use the first one we found.
- if (NULL == ipAddr) ipAddr = fallbackIpAddr;
+ if (NULL == ipAddr)
+ ipAddr = fallbackIpAddr;
if (ipAddr && this->_serviceFoundCallback)
{
@@ -1164,7 +1202,7 @@ MDNSError_t MDNS::_processMDNSQuery()
}
}
- *p = '.';
+ *p = '.';
} // for
}
@@ -1225,19 +1263,22 @@ MDNSError_t MDNS::_processMDNSQuery()
return statusCode;
}
+////////////////////////////////////////
+
void MDNS::run()
{
uint8_t i;
unsigned long now = millis();
-
- // KH, Debug
+
+#if 0
MDNSError_t statusCode = _processMDNSQuery();
- if (statusCode != MDNSTryLater /*3*/)
+ if (statusCode != MDNSTryLater)
{
- // KH debug
- //MDNS_LOGDEBUG1("::run: statusCode=", (int) statusCode);
+ MDNS_LOGDEBUG1("::run: statusCode=", (int) statusCode);
}
+#endif
+
// first, look for MDNS queries to handle
//(void)_processMDNSQuery();
@@ -1251,18 +1292,15 @@ void MDNS::run()
{
(void)this->_sendMDNSMessage(0, 0, (0 == i) ? MDNSPacketTypeNameQuery : MDNSPacketTypeServiceQuery, 0);
- // KH debug
MDNS_LOGDEBUG3("::run: _sendMDNSMessage, now =", now, ", _resolveLastSendMillis =", this->_resolveLastSendMillis[i] );
}
if (this->_resolveTimeouts[i] > 0 && now > this->_resolveTimeouts[i])
{
- // KH debug
MDNS_LOGDEBUG1("::run: _resolveTimeouts =", this->_resolveTimeouts[i]);
if (i == 0)
{
- // KH debug
MDNS_LOGWARN("::run: to report IP, NULL");
this->_finishedResolvingName((char*)this->_resolveNames[0], NULL);
@@ -1307,6 +1345,8 @@ void MDNS::run()
}
}
+////////////////////////////////////////
+
// return values:
// 1 on success
// 0 otherwise
@@ -1329,6 +1369,8 @@ int MDNS::setName(const char* name)
return 1;
}
+////////////////////////////////////////
+
// return values:
// 1 on success
// 0 otherwise
@@ -1343,6 +1385,8 @@ int MDNS::addServiceRecord(const char* name, uint16_t port, MDNSServiceProtocol_
#endif
}
+////////////////////////////////////////
+
// return values:
// 1 on success
// 0 otherwise
@@ -1425,6 +1469,8 @@ int MDNS::addServiceRecord(const char* name, uint16_t port, MDNSServiceProtocol_
return 0;
}
+////////////////////////////////////////
+
void MDNS::_removeServiceRecord(int idx)
{
if (NULL != this->_serviceRecords[idx])
@@ -1444,11 +1490,15 @@ void MDNS::_removeServiceRecord(int idx)
}
}
+////////////////////////////////////////
+
void MDNS::removeServiceRecord(uint16_t port, MDNSServiceProtocol_t proto)
{
this->removeServiceRecord(NULL, port, proto);
}
+////////////////////////////////////////
+
void MDNS::removeServiceRecord(const char* name, uint16_t port,
MDNSServiceProtocol_t proto)
{
@@ -1465,6 +1515,8 @@ void MDNS::removeServiceRecord(const char* name, uint16_t port,
}
}
+////////////////////////////////////////
+
void MDNS::removeAllServiceRecords()
{
int i;
@@ -1473,6 +1525,8 @@ void MDNS::removeAllServiceRecords()
this->_removeServiceRecord(i);
}
+////////////////////////////////////////
+
void MDNS::_writeDNSName(const uint8_t* name, uint16_t* pPtr,
uint8_t* buf, int bufSize, int zeroTerminate)
{
@@ -1529,6 +1583,8 @@ void MDNS::_writeDNSName(const uint8_t* name, uint16_t* pPtr,
*pPtr = ptr;
}
+////////////////////////////////////////
+
void MDNS::_writeMyIPAnswerRecord(uint16_t* pPtr, uint8_t* buf, int bufSize)
{
uint16_t ptr = *pPtr;
@@ -1559,6 +1615,8 @@ void MDNS::_writeMyIPAnswerRecord(uint16_t* pPtr, uint8_t* buf, int bufSize)
*pPtr = ptr;
}
+////////////////////////////////////////
+
void MDNS::_writeServiceRecordName(int recordIndex, uint16_t* pPtr, uint8_t* buf, int bufSize, int tld)
{
uint16_t ptr = *pPtr;
@@ -1583,6 +1641,8 @@ void MDNS::_writeServiceRecordName(int recordIndex, uint16_t* pPtr, uint8_t* buf
*pPtr = ptr;
}
+////////////////////////////////////////
+
void MDNS::_writeServiceRecordPTR(int recordIndex, uint16_t* pPtr, uint8_t* buf, int bufSize, uint32_t ttl)
{
uint16_t ptr = *pPtr;
@@ -1608,6 +1668,8 @@ void MDNS::_writeServiceRecordPTR(int recordIndex, uint16_t* pPtr, uint8_t* buf,
*pPtr = ptr;
}
+////////////////////////////////////////
+
uint8_t* MDNS::_findFirstDotFromRight(const uint8_t* str)
{
const uint8_t* p = str + strlen((char*)str);
@@ -1617,6 +1679,8 @@ uint8_t* MDNS::_findFirstDotFromRight(const uint8_t* str)
return (uint8_t*)&p[2];
}
+////////////////////////////////////////
+
int MDNS::_matchStringPart(const uint8_t** pCmpStr, int* pCmpLen, const uint8_t* buf,
int dataLen)
{
@@ -1636,6 +1700,8 @@ int MDNS::_matchStringPart(const uint8_t** pCmpStr, int* pCmpLen, const uint8_t*
return matches;
}
+////////////////////////////////////////
+
const uint8_t* MDNS::_postfixForProtocol(MDNSServiceProtocol_t proto)
{
const uint8_t* srv_type = NULL;
@@ -1653,11 +1719,12 @@ const uint8_t* MDNS::_postfixForProtocol(MDNSServiceProtocol_t proto)
return srv_type;
}
+////////////////////////////////////////
+
void MDNS::_finishedResolvingName(char* name, const byte ipAddr[4])
{
if ( (NULL != this->_nameFoundCallback) /*&& (ipAddr != NULL)*/ )
{
-
if (NULL != name)
{
uint8_t* n = this->_findFirstDotFromRight((const uint8_t*)name);
@@ -1671,7 +1738,6 @@ void MDNS::_finishedResolvingName(char* name, const byte ipAddr[4])
}
else
{
- // KH debug
MDNS_LOGDEBUG3("::_finishedResolvingName: name =", name, ", IP =", IPAddress(ipAddr));
this->_nameFoundCallback((const char*)name, IPAddress(ipAddr));
diff --git a/src/MDNS_Responder.h b/src/MDNS_Responder.h
index 1bc2a81..c64995f 100644
--- a/src/MDNS_Responder.h
+++ b/src/MDNS_Responder.h
@@ -19,17 +19,18 @@
You should have received a copy of the GNU Lesser General Public License along with EthernetBonjour.
If not, see .
- Version: 1.4.1
+ Version: 1.4.2
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 01/08/2020 Initial coding to support W5x00 using Ethernet, EthernetLarge libraries
- Supported boards: nRF52, STM32, SAMD21/SAMD51, SAM DUE, Mega
+ Supported boards: nRF52, STM32, SAMD21/SAMD51, SAM DUE, Mega
...
1.3.0 K Hoang 28/09/2021 Add support to Portenta_H7, using WiFi or Ethernet
1.3.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json`
1.4.0 K Hoang 26/01/2022 Fix `multiple-definitions` linker error
1.4.1 K Hoang 11/04/2022 Use Ethernet_Generic library as default. Support SPI1/SPI2 for RP2040/ESP32
+ 1.4.2 K Hoang 12/10/2022 Fix bugs in UDP length check and in WiFi example
*****************************************************************************************************************************/
// Port of CC3000 MDNS Responder to WINC1500.
// Author: Tony DiCola
diff --git a/src/MDNS_Responder.hpp b/src/MDNS_Responder.hpp
index 481824e..032d1ed 100644
--- a/src/MDNS_Responder.hpp
+++ b/src/MDNS_Responder.hpp
@@ -19,17 +19,18 @@
You should have received a copy of the GNU Lesser General Public License along with EthernetBonjour.
If not, see .
- Version: 1.4.1
+ Version: 1.4.2
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 01/08/2020 Initial coding to support W5x00 using Ethernet, EthernetLarge libraries
- Supported boards: nRF52, STM32, SAMD21/SAMD51, SAM DUE, Mega
+ Supported boards: nRF52, STM32, SAMD21/SAMD51, SAM DUE, Mega
...
1.3.0 K Hoang 28/09/2021 Add support to Portenta_H7, using WiFi or Ethernet
1.3.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json`
1.4.0 K Hoang 26/01/2022 Fix `multiple-definitions` linker error
1.4.1 K Hoang 11/04/2022 Use Ethernet_Generic library as default. Support SPI1/SPI2 for RP2040/ESP32
+ 1.4.2 K Hoang 12/10/2022 Fix bugs in UDP length check and in WiFi example
*****************************************************************************************************************************/
// Port of CC3000 MDNS Responder to WINC1500.
// Author: Tony DiCola
@@ -59,6 +60,8 @@
#include "MDNS_Generic_Debug.h"
+////////////////////////////////////////
+
class MDNS_Responder
{
public:
@@ -89,4 +92,6 @@ class MDNS_Responder
IPAddress _localIP = IPAddress(0,0,0,0);
};
+////////////////////////////////////////
+
#endif // MDNS_RESPONDER_HPP
diff --git a/src/MDNS_Responder_Impl.h b/src/MDNS_Responder_Impl.h
index b811a2b..e458392 100644
--- a/src/MDNS_Responder_Impl.h
+++ b/src/MDNS_Responder_Impl.h
@@ -19,17 +19,18 @@
You should have received a copy of the GNU Lesser General Public License along with EthernetBonjour.
If not, see .
- Version: 1.4.1
+ Version: 1.4.2
Version Modified By Date Comments
------- ----------- ---------- -----------
1.0.0 K Hoang 01/08/2020 Initial coding to support W5x00 using Ethernet, EthernetLarge libraries
- Supported boards: nRF52, STM32, SAMD21/SAMD51, SAM DUE, Mega
+ Supported boards: nRF52, STM32, SAMD21/SAMD51, SAM DUE, Mega
...
1.3.0 K Hoang 28/09/2021 Add support to Portenta_H7, using WiFi or Ethernet
1.3.1 K Hoang 10/10/2021 Update `platform.ini` and `library.json`
1.4.0 K Hoang 26/01/2022 Fix `multiple-definitions` linker error
1.4.1 K Hoang 11/04/2022 Use Ethernet_Generic library as default. Support SPI1/SPI2 for RP2040/ESP32
+ 1.4.2 K Hoang 12/10/2022 Fix bugs in UDP length check and in WiFi example
*****************************************************************************************************************************/
// Port of CC3000 MDNS Responder to WINC1500.
@@ -78,6 +79,8 @@
#define TTL_OFFSET 4
#define IP_OFFSET 10
+////////////////////////////////////////
+
const uint8_t expectedRequestHeader[HEADER_SIZE] =
{
0x00, 0x00,
@@ -88,6 +91,8 @@ const uint8_t expectedRequestHeader[HEADER_SIZE] =
0x00, 0x00
};
+////////////////////////////////////////
+
const uint8_t responseHeader[] =
{
0x00, 0x00, // ID = 0
@@ -98,6 +103,8 @@ const uint8_t responseHeader[] =
0x00, 0x01 // Additional records = 1
};
+////////////////////////////////////////
+
// Generate positive response for IPV4 address
const uint8_t aRecord[] =
{
@@ -108,6 +115,8 @@ const uint8_t aRecord[] =
0x00, 0x00, 0x00, 0x00 // IP address, to be filled in later
};
+////////////////////////////////////////
+
// Generate negative response for IPV6 address (CC3000 doesn't support IPV6)
const uint8_t nsecRecord[] =
{
@@ -122,18 +131,27 @@ const uint8_t nsecRecord[] =
0x40, 0x00, 0x00, 0x00 // Bitmap value = Only first bit (A record/IPV4) is set
};
+////////////////////////////////////////
+
const uint8_t domain[] = { 'l', 'o', 'c', 'a', 'l' };
+////////////////////////////////////////
+////////////////////////////////////////
+
MDNS_Responder::MDNS_Responder(UDP& udp) : minimumExpectedRequestLength(0)
{
this->_udp = &udp;
}
+////////////////////////////////////////
+
MDNS_Responder::~MDNS_Responder()
{
this->_udp->stop();
}
+////////////////////////////////////////
+
bool MDNS_Responder::begin(const IPAddress& ip, const char* _name, const uint32_t& _ttlSeconds)
{
_localIP = ip;
@@ -144,6 +162,7 @@ bool MDNS_Responder::begin(const IPAddress& ip, const char* _name, const uint32_
{
// Can only handle domains that are upto 255 chars in length.
minimumExpectedRequestLength = 0;
+
return false;
}
@@ -165,6 +184,8 @@ bool MDNS_Responder::begin(const IPAddress& ip, const char* _name, const uint32_
return true;
}
+////////////////////////////////////////
+
void MDNS_Responder::poll()
{
if (parseRequest())
@@ -175,6 +196,8 @@ void MDNS_Responder::poll()
}
}
+////////////////////////////////////////
+
bool MDNS_Responder::parseRequest()
{
int packetLength = this->_udp->parsePacket();
@@ -243,6 +266,8 @@ bool MDNS_Responder::parseRequest()
return false;
}
+////////////////////////////////////////
+
void MDNS_Responder::replyToRequest()
{
int nameLength = name.length();
@@ -301,4 +326,6 @@ void MDNS_Responder::replyToRequest()
this->_udp->endPacket();
}
+////////////////////////////////////////
+
#endif // MDNS_RESPONDER_IMPL_H