- Why do we need this MDNS_Generic library
- Changelog
- Prerequisites
- Installation
- Packages' Patches
- Libraries' Patches
- Important Notes
- Basic Usage
- Examples
- Example ResolvingHostNames
- Debug Terminal Output Samples
- 1. ResolvingHostNames on nRF52 Adafruit NRF52840_FEATHER EXPRESS with W5500 using Ethernet2 library
- 2. DiscoveringServices on nRF52 Adafruit NRF52840_FEATHER EXPRESS with W5500 using EthernetLarge library
- 3. ResolvingHostNames on SAMD21 Seeeduino SEEED_XIAO_M0 with W5500 using EthernetLarge library
- 4. DiscoveringServices on NUCLEO_F767ZI with W5x00 using Ethernet2 Library
- 5. ResolvingHostNames on NUCLEO_F767ZI with W5x00 using Ethernet2 Library
- 6. ResolvingHostNames on RASPBERRY_PI_PICO with W5x00 using EthernetLarge Library
- 7. DiscoveringServices on MBED RASPBERRY_PI_PICO with W5x00 using EthernetLarge Library
- 8. WiFiRegisteringServices on MBED NANO_RP2040_CONNECT
- 9. WiFiRegisteringServices on ESP32_DEV
- 10. RegisteringServices on NRF52840_FEATHER with W5x00 using EthernetLarge Library
- Debug
- Troubleshooting
- Releases
- Issues
- TO DO
- DONE
- Contributions and Thanks
- Contributing
- License
- Copyright
Why do we need this MDNS_Generic library
MDNS (Multicast DNS) is a protocol to resolve hostnames to IP addresses within small networks that do not include a local name server. It is a zero-configuration service, using essentially the same programming interfaces, packet formats and operating semantics as the unicast Domain Name System (DNS).
The mDNS protocol, published as RFC 6762, uses IP multicast User Datagram Protocol (UDP) packets, and is implemented by the Apple Bonjour and open source Avahi software packages.
mDNS can work in conjunction with DNS Service Discovery (DNS-SD), a companion zero-configuration networking technique specified separately in RFC 6763.
This MDNS_Generic library is based on and modified from Dario Pennisi's ArduinoMDNS Library to provide support to many more boards, such as ESP32, Arduino SAMD21, Adafruit SAMD21/SAMD51, Seeeduino SAMD21/SAMD51, nRF52, STM32F/L/H/G/WB/MP1, Teensy, SAM DUE, AVR Mega, RP2040-based boards, etc. and enable those boards to use MDNS services. The currently supported modules/shield is W5x00 using Ethernet, EthernetLarge, Ethernet2 or Ethernet3 library.
-
The WiFiNINA modules/shields are currently supported from v1.2.0, using WiFiNINA_Generic Library
-
The WiFi101 modules/shields are currently supported from v1.2.0, using WiFi101 Library
-
Ethernet2 Library is also supported only after applying the fix to add Multicast feature. See Libraries' Patches
-
ENC28J60 using EthernetENC or UIPEthernet library is not supported as UDP Multicast is not available by design.
-
LAN8742A using STM32Ethernet / STM32 LwIP libraries is not supported as UDP Multicast is not enabled by design, unless you modify the code to add support.
-
ESP32
-
AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox etc..
-
Arduino SAMD21 (ZERO, MKR, NANO_33_IOT, etc.).
-
Adafruit SAM21 (Itsy-Bitsy M0, Metro M0, Feather M0, Gemma M0, etc.).
-
Adafruit SAM51 (Itsy-Bitsy M4, Metro M4, Grand Central M4, Feather M4 Express, etc.).
-
Seeeduino SAMD21/SAMD51 boards (SEEED_WIO_TERMINAL, SEEED_FEMTO_M0, SEEED_XIAO_M0, Wio_Lite_MG126, WIO_GPS_BOARD, SEEEDUINO_ZERO, SEEEDUINO_LORAWAN, SEEED_GROVE_UI_WIRELESS, etc.)
-
STM32 (Nucleo-144, Nucleo-64, Nucleo-32, Discovery, STM32F1, STM32F3, STM32F4, STM32H7, STM32L0, etc.).
-
STM32F/L/H/G/WB/MP1 (Nucleo-64 L053R8,Nucleo-144, Nucleo-64, Nucleo-32, Discovery, STM32Fx, STM32H7, STM32Lx, STM32Gx, STM32WB, STM32MP1, etc.) having 64K+ Flash program memory.
-
RP2040-based boards, such as Nano RP2040 Connect, using Arduino mbed OS for Nano boards.
-
RP2040-based boards, such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Arduino-mbed RP2040 core or Earle Philhower's arduino-pico core.
- W5x00's using Ethernet, EthernetLarge or Ethernet3 Library.
- Ethernet2 Library is also supported only after applying the fix to add Multicast feature. See Libraries' Patches
- ENC28J60 using EthernetENC and UIPEthernet library is not supported as UDP Multicast is not available by design.
- LAN8742A using STM32Ethernet / STM32 LwIP libraries is not supported as UDP Multicast is not enabled by design, unless you modify the code to add support.
- WiFiNINA using
WiFiNINA_Generic library
- WiFi101 using
WiFi101 library
- U-Blox W101, W102 using
WiFiNINA_Generic library
- ESP8266-AT command using
WiFiEspAT library
- ESP32 using native WiFi
- Remove support to ESP8266 to use native ESP8266mDNS library
- Add support to RP2040-based boards, such as Nano_RP2040_Connect, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Arduino-mbed RP2040 core using WiFi / WiFiNINA_Generic Library
- Add support to RP2040-based boards, such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Earle Philhower's arduino-pico core using WiFi / WiFiNINA_Generic Library
- Add support to ESP32 and ESP8266 boards using native ESP WiFi
- Add support to Generic boards, such as MKR WiFi1010, using WiFi101 Library
- Add WiFi-related examples.
- Modify hostname from easily-duplicated
arduino
to board-related hostname to fix issue caused by duplicated hostname, such as mDNS stops working after two minutes #5 - Verify issue mDNS stops working after two minutes #5 is fixed, using Nano_RP2040_Connect, WiFiNINA FW 1.4.8 and WiFiNINA_Generic Library
- Change License from
MIT
to GPLv3
- Add support to RP2040-based boards, such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Earle Philhower's arduino-pico core.
- Add support to RP2040-based boards, such as Nano_RP2040_Connect, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Arduino-mbed RP2040 core.
- Update examples
- Update `Packages' Patches
- Add Version String and Table of Contents
- Add support to W5x00 using Ethernet2 or Ethernet3 library
- Update Platform.ini to support PlatformIO 5.x owner-based dependency declaration.
- Update Packages' Patches.
- Update Libraries' Patches for Ethernet2 library to add Multicast feature necessary for this MDNS_Generic library
- Enhance examples.
- Add support to nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox, etc..
- Add support to SAMD51 (Itsy-Bitsy M4, Metro M4, Grand Central M4, Feather M4 Express, etc.).
- Add support to SAMD21 (ZERO, MKR, NANO_33_IOT, M0, M0 Pro, AdaFruit CIRCUITPLAYGROUND_EXPRESS, etc.).
- Add support to Seeeduino SAMD21/SAMD51 boards (SEEED_WIO_TERMINAL, SEEED_FEMTO_M0, SEEED_XIAO_M0, Wio_Lite_MG126, WIO_GPS_BOARD, SEEEDUINO_ZERO, SEEEDUINO_LORAWAN, SEEED_GROVE_UI_WIRELESS, etc.)
- Add support to all STM32F/L/H/G/WB/MP1 (Nucleo-144 NUCLEO_F767ZI, Nucleo-64 NUCLEO_L053R8, etc.)
- Add support to Teensy (4.1, 4.0, 3.x, Teensy++ 2.0, Teensy 2.0, etc.)
- Add sample Packages Patches for STM32F/L/H/G/WB/MP1
- Add Library Patches for Ethernet.
- Add Packages' Patches for Arduino SAMD21 to fix compiler error issue when using STL for Nano-33-IoT, ZERO, MKR, etc.
-
Arduino AVR core 1.8.3+
for Arduino (Use Arduino Board Manager) for AVR boards. -
Teensy core v1.54+
for Teensy (4.1, 4.0, 3.6, 3.5, 3,2, 3.1, 3.0) boards. -
Arduino SAM DUE core v1.6.12+
for SAM DUE ARM Cortex-M3 boards. -
Arduino SAMD core 1.8.11+
for SAMD ARM Cortex-M0+ boards. -
Adafruit SAMD core 1.7.5+
for SAMD ARM Cortex-M0+ and M4 boards (Nano 33 IoT, etc.). -
Seeeduino SAMD core 1.8.1+
for SAMD21/SAMD51 boards (XIAO M0, Wio Terminal, etc.). -
Adafruit nRF52 v1.0.0
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. -
Arduino mbed_rp2040 core 2.4.1+
for Arduino (Use Arduino Board Manager) RP2040-based boards, such as Arduino Nano RP2040 Connect, RASPBERRY_PI_PICO, etc.. -
Earle Philhower's arduino-pico core v1.9.4+
for RP2040-based boards such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, etc. -
Arduino Core for STM32 v2.0.0+
for STM32F/L/H/G/WB/MP1 boards. -
ESP32 Core 2.0.0+
for ESP32-based boards. -
Depending on which Ethernet module/shield you're using :
Ethernet library v2.0.0+
for W5100, W5200 and W5500.EthernetLarge library v2.0.0+
for W5100, W5200 and W5500.Ethernet2 library v1.0.4+
for W5500.Ethernet3 library v1.5.5+
for W5500/WIZ550io/WIZ850io/USR-ES1 with Wiznet W5500 chip.
-
STM32Ethernet library v1.2.0+
for built-in LAN8742A Ethernet on (Nucleo-144, Discovery).. To be used with
LwIP library v2.1.2+
.. Not yet ready in v1.2.0.
-
WiFiNINA_Generic library v1.8.13+
. To install. checkif using WiFiNINA for boards such as Nano 33 IoT, nRF52, Teensy, etc. Ready from v1.2.0.
-
WiFi101 library v0.16.1+
if using WINC1500/WiFi101 shields (MKR1000, MKR1010, etc.). -
WiFiEspAT library v1.3.1+
if using ESP8288/ESP32-AT shields.
The best and easiest way is to use Arduino Library Manager
. Search for MDNS_Generic, then select / install the latest version.
You can also use this link for more detailed instructions.
Another way to install is to:
- Navigate to MDNS_Generic page.
- Download the latest release
MDNS_Generic-master.zip
. - Extract the zip file to
MDNS_Generic-master
directory - Copy whole
MDNS_Generic-master
folder to Arduino libraries' directory such as~/Arduino/libraries/
.
- Install VS Code
- Install PlatformIO
- Install MDNS_Generic library by using Library Manager. Search for MDNS_Generic in Platform.io Author's Libraries
- Use included platformio.ini file from examples to ensure that all dependent libraries will installed automatically. Please visit documentation for the other options and examples at Project Configuration File
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 directory into Adafruit nRF52 directory (~/.arduino15/packages/adafruit/hardware/nrf52/1.0.0).
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:
~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/platform.txt
~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/boards.txt
~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B302_ublox/variant.h
~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B302_ublox/variant.cpp
~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B112_ublox/variant.h
~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/variants/NINA_B112_ublox/variant.cpp
~/.arduino15/packages/adafruit/hardware/nrf52/x.yy.z/cores/nRF5/Udp.h
To be able to compile and run on Teensy boards, you have to copy the files in Packages_Patches for Teensy directory into Teensy hardware directory (./arduino-1.8.13/hardware/teensy/avr/boards.txt).
Supposing the Arduino version is 1.8.13. These files must be copied into the directory:
./arduino-1.8.13/hardware/teensy/avr/boards.txt
./arduino-1.8.13/hardware/teensy/avr/cores/teensy/Stream.h
./arduino-1.8.13/hardware/teensy/avr/cores/teensy3/Stream.h
./arduino-1.8.13/hardware/teensy/avr/cores/teensy4/Stream.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 These files must be copied into the directory:
./arduino-x.yy.zz/hardware/teensy/avr/boards.txt
./arduino-x.yy.zz/hardware/teensy/avr/cores/teensy/Stream.h
./arduino-x.yy.zz/hardware/teensy/avr/cores/teensy3/Stream.h
./arduino-x.yy.zz/hardware/teensy/avr/cores/teensy4/Stream.h
To be able to compile and run on SAM DUE boards, you have to copy the whole SAM DUE directory into Arduino sam directory (~/.arduino15/packages/arduino/hardware/sam/1.6.12).
Supposing the Arduino SAM core version is 1.6.12. This file must be copied into the directory:
~/.arduino15/packages/arduino/hardware/sam/1.6.12/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:
~/.arduino15/packages/arduino/hardware/sam/x.yy.zz/platform.txt
To be able to compile without error and automatically detect and display BOARD_NAME on Arduino SAMD (Nano-33-IoT, etc) boards, you have to copy the whole Arduino SAMD cores 1.8.11 directory into Arduino SAMD directory (~/.arduino15/packages/arduino/hardware/samd/1.8.11).
Supposing the Arduino SAMD version is 1.8.11. Now only one file must be copied into the directory:
~/.arduino15/packages/arduino/hardware/samd/1.8.11/platform.txt
Whenever a new version is installed, remember to copy this files into the new version directory. For example, new version is x.yy.zz
This file must be copied into the directory:
~/.arduino15/packages/arduino/hardware/samd/x.yy.zz/platform.txt
Supposing the Arduino SAMD version is 1.8.9. These files must be copied into the directory:
~/.arduino15/packages/arduino/hardware/samd/1.8.9/platform.txt
~/.arduino15/packages/arduino/hardware/samd/1.8.9/cores/arduino/Arduino.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:
~/.arduino15/packages/arduino/hardware/samd/x.yy.z/platform.txt
~/.arduino15/packages/arduino/hardware/samd/x.yy.z/cores/arduino/Arduino.h
This is mandatory to fix the notorious Arduino SAMD compiler error. See Improve Arduino compatibility with the STL (min and max macro)
...\arm-none-eabi\include\c++\7.2.1\bits\stl_algobase.h:243:56: error: macro "min" passed 3 arguments, but takes just 2
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
Whenever the above-mentioned compiler error issue is fixed with the new Arduino SAMD release, you don't need to copy the Arduino.h
file anymore.
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 into Adafruit samd directory (~/.arduino15/packages/adafruit/hardware/samd/1.7.5).
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.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:
~/.arduino15/packages/adafruit/hardware/samd/x.yy.zz/platform.txt
To be able to automatically detect and display BOARD_NAME on Seeeduino SAMD (XIAO M0, Wio Terminal, etc) boards, you have to copy the file Seeeduino SAMD platform.txt into Adafruit samd directory (~/.arduino15/packages/Seeeduino/hardware/samd/1.8.1).
Supposing the Seeeduino SAMD core version is 1.8.1. This file must be copied into the directory:
~/.arduino15/packages/Seeeduino/hardware/samd/1.8.1/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:
~/.arduino15/packages/Seeeduino/hardware/samd/x.yy.zz/platform.txt
To use LAN8720 on some STM32 boards
- Nucleo-144 (F429ZI, NUCLEO_F746NG, NUCLEO_F746ZG, NUCLEO_F756ZG)
- 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 and stm32f7xx_hal_conf_default.h 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 1.9.0. These files must be copied into the directory:
~/.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:
~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/system/STM32F4xx/stm32f4xx_hal_conf_default.h
- `~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/system/STM32F7xx/stm32f7xx_hal_conf_default.h
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 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 1.9.0. These files must be copied into the directory:
~/.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:
~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/variants/NUCLEO_F767ZI/variant.h
~/.arduino15/packages/STM32/hardware/stm32/x.yy.zz/variants/NUCLEO_L053R8/variant.h
8. For RP2040-based boards using Earle Philhower arduino-pico core
To be able to automatically detect and display BOARD_NAME on RP2040-based boards (RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040, GENERIC_RP2040, etc) boards, you have to copy the file RP2040 platform.txt into rp2040 directory (~/.arduino15/packages/rp2040/hardware/rp2040/1.4.0).
Supposing the rp2040 core version is 1.4.0. This file must be copied into the directory:
~/.arduino15/packages/rp2040/hardware/rp2040/1.4.0/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:
~/.arduino15/packages/rp2040/hardware/rp2040/x.yy.zz/platform.txt
With core after v1.5.0, this step is not necessary anymore thanks to the PR Add -DBOARD_NAME="{build.board}" #136.
Some libraries, such as Adafruit DHT-sensor-library, require the definition of microsecondsToClockCycles(). To be able to compile and run on RP2040-based boards, you have to copy the files in RP2040 Arduino.h into rp2040 directory (~/.arduino15/packages/rp2040/hardware/rp2040/1.4.0).
Supposing the rp2040 core version is 1.4.0. This file must be copied to replace:
~/.arduino15/packages/rp2040/hardware/rp2040/1.4.0/cores/rp2040/Arduino.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 to replace:
~/.arduino15/packages/rp2040/hardware/rp2040/x.yy.zz/cores/rp2040/Arduino.h
With core after v1.5.0, this step is not necessary anymore thanks to the PR Add defs for compatibility #142.
If your application requires 2K+ HTML page, the current Ethernet library
must be modified if you are using W5200/W5500 Ethernet shields. W5100 is not supported for 2K+ buffer. If you use boards requiring different CS/SS pin for W5x00 Ethernet shield, for example ESP32, nRF52, etc., you also have to modify the following libraries to be able to specify the CS/SS pin correctly.
To fix Ethernet library
, just copy these following files into the Ethernet library
directory to overwrite the old files:
To fix EthernetLarge library
, just copy these following files into the EthernetLarge library
directory to overwrite the old files:
To fix Ethernet2 library
, just copy these following files into the Ethernet2 library
directory to overwrite the old files:
To add UDP Multicast support, necessary for the UPnP_Generic library:
- To fix
Ethernet3 library
, just copy these following files into theEthernet3 library
directory to overwrite the old files:
To be able to compile and run on nRF52 boards with ENC28J60 using UIPEthernet library, you have to copy these following files into the UIPEthernet utility
directory to overwrite the old files:
To fix ESP32 compile error
, just copy the following file into the ESP32
cores/esp32 directory (e.g. ./arduino-1.8.12/hardware/espressif/cores/esp32) to overwrite the old file:
- For Adafruit nRF52, use the SPI's pin as follows:
- SS/CS = 10
- SPI_MOSI = MO(SI)
- SPI_MISO = MI(SO)
- SPI_SCK = SCK
- For Adafruit SAMD21/SAMD51, use the SPI's CS/SS pin as follows:
- Itsy-Bitsy M0/M4, Feather M0 (Express), Hallowing M0 Express, Zero, Metro M0 => use CS = 16 = pin A2
- Feather M4 (SAMD51) => use SS/CS = 9
- Grand Central M4 => use SS/CS = 53
- Hallowing M4 => use SS/CS = 10
- Metro M4 AirLift => use SS/CS = 36
To know the default CS/SS pins of not listed boards, check the related variant.h
files in
~/.arduino15/packages/adafruit/hardware/samd/x.y.zz/variants/board_name/variant.h
- For Arduino SAM DUE, use the SPI's pin as follows:
- SS/CS = 10
- SPI_MOSI = 75 ( pin 4 @ ICSP connector )
- SPI_MISO = 74 ( pin 1 @ ICSP connector )
- SPI_SCK = 76 ( pin 3 @ ICSP connector )
EthernetUDP udp;
MDNS mdns(udp);
mdns.begin(Ethernet.localIP(), hostname.c_str() /*"arduino"*/);
void loop()
{
mdns.run();
}
mdns.setNameResolvedCallback(nameFound);
void nameFound(const char* name, IPAddress ip)
{
// To process the MDNS resolved name and IP from hostname
}
mdns.setServiceFoundCallback(serviceFound);
void serviceFound(const char* type, MDNSServiceProtocol /*proto*/, const char* name, IPAddress ip,
unsigned short port, const char* txtContent)
{
// To process the MDNS resolved name, IP, port and txtContent (if available)
}
mdns.resolveName(hostName, 5000);
mdns.addServiceRecord("You_Service._http", 80, MDNSServiceTCP);
mdns.startDiscoveringService(serviceName, MDNSServiceTCP, 5000);
- WiFiDiscoveringServices
- WiFiRegisteringServices
- WiFiRegisteringServicesWithTxtRecord
- WiFiResolvingHostNames
Example ResolvingHostNames
1. File ResolvingHostNames.ino
// Illustrates how to resolve host names via MDNS (Multicast DNS)
#include "defines.h"
#include <MDNS_Generic.h>
EthernetUDP udp;
MDNS mdns(udp);
void nameFound(const char* name, IPAddress ip);
void setup()
{
Serial.begin(115200);
while (!Serial);
Serial.print("\nStart ResolvingHostNames on "); Serial.print(BOARD_NAME);
Serial.print(" using "); Serial.println(SHIELD_TYPE);
Serial.println(MDNS_GENERIC_VERSION);
Serial.println(("========================="));
Serial.println(("Default SPI pinout:"));
Serial.print("MOSI:");
Serial.println(MOSI);
Serial.print("MISO:");
Serial.println(MISO);
Serial.print("SCK:");
Serial.println(SCK);
Serial.print("SS:");
Serial.println(SS);
Serial.println(("========================="));
// unknown board, do nothing, use default SS = 10
#ifndef USE_THIS_SS_PIN
#define USE_THIS_SS_PIN 10 // For other boards
#endif
MDNS_LOGERROR3(F("Board :"), BOARD_NAME, F(", setCsPin:"), USE_THIS_SS_PIN);
// For other boards, to change if necessary
#if ( USE_ETHERNET || USE_ETHERNET_LARGE || USE_ETHERNET2 )
// Must use library patch for Ethernet, Ethernet2, EthernetLarge libraries
Ethernet.init (USE_THIS_SS_PIN);
#elif USE_ETHERNET3
// Use MAX_SOCK_NUM = 4 for 4K, 2 for 8K, 1 for 16K RX/TX buffer
#ifndef ETHERNET3_MAX_SOCK_NUM
#define ETHERNET3_MAX_SOCK_NUM 4
#endif
Ethernet.setCsPin (USE_THIS_SS_PIN);
Ethernet.init (ETHERNET3_MAX_SOCK_NUM);
#endif //( USE_ETHERNET || USE_ETHERNET2 || USE_ETHERNET3 || USE_ETHERNET_LARGE )
// start the ethernet connection and the server:
// Use Static IP
//Ethernet.begin(mac, ip);
// Use DHCP dynamic IP and random mac
uint16_t index = millis() % NUMBER_OF_MAC;
Ethernet.begin(mac[index]);
// Just info to know how to connect correctly
Serial.println("=========================");
Serial.println("Currently Used SPI pinout:");
Serial.print("MOSI:");
Serial.println(MOSI);
Serial.print("MISO:");
Serial.println(MISO);
Serial.print("SCK:");
Serial.println(SCK);
Serial.print("SS:");
Serial.println(SS);
Serial.println("=========================");
Serial.print("Using mac index = ");
Serial.println(index);
Serial.print("Connected! IP address: ");
Serial.println(Ethernet.localIP());
// Initialize the mDNS library. You can now reach or ping this
// Arduino via the host name "arduino.local", provided that your operating
// system is mDNS/Bonjour-enabled (such as MacOS X).
// Always call this before any other method!
String hostname = String(BOARD_NAME) + "_" + String(index);
hostname.toUpperCase();
hostname.replace(" ", "-");
Serial.print("Registering mDNS hostname: "); Serial.println(hostname);
Serial.print("To access, using "); Serial.print(hostname); Serial.println(".local");
mdns.begin(Ethernet.localIP(), hostname.c_str());
// We specify the function that the mDNS library will call when it
// resolves a host name. In this case, we will call the function named
// "nameFound".
mdns.setNameResolvedCallback(nameFound);
Serial.println("Enter a mDNS host name via the Arduino Serial Monitor to have it resolved.");
Serial.println("Do not postfix the name with \".local\"");
}
void loop()
{
static char hostName[256];
//char hostName[512];
uint8_t length = 0;
// read in a host name from the Arduino IDE's serial monitor.
while (Serial.available())
{
hostName[length] = Serial.read();
length = (length + 1) % 256;
delay(5);
}
// Terminal adds "\r\n", need to remove
if (length > 1)
length = (length - 2) % 256;
hostName[length] = '\0';
// You can use the "isResolvingName()" function to find out whether the
// mDNS library is currently resolving a host name.
// If so, we skip this input, since we want our previous request to continue.
if (!mdns.isResolvingName())
{
if (length > 0)
{
MDNS_LOGDEBUG3("Receiving len = ", length, ", hostname", hostName);
Serial.print("Resolving '");
Serial.print(hostName);
Serial.println("' via Multicast DNS (Bonjour)...");
// Now we tell the mDNS library to resolve the host name. We give it a
// timeout of 5 seconds (e.g. 5000 milliseconds) to find an answer. The
// library will automatically resend the query every second until it
// either receives an answer or your timeout is reached - In either case,
// the callback function you specified in setup() will be called.
mdns.resolveName(hostName, 5000);
}
}
// This actually runs the mDNS module. YOU HAVE TO CALL THIS PERIODICALLY,
// OR NOTHING WILL WORK! Preferably, call it once per loop().
mdns.run();
//delay(1000);
}
// 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
// (a const char*, which is the hostName you wanted resolved, and a const
// byte[4], which contains the IP address of the host on success, or NULL if
// 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) )
{
Serial.print("The IP address for '");
Serial.print(name);
Serial.print("' is ");
Serial.println(ip);
for (int i = 0; i < 4; i++)
{
MDNS_LOGDEBUG3("IP[", i, "]=", ip[i]);
}
}
else if (ip[0] == 0)
{
Serial.print("Resolving '");
Serial.print(name);
Serial.println("' error.");
}
else
{
Serial.print("Resolving '");
Serial.print(name);
Serial.println("' timed out.");
}
}
2. File defines.h
#ifndef defines_h
#define defines_h
#define MDNS_DEBUG_PORT Serial
// Debug Level from 0 to 4
#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) \
|| defined(ARDUINO_SAMD_MKRGSM1400) || defined(ARDUINO_SAMD_MKRNB1500) || defined(ARDUINO_SAMD_MKRVIDOR4000) || defined(__SAMD21G18A__) \
|| defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS) || defined(__SAMD21E18A__) || defined(__SAMD51__) || defined(__SAMD51J20A__) || defined(__SAMD51J19A__) \
|| defined(__SAMD51G19A__) || defined(__SAMD51P19A__) || defined(__SAMD21G18A__) )
#if defined(ETHERNET_USE_SAMD)
#undef ETHERNET_USE_SAMD
#endif
#define ETHERNET_USE_SAMD true
#endif
#if ( defined(NRF52840_FEATHER) || defined(NRF52832_FEATHER) || defined(NRF52_SERIES) || defined(ARDUINO_NRF52_ADAFRUIT) || \
defined(NRF52840_FEATHER_SENSE) || defined(NRF52840_ITSYBITSY) || defined(NRF52840_CIRCUITPLAY) || defined(NRF52840_CLUE) || \
defined(NRF52840_METRO) || defined(NRF52840_PCA10056) || defined(PARTICLE_XENON) || defined(NINA_B302_ublox) || defined(NINA_B112_ublox) )
#if defined(ETHERNET_USE_NRF528XX)
#undef ETHERNET_USE_NRF528XX
#endif
#define ETHERNET_USE_NRF528XX true
#endif
#if ( defined(ARDUINO_SAM_DUE) || defined(__SAM3X8E__) )
#if defined(ETHERNET_USE_SAM_DUE)
#undef ETHERNET_USE_SAM_DUE
#endif
#define ETHERNET_USE_SAM_DUE true
#endif
#if ( defined(STM32F0) || defined(STM32F1) || defined(STM32F2) || defined(STM32F3) ||defined(STM32F4) || defined(STM32F7) || \
defined(STM32L0) || defined(STM32L1) || defined(STM32L4) || defined(STM32H7) ||defined(STM32G0) || defined(STM32G4) || \
defined(STM32WB) || defined(STM32MP1) )
#if defined(ETHERNET_USE_STM32)
#undef ETHERNET_USE_STM32
#endif
#define ETHERNET_USE_STM32 true
#endif
#if ( defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_RASPBERRY_PI_PICO) || defined(ARDUINO_ADAFRUIT_FEATHER_RP2040) || defined(ARDUINO_GENERIC_RP2040) )
#if defined(ETHERNET_USE_RP2040)
#undef ETHERNET_USE_RP2040
#endif
#define ETHERNET_USE_RP2040 true
#endif
#if defined(ETHERNET_USE_SAMD)
// For SAMD
#if ( defined(ARDUINO_SAMD_ZERO) && !defined(SEEED_XIAO_M0) )
#define BOARD_TYPE "SAMD Zero"
#elif defined(ARDUINO_SAMD_MKR1000)
#define BOARD_TYPE "SAMD MKR1000"
#elif defined(ARDUINO_SAMD_MKRWIFI1010)
#define BOARD_TYPE "SAMD MKRWIFI1010"
#elif defined(ARDUINO_SAMD_NANO_33_IOT)
#define BOARD_TYPE "SAMD NANO_33_IOT"
#elif defined(ARDUINO_SAMD_MKRFox1200)
#define BOARD_TYPE "SAMD MKRFox1200"
#elif ( defined(ARDUINO_SAMD_MKRWAN1300) || defined(ARDUINO_SAMD_MKRWAN1310) )
#define BOARD_TYPE "SAMD MKRWAN13X0"
#elif defined(ARDUINO_SAMD_MKRGSM1400)
#define BOARD_TYPE "SAMD MKRGSM1400"
#elif defined(ARDUINO_SAMD_MKRNB1500)
#define BOARD_TYPE "SAMD MKRNB1500"
#elif defined(ARDUINO_SAMD_MKRVIDOR4000)
#define BOARD_TYPE "SAMD MKRVIDOR4000"
#elif defined(ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS)
#define BOARD_TYPE "SAMD ARDUINO_SAMD_CIRCUITPLAYGROUND_EXPRESS"
#elif defined(ADAFRUIT_FEATHER_M0_EXPRESS)
#define BOARD_TYPE "SAMD21 ADAFRUIT_FEATHER_M0_EXPRESS"
#elif defined(ADAFRUIT_METRO_M0_EXPRESS)
#define BOARD_TYPE "SAMD21 ADAFRUIT_METRO_M0_EXPRESS"
#elif defined(ADAFRUIT_CIRCUITPLAYGROUND_M0)
#define BOARD_TYPE "SAMD21 ADAFRUIT_CIRCUITPLAYGROUND_M0"
#elif defined(ADAFRUIT_GEMMA_M0)
#define BOARD_TYPE "SAMD21 ADAFRUIT_GEMMA_M0"
#elif defined(ADAFRUIT_TRINKET_M0)
#define BOARD_TYPE "SAMD21 ADAFRUIT_TRINKET_M0"
#elif defined(ADAFRUIT_ITSYBITSY_M0)
#define BOARD_TYPE "SAMD21 ADAFRUIT_ITSYBITSY_M0"
#elif defined(ARDUINO_SAMD_HALLOWING_M0)
#define BOARD_TYPE "SAMD21 ARDUINO_SAMD_HALLOWING_M0"
#elif defined(ADAFRUIT_METRO_M4_EXPRESS)
#define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_EXPRESS"
#elif defined(ADAFRUIT_GRAND_CENTRAL_M4)
#define BOARD_TYPE "SAMD51 ADAFRUIT_GRAND_CENTRAL_M4"
#elif defined(ADAFRUIT_FEATHER_M4_EXPRESS)
#define BOARD_TYPE "SAMD51 ADAFRUIT_FEATHER_M4_EXPRESS"
#elif defined(ADAFRUIT_ITSYBITSY_M4_EXPRESS)
#define BOARD_TYPE "SAMD51 ADAFRUIT_ITSYBITSY_M4_EXPRESS"
#elif defined(ADAFRUIT_TRELLIS_M4_EXPRESS)
#define BOARD_TYPE "SAMD51 ADAFRUIT_TRELLIS_M4_EXPRESS"
#elif defined(ADAFRUIT_PYPORTAL)
#define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL"
#elif defined(ADAFRUIT_PYPORTAL_M4_TITANO)
#define BOARD_TYPE "SAMD51 ADAFRUIT_PYPORTAL_M4_TITANO"
#elif defined(ADAFRUIT_PYBADGE_M4_EXPRESS)
#define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_M4_EXPRESS"
#elif defined(ADAFRUIT_METRO_M4_AIRLIFT_LITE)
#define BOARD_TYPE "SAMD51 ADAFRUIT_METRO_M4_AIRLIFT_LITE"
#elif defined(ADAFRUIT_PYGAMER_M4_EXPRESS)
#define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_M4_EXPRESS"
#elif defined(ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS)
#define BOARD_TYPE "SAMD51 ADAFRUIT_PYGAMER_ADVANCE_M4_EXPRESS"
#elif defined(ADAFRUIT_PYBADGE_AIRLIFT_M4)
#define BOARD_TYPE "SAMD51 ADAFRUIT_PYBADGE_AIRLIFT_M4"
#elif defined(ADAFRUIT_MONSTER_M4SK_EXPRESS)
#define BOARD_TYPE "SAMD51 ADAFRUIT_MONSTER_M4SK_EXPRESS"
#elif defined(ADAFRUIT_HALLOWING_M4_EXPRESS)
#define BOARD_TYPE "SAMD51 ADAFRUIT_HALLOWING_M4_EXPRESS"
#elif defined(SEEED_WIO_TERMINAL)
#define BOARD_TYPE "SAMD SEEED_WIO_TERMINAL"
#elif defined(SEEED_FEMTO_M0)
#define BOARD_TYPE "SAMD SEEED_FEMTO_M0"
#elif defined(SEEED_XIAO_M0)
#define BOARD_TYPE "SAMD SEEED_XIAO_M0"
#define USE_THIS_SS_PIN A1
#warning define SEEED_XIAO_M0 USE_THIS_SS_PIN == A1
#elif defined(Wio_Lite_MG126)
#define BOARD_TYPE "SAMD SEEED Wio_Lite_MG126"
#elif defined(WIO_GPS_BOARD)
#define BOARD_TYPE "SAMD SEEED WIO_GPS_BOARD"
#elif defined(SEEEDUINO_ZERO)
#define BOARD_TYPE "SAMD SEEEDUINO_ZERO"
#elif defined(SEEEDUINO_LORAWAN)
#define BOARD_TYPE "SAMD SEEEDUINO_LORAWAN"
#elif defined(SEEED_GROVE_UI_WIRELESS)
#define BOARD_TYPE "SAMD SEEED_GROVE_UI_WIRELESS"
#elif defined(__SAMD21E18A__)
#define BOARD_TYPE "SAMD21E18A"
#elif defined(__SAMD21G18A__)
#define BOARD_TYPE "SAMD21G18A"
#elif defined(__SAMD51G19A__)
#define BOARD_TYPE "SAMD51G19A"
#elif defined(__SAMD51J19A__)
#define BOARD_TYPE "SAMD51J19A"
#elif defined(__SAMD51J20A__)
#define BOARD_TYPE "SAMD51J20A"
#elif defined(__SAM3X8E__)
#define BOARD_TYPE "SAM3X8E"
#elif defined(__CPU_ARC__)
#define BOARD_TYPE "CPU_ARC"
#elif defined(__SAMD51__)
#define BOARD_TYPE "SAMD51"
#else
#define BOARD_TYPE "SAMD Unknown"
#endif
#elif (ETHERNET_USE_SAM_DUE)
#define BOARD_TYPE "SAM DUE"
#elif (ETHERNET_USE_NRF528XX)
#if defined(NRF52840_FEATHER)
#define BOARD_TYPE "NRF52840_FEATHER"
#elif defined(NRF52832_FEATHER)
#define BOARD_TYPE "NRF52832_FEATHER"
#elif defined(NRF52840_FEATHER_SENSE)
#define BOARD_TYPE "NRF52840_FEATHER_SENSE"
#elif defined(NRF52840_ITSYBITSY)
#define BOARD_TYPE "NRF52840_ITSYBITSY"
#elif defined(NRF52840_CIRCUITPLAY)
#define BOARD_TYPE "NRF52840_CIRCUITPLAY"
#elif defined(NRF52840_CLUE)
#define BOARD_TYPE "NRF52840_CLUE"
#elif defined(NRF52840_METRO)
#define BOARD_TYPE "NRF52840_METRO"
#elif defined(NRF52840_PCA10056)
#define BOARD_TYPE "NRF52840_PCA10056"
#elif defined(NINA_B302_ublox)
#define BOARD_TYPE "NINA_B302_ublox"
#elif defined(NINA_B112_ublox)
#define BOARD_TYPE "NINA_B112_ublox"
#elif defined(PARTICLE_XENON)
#define BOARD_TYPE "PARTICLE_XENON"
#elif defined(ARDUINO_NRF52_ADAFRUIT)
#define BOARD_TYPE "ARDUINO_NRF52_ADAFRUIT"
#else
#define BOARD_TYPE "nRF52 Unknown"
#endif
#elif ( defined(CORE_TEENSY) )
#if defined(__IMXRT1062__)
// For Teensy 4.1/4.0
#define BOARD_TYPE "TEENSY 4.1/4.0"
#elif defined(__MK66FX1M0__)
#define BOARD_TYPE "Teensy 3.6"
#elif defined(__MK64FX512__)
#define BOARD_TYPE "Teensy 3.5"
#elif defined(__MKL26Z64__)
#define BOARD_TYPE "Teensy LC"
#elif defined(__MK20DX256__)
#define BOARD_TYPE "Teensy 3.2" // and Teensy 3.1 (obsolete)
#elif defined(__MK20DX128__)
#define BOARD_TYPE "Teensy 3.0"
#elif defined(__AVR_AT90USB1286__)
#error Teensy 2.0++ not supported yet
#elif defined(__AVR_ATmega32U4__)
#error Teensy 2.0 not supported yet
#else
// For Other Boards
#define BOARD_TYPE "Unknown Teensy Board"
#endif
#elif (ETHERNET_USE_STM32)
#if defined(STM32F0)
#define BOARD_TYPE "STM32F0"
#elif defined(STM32F1)
#define BOARD_TYPE "STM32F1"
#elif defined(STM32F2)
#define BOARD_TYPE "STM32F2"
#elif defined(STM32F3)
#define BOARD_TYPE "STM32F3"
#elif defined(STM32F4)
#define BOARD_TYPE "STM32F4"
#elif defined(STM32F7)
#define BOARD_TYPE "STM32F7"
#elif defined(STM32L0)
#define BOARD_TYPE "STM32L0"
#elif defined(STM32L1)
#define BOARD_TYPE "STM32L1"
#elif defined(STM32L4)
#define BOARD_TYPE "STM32L4"
#elif defined(STM32H7)
#define BOARD_TYPE "STM32H7"
#elif defined(STM32G0)
#define BOARD_TYPE "STM32G0"
#elif defined(STM32G4)
#define BOARD_TYPE "STM32G4"
#elif defined(STM32WB)
#define BOARD_TYPE "STM32WB"
#elif defined(STM32MP1)
#define BOARD_TYPE "STM32MP1"
#else
#define BOARD_TYPE "STM32 Unknown"
#endif
#elif ETHERNET_USE_RP2040
// Default pin 5 (in Mbed) or 17 to SS/CS
#if defined(ARDUINO_ARCH_MBED)
// For RPI Pico using Arduino Mbed RP2040 core
// SCK: GPIO2, MOSI: GPIO3, MISO: GPIO4, SS/CS: GPIO5
#define USE_THIS_SS_PIN 5
#if defined(BOARD_NAME)
#undef BOARD_NAME
#endif
#if defined(ARDUINO_NANO_RP2040_CONNECT)
#define BOARD_TYPE "MBED NANO_RP2040_CONNECT"
#elif defined(ARDUINO_RASPBERRY_PI_PICO)
#define BOARD_TYPE "MBED RASPBERRY_PI_PICO"
#elif defined(ARDUINO_ADAFRUIT_FEATHER_RP2040)
#define BOARD_TYPE "MBED ADAFRUIT_FEATHER_RP2040"
#elif defined(ARDUINO_GENERIC_RP2040)
#define BOARD_TYPE "MBED GENERIC_RP2040"
#else
#define BOARD_TYPE "MBED Unknown RP2040"
#endif
#else
// For RPI Pico using E. Philhower RP2040 core
// SCK: GPIO18, MOSI: GPIO19, MISO: GPIO16, SS/CS: GPIO17
#define USE_THIS_SS_PIN 17
#endif
#define SS_PIN_DEFAULT USE_THIS_SS_PIN
// For RPI Pico
#warning Use RPI-Pico RP2040 architecture
#else
// For Mega
#define BOARD_TYPE "AVR Mega"
#endif
#if defined(ARDUINO_BOARD)
#define BOARD_NAME ARDUINO_BOARD
#elif !defined(BOARD_NAME)
#define BOARD_NAME BOARD_TYPE
#endif
#include <SPI.h>
// UIPEthernet, Ethernet_Shield_W5200, EtherCard, EtherSia libraries are not supported
// To override the default CS/SS pin. Don't use unless you know exactly which pin to use
// You can define here or customize for each board at same place with BOARD_TYPE
// Check @ defined(SEEED_XIAO_M0)
//#define USE_THIS_SS_PIN 22 //21 //5 //4 //2 //15
// Only one if the following to be true
#define USE_ETHERNET false
#define USE_ETHERNET2 false
#define USE_ETHERNET3 false //true
#define USE_ETHERNET_LARGE true
#if USE_ETHERNET
#include "Ethernet.h"
#include "EthernetUdp.h"
#warning Use Ethernet lib
#define SHIELD_TYPE "W5x00 using Ethernet Library"
#elif USE_ETHERNET_LARGE
#include "EthernetLarge.h"
#include "EthernetUdp.h"
#warning Use EthernetLarge lib
#define SHIELD_TYPE "W5x00 using EthernetLarge Library"
#elif USE_ETHERNET2
#include "Ethernet2.h"
#include "EthernetUdp2.h"
#warning Use Ethernet2 lib
#define SHIELD_TYPE "W5x00 using Ethernet2 Library"
#elif USE_ETHERNET3
#include "Ethernet3.h"
#include "EthernetUdp3.h"
#warning Use Ethernet3 lib
#define SHIELD_TYPE "W5x00 using Ethernet3 Library"
#else
#define USE_ETHERNET true
#include "Ethernet.h"
#warning Use Ethernet lib
#define SHIELD_TYPE "W5x00 using Ethernet Library"
#endif
// Enter a MAC address and IP address for your controller below.
#define NUMBER_OF_MAC 20
byte mac[][NUMBER_OF_MAC] =
{
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x01 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x02 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x03 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x04 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x05 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x06 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x07 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x08 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x09 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0A },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0B },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0C },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0D },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x0E },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x0F },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x10 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x11 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x12 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0x13 },
{ 0xDE, 0xAD, 0xBE, 0xEF, 0xBE, 0x14 },
};
// Select the IP address according to your local network
IPAddress ip(192, 168, 2, 222);
#endif //defines_h
This is terminal debug output when running ResolvingHostNames on nRF52 Adafruit NRF52840_FEATHER EXPRESS with W5500 Ethernet module using Ethernet2 library.
Starting ResolvingHostNames on NRF52840_FEATHER with W5x00 using Ethernet2 Library
MDNS_Generic v1.2.1
=========================
Default SPI pinout:
MOSI:11
MISO:12
SCK:13
SS:10
=========================
[MDNS] Board : NRF52840_FEATHER , setCsPin: 10
=========================
Currently Used SPI pinout:
MOSI:11
MISO:12
SCK:13
SS:10
=========================
Using mac index = 15
Connected! IP address: 192.168.2.158
Registering mDNS hostname: NRF52840_FEATHER_15
To access, using NRF52840_FEATHER_15.local
Enter a mDNS host name via the Arduino Serial Monitor to have it resolved.
Do not postfix the name with ".local"
Resolving 'raspberrypi-02' via Multicast DNS (Bonjour)...
The IP address for 'raspberrypi-02' is 192.168.2.122
Resolving 'raspberrypi-01' via Multicast DNS (Bonjour)...
The IP address for 'raspberrypi-01' is 192.168.2.120
2. DiscoveringServices on nRF52 Adafruit NRF52840_FEATHER EXPRESS with W5500 using EthernetLarge library
This is terminal debug output when running DiscoveringServices on nRF52 Adafruit NRF52840_FEATHER EXPRESS with W5500 Ethernet module using EthernetLarge library.
Starting DiscoveringServices on NRF52840_FEATHER with W5x00 using EthernetLarge Library
MDNS_Generic v1.2.1
=========================
Default SPI pinout:
MOSI:25
MISO:24
SCK:26
SS:5
=========================
[MDNS] Board : NRF52840_FEATHER , setCsPin: 10
_pinCS = 0
W5100 init, using SS_PIN_DEFAULT = 10, new ss_pin = 10, W5100Class::ss_pin = 10
W5100::init: W5500, SSIZE =8192
=========================
Currently Used SPI pinout:
MOSI:25
MISO:24
SCK:26
SS:5
=========================
Using mac index = 16
Connected! IP address: 192.168.2.160
Registering mDNS hostname: NRF52840_FEATHER_16
To access, using NRF52840_FEATHER_16.local
Enter a mDNS service name via Serial Monitor to discover instances on the network.
Examples are "_http", "_afpovertcp" or "_ssh" (Note the underscores).
Discovering services of type '_http' via Multi-Cast DNS (Bonjour)...
Found: 'Arduino Bonjour Webserver Example' at 192.168.2.156, port 4 (TCP)
Found: 'Arduino mDNS Webserver Example, Page 2' at 192.168.2.156, port 4 (TCP)
Found: 'Linksys07265' at 192.168.2.12, port 80 (TCP)
Finished discovering services of type _http
This is terminal debug output when running ResolvingHostNames on SAMD21 Seeeduino SEEED_XIAO_M0 with W5500 Ethernet module using EthernetLarge library.
Starting ResolvingHostNames on SEEED_XIAO_M0 with W5x00 using EthernetLarge Library
MDNS_Generic v1.2.1
=========================
Default SPI pinout:
MOSI:10
MISO:9
SCK:8
SS:4
=========================
[MDNS] Board : SEEED_XIAO_M0 , setCsPin: 1
_pinCS = 0
W5100 init, using SS_PIN_DEFAULT = 10, new ss_pin = 10, W5100Class::ss_pin = 1
W5100::init: W5500, SSIZE =8192
=========================
Currently Used SPI pinout:
MOSI:10
MISO:9
SCK:8
SS:4
=========================
Using mac index = 0
Connected! IP address: 192.168.2.165
Registering mDNS hostname: SEEED_XIAO_M0_0
To access, using SEEED_XIAO_M0_0.local
Enter a mDNS host name via the Arduino Serial Monitor to have it resolved.
Do not postfix the name with ".local"
Resolving 'raspberrypi-01' via Multicast DNS (Bonjour)...
The IP address for 'raspberrypi-01' is 192.168.2.110
Resolving 'raspberrypi-02' via Multicast DNS (Bonjour)...
The IP address for 'raspberrypi-02' is 192.168.2.112
This is terminal debug output when running DiscoveringServices on STM32 Nucleo-144 NUCLEO_F767ZI with W5x00 using Ethernet2 Library.
Starting DiscoveringServices on NUCLEO_F767ZI with W5x00 using Ethernet2 Library
MDNS_Generic v1.2.1
=========================
Default SPI pinout:
MOSI:11
MISO:12
SCK:13
SS:10
=========================
[MDNS] Board : NUCLEO_F767ZI , setCsPin: 10
=========================
Currently Used SPI pinout:
MOSI:11
MISO:12
SCK:13
SS:10
=========================
Using mac index = 15
Connected! IP address: 192.168.2.98
Registering mDNS hostname: NUCLEO_F767ZI_15
To access, using NUCLEO_F767ZI_15.local
Enter a mDNS service name via Serial Monitor to discover instances on the network.
Examples are "_http", "_afpovertcp" or "_ssh" (Note the underscores).
Discovering services of type '_http' via Multi-Cast DNS (Bonjour)...
Found: 'Arduino mDNS Webserver Example' at 192.168.2.85, port 0 (TCP)
Found: 'Linksys07265' at 192.168.2.12, port 80 (TCP)
Finished discovering services of type _http
This is terminal debug output when running ResolvingHostNames on STM32 Nucleo-144 NUCLEO_F767ZI with W5x00 using Ethernet2 Library.
Starting ResolvingHostNames on NUCLEO_F767ZI with W5x00 using Ethernet2 Library
MDNS_Generic v1.2.1
=========================
Default SPI pinout:
MOSI:11
MISO:12
SCK:13
SS:10
=========================
[MDNS] Board : NUCLEO_F767ZI , setCsPin: 10
=========================
Currently Used SPI pinout:
MOSI:11
MISO:12
SCK:13
SS:10
=========================
Using mac index = 15
Connected! IP address: 192.168.2.98
Registering mDNS hostname: NUCLEO_F767ZI_15
To access, using NUCLEO_F767ZI_15.local
Enter a mDNS host name via the Arduino Serial Monitor to have it resolved.
Do not postfix the name with ".local"
Resolving 'raspberrypi-02' via Multicast DNS (Bonjour)...
The IP address for 'raspberrypi-02' is 192.168.2.112
Resolving 'raspberrypi-01' via Multicast DNS (Bonjour)...
The IP address for 'raspberrypi-01' is 192.168.2.110
This is terminal debug output when running ResolvingHostNames on RASPBERRY_PI_PICO with W5x00 using EthernetLarge Library.
Starting ResolvingHostNames on RASPBERRY_PI_PICO with W5x00 using EthernetLarge Library
MDNS_Generic v1.2.1
=========================
Default SPI pinout:
MOSI:19
MISO:16
SCK:18
SS:17
=========================
[MDNS] Board : RASPBERRY_PI_PICO , setCsPin: 17
_pinCS = 0
W5100 init, using SS_PIN_DEFAULT = 10, new ss_pin = 10, W5100Class::ss_pin = 17
W5100::init: W5500, SSIZE =8192
=========================
Currently Used SPI pinout:
MOSI:19
MISO:16
SCK:18
SS:17
=========================
Using mac index = 6
Connected! IP address: 192.168.2.115
Registering mDNS hostname: MBED_RASPBERRY_PI_PICO_6
To access, using MBED_RASPBERRY_PI_PICO_6.local
Enter a mDNS host name via the Arduino Serial Monitor to have it resolved.
Do not postfix the name with ".local"
Resolving 'raspberrypi-01' via Multicast DNS (Bonjour)...
The IP address for 'raspberrypi-01' is 192.168.2.120
Resolving 'raspberrypi-02' via Multicast DNS (Bonjour)...
The IP address for 'raspberrypi-02' is 192.168.2.122
This is terminal debug output when running DiscoveringServices on MBED RASPBERRY_PI_PICO using W5x00 using EthernetLarge Library.
Start DiscoveringServices on MBED RASPBERRY_PI_PICO using W5x00 using EthernetLarge Library
MDNS_Generic v1.2.1
=========================
Default SPI pinout:
MOSI:3
MISO:4
SCK:2
SS:5
=========================
[MDNS] Board : MBED RASPBERRY_PI_PICO , setCsPin: 5
_pinCS = 0
W5100 init, using SS_PIN_DEFAULT = 5, new ss_pin = 10, W5100Class::ss_pin = 5
W5100::init: W5500, SSIZE =8192
=========================
Currently Used SPI pinout:
MOSI:3
MISO:4
SCK:2
SS:5
=========================
Using mac index = 13
Connected! IP address: 192.168.2.93
Registering mDNS hostname: MBED_RASPBERRY_PI_PICO_13
To access, using MBED_RASPBERRY_PI_PICO_13.local
Enter a mDNS service name via Serial Monitor to discover instances on the network.
Examples are "_http", "_afpovertcp" or "_ssh" (Note the underscores).
Discovering services of type '_http' via Multi-Cast DNS (Bonjour)...
Found: 'Linksys08398' at 192.168.2.14, port 80 (TCP)
Found: 'Linksys07265' at 192.168.2.12, port 80 (TCP)
This is terminal debug output when running WiFiRegisteringServices on MBED NANO_RP2040_CONNECT using WiFiNINA_Generic Library.
Start WiFiRegisteringServices on MBED NANO_RP2040_CONNECT
MDNS_Generic v1.2.1
Used/default SPI pinout:
MOSI:11
MISO:12
SCK:13
SS:10
Attempting to connect to SSID: HueNet1
SSID: HueNet1
Local IP address: 192.168.2.111
Signal strength (RSSI):-21 dBm
Registering mDNS hostname: MBED-NANO_RP2040_CONNECT
To access, using MBED-NANO_RP2040_CONNECT.local
kh@kh-Inspiron-3593:~$ ping MBED-NANO_RP2040_CONNECT.local
PING arduino.local (192.168.2.111) 56(84) bytes of data.
64 bytes from arduino-1f98 (192.168.2.111): icmp_seq=1 ttl=255 time=65.1 ms
64 bytes from arduino-1f98 (192.168.2.111): icmp_seq=2 ttl=255 time=48.6 ms
64 bytes from arduino-1f98 (192.168.2.111): icmp_seq=3 ttl=255 time=70.8 ms
64 bytes from arduino-1f98 (192.168.2.111): icmp_seq=4 ttl=255 time=93.0 ms
64 bytes from arduino-1f98 (192.168.2.111): icmp_seq=5 ttl=255 time=116 ms
64 bytes from arduino-1f98 (192.168.2.111): icmp_seq=6 ttl=255 time=35.8 ms
64 bytes from arduino-1f98 (192.168.2.111): icmp_seq=7 ttl=255 time=37.2 ms
64 bytes from arduino-1f98 (192.168.2.111): icmp_seq=8 ttl=255 time=8.45 ms
64 bytes from arduino-1f98 (192.168.2.111): icmp_seq=9 ttl=255 time=36.5 ms
64 bytes from arduino-1f98 (192.168.2.111): icmp_seq=10 ttl=255 time=59.5 ms
64 bytes from arduino-1f98 (192.168.2.111): icmp_seq=11 ttl=255 time=29.0 ms
64 bytes from arduino-1f98 (192.168.2.111): icmp_seq=12 ttl=255 time=48.7 ms
...
This is terminal debug output when running WiFiRegisteringServices on ESP32_DEV
Start WiFiRegisteringServices on ESP32_DEV
MDNS_Generic v1.2.1
Attempting to connect to SSID: HueNet1
SSID: HueNet1
Local IP address: 192.168.2.80
Signal strength (RSSI):-25 dBm
Registering mDNS hostname: ESP_9ABF498
To access, using ESP_9ABF498.local
kh@kh-Inspiron-3593:~$ ping ESP_9ABF498.local
PING arduino.local (192.168.2.80) 56(84) bytes of data.
64 bytes from esp32-090ADC (192.168.2.80): icmp_seq=1 ttl=255 time=29.4 ms
64 bytes from esp32-090ADC (192.168.2.80): icmp_seq=2 ttl=255 time=49.3 ms
64 bytes from esp32-090ADC (192.168.2.80): icmp_seq=3 ttl=255 time=20.7 ms
64 bytes from esp32-090ADC (192.168.2.80): icmp_seq=4 ttl=255 time=42.5 ms
64 bytes from esp32-090ADC (192.168.2.80): icmp_seq=5 ttl=255 time=13.5 ms
64 bytes from esp32-090ADC (192.168.2.80): icmp_seq=6 ttl=255 time=43.4 ms
64 bytes from esp32-090ADC (192.168.2.80): icmp_seq=7 ttl=255 time=12.4 ms
64 bytes from esp32-090ADC (192.168.2.80): icmp_seq=8 ttl=255 time=30.0 ms
64 bytes from esp32-090ADC (192.168.2.80): icmp_seq=9 ttl=255 time=59.5 ms
64 bytes from esp32-090ADC (192.168.2.80): icmp_seq=10 ttl=255 time=24.5 ms
64 bytes from esp32-090ADC (192.168.2.80): icmp_seq=11 ttl=255 time=47.2 ms
64 bytes from esp32-090ADC (192.168.2.80): icmp_seq=12 ttl=255 time=18.5 ms
64 bytes from esp32-090ADC (192.168.2.80): icmp_seq=13 ttl=255 time=39.7 ms
64 bytes from esp32-090ADC (192.168.2.80): icmp_seq=14 ttl=255 time=10.9 ms
64 bytes from esp32-090ADC (192.168.2.80): icmp_seq=15 ttl=255 time=33.5 ms
...
This is terminal debug output when running RegisteringServices on NRF52840_FEATHER with W5x00 using EthernetLarge Library
Start RegisteringServices on NRF52840_FEATHER using W5x00 using EthernetLarge Library
MDNS_Generic v1.2.1
=========================
Default SPI pinout:
MOSI:25
MISO:24
SCK:26
SS:5
=========================
[MDNS] Board : NRF52840_FEATHER , setCsPin: 10
_pinCS = 0
W5100 init, using SS_PIN_DEFAULT = 10, new ss_pin = 10, W5100Class::ss_pin = 10
W5100::init: W5500, SSIZE =8192
=========================
Currently Used SPI pinout:
MOSI:25
MISO:24
SCK:26
SS:5
=========================
Using mac index = 11
Connected! IP address: 192.168.2.106
Registering mDNS hostname: NRF52840_FEATHER_11
To access, using NRF52840_FEATHER_11.local
AddService : NRF52840_FEATHER_mDNS_Webserver._http
kh@kh-Inspiron-3593:~$ ping NRF52840_FEATHER_11.local
PING NRF52840_FEATHER_11.local (192.168.2.106) 56(84) bytes of data.
64 bytes from WIZnetEFBE0C (192.168.2.106): icmp_seq=1 ttl=128 time=0.253 ms
64 bytes from WIZnetEFBE0C (192.168.2.106): icmp_seq=2 ttl=128 time=0.303 ms
64 bytes from WIZnetEFBE0C (192.168.2.106): icmp_seq=3 ttl=128 time=0.289 ms
64 bytes from WIZnetEFBE0C (192.168.2.106): icmp_seq=4 ttl=128 time=0.256 ms
...
Debug is enabled by default on Serial. To disable, add at the beginning of sketch
/* Comment this out to disable prints and save space */
// Debug Level from 0 to 4
#define MDNS_DEBUG_PORT Serial
// Debug Level from 0 to 4
#define _MDNS_LOGLEVEL_ 1
If you get compilation errors, more often than not, you may need to install a newer version of the board's core, dependent libraries or this library version.
Sometimes, the library will only work if you update the core to the newer or older version because some function compatibility.
- Remove support to ESP8266 to use native ESP8266mDNS library
- Add support to RP2040-based boards, such as Nano_RP2040_Connect, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Arduino-mbed RP2040 core using WiFi / WiFiNINA_Generic Library
- Add support to RP2040-based boards, such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Earle Philhower's arduino-pico core using WiFi / WiFiNINA_Generic Library
- Add support to ESP32 and ESP8266 boards using native ESP WiFi
- Add support to Generic boards, such as MKR WiFi1010, using WiFi101 Library
- Add WiFi-related examples.
- Modify hostname from easily-duplicated
arduino
to board-related hostname to fix issue caused by duplicated hostname, such as mDNS stops working after two minutes #5 - Verify issue mDNS stops working after two minutes #5 is fixed, using Nano_RP2040_Connect, WiFiNINA FW 1.4.8 and WiFiNINA_Generic Library
- Change License from
MIT
to GPLv3
- Add support to RP2040-based boards, such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Earle Philhower's arduino-pico core.
- Add support to RP2040-based boards, such as Nano_RP2040_Connect, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Arduino-mbed RP2040 core.
- Update examples
- Update `Packages' Patches
- Add Version String and Table of Contents
- Add support to W5x00 using Ethernet2 or Ethernet3 library
- Update Platform.ini to support PlatformIO 5.x owner-based dependency declaration.
- Update Packages' Patches.
- Update Libraries' Patches for Ethernet2 library to add Multicast feature necessary for this MDNS_Generic library
- Enhance examples.
- Add support to nRF52 boards, such as AdaFruit Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox, etc..
- Add support to SAMD51 (Itsy-Bitsy M4, Metro M4, Grand Central M4, Feather M4 Express, etc.).
- Add support to SAMD21 (ZERO, MKR, NANO_33_IOT, M0, M0 Pro, AdaFruit CIRCUITPLAYGROUND_EXPRESS, etc.).
- Add support to Seeeduino SAMD21/SAMD51 boards (SEEED_WIO_TERMINAL, SEEED_FEMTO_M0, SEEED_XIAO_M0, Wio_Lite_MG126, WIO_GPS_BOARD, SEEEDUINO_ZERO, SEEEDUINO_LORAWAN, SEEED_GROVE_UI_WIRELESS, etc.)
- Add support to all STM32F/L/H/G/WB/MP1 (Nucleo-144 NUCLEO_F767ZI, Nucleo-64 NUCLEO_L053R8, etc.)
- Add support to Teensy (4.1, 4.0, 3.x, Teensy++ 2.0, Teensy 2.0, etc.)
- Add sample Packages Patches for STM32F/L/H/G/WB/MP1
- Add Library Patches for Ethernet.
- Add Packages' Patches for Arduino SAMD21 to fix compiler error issue when using STL for Nano-33-IoT, ZERO, MKR, etc.
Submit issues to: MDNS_Generic issues
- Support more boards.
- Support ENC28J60 Ethernet.
- Support LAN8742A Ethernet.
- Support more non-compatible Ethernet Libraries such as Ethernet_Shield_W5200, EtherCard, EtherSia
- Add more examples
- Add support to Arduino SAMD21 (ZERO, MKR, NANO_33_IOT, etc.)
- Add support to Adafruit SAMD21 (Itsy-Bitsy M0, Metro M0, Feather M0 Express, etc.).
- Add support to Adafruit SAMD51 (Itsy-Bitsy M4, Metro M4, Grand Central M4, Feather M4 Express, etc.).
- Add support to Seeeduino SAMD21/SAMD51: LoRaWAN, Zero, Femto M0, XIAO M0, Wio GPS Board, Wio Terminal, Grove UI Wireless, etc.
- Add support to Adafruit nRF52 ( Feather nRF52832, nRF52840 Express, BlueFruit Sense, Itsy-Bitsy nRF52840 Express, Metro nRF52840 Express, NINA_B302_ublox, NINA_B112_ublox, etc..
- Add support to SAM DUE.
- Add support to STM32F/L/H/G/WB/MP1.
- Add support to Ethernet W5x00, using either
Ethernet
orEthernetLarge
library - Add debugging feature.
- Add support to Ethernet W5x00, using
Ethernet2
orEthernet3
library - Add support to RP2040-based boards, such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Earle Philhower's arduino-pico core.
- Add support to RP2040-based boards, such as NANO_RP2040_CONNECT, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Arduino-mbed RP2040 core.
- Add Version String and Table of Contents
- Add support to RP2040-based boards, such as Nano_RP2040_Connect, RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Arduino-mbed RP2040 core using WiFi / WiFiNINA_Generic Library
- Add support to RP2040-based boards, such as RASPBERRY_PI_PICO, ADAFRUIT_FEATHER_RP2040 and GENERIC_RP2040, using Earle Philhower's arduino-pico core using WiFi / WiFiNINA_Generic Library
- Add support to ESP32 boards using native ESP WiFi
- Add support to Generic boards, such as MKR WiFi1010, using WiFi101 Library
- Based on and modified from TrippyLighting's EthernetBonjour and Dario Pennisi's ArduinoMDNS
![]() ⭐️ TrippyLighting |
![]() ⭐️ Dario Pennisi |
If you want to contribute to this project:
- Report bugs and errors
- Ask for enhancements
- Create issues and pull requests
- Tell other people about this library
-
Most of the credits go to original authors Georg Kaindl, TrippyLighting and Dario Pennisi.
-
The library is licensed under GPLv3
- Copyright (C) 2010 Georg Kaindl
- Copyright (c) 2017 Arduino LLC. All right reserved.
- Copyright (c) 2020- Khoi Hoang