- Why do we need this AsyncDNSServer_STM32 library
- Changelog
- Prerequisites
- Installation
- Packages' Patches
- HOWTO Setting up the Async DNS Server
- HOWTO use STM32F4 with LAN8720
- Examples
- Example AsyncDNSServer_STM32
- Debug
- Troubleshooting
- Issues
- TO DO
- DONE
- Contributions and Thanks
- Contributing
- License
- Copyright
Why do we need this AsyncDNSServer_STM32 library
This AsyncDNSServer_STM32 library is a fully asynchronous DNSServer library, designed for a trouble-free, multi-connection network environment, for STM32F/L/H/G/WB/MP1 boards using LAN8720 or built-in LAN8742A Ethernet.
This library is based on, modified from:
to apply the better and faster asynchronous feature of the powerful AsyncDNSServer_STM32 Library into STM32F/L/H/G/WB/MP1 boards using LAN8720 or built-in LAN8742A Ethernet.
- Using asynchronous network means that you can handle more than one connection at the same time
- You are called once the packet is ready
- After a DNS Client connected to this Async DNS server, you are immediately ready to handle other connections while the Server is taking care of receiving and responding to the UDP packets in the background.
- You are not required to check in a tight loop() the arrival of the DNS requesting packets to process them.
- Speed is OMG
- STM32F/L/H/G/WB/MP1 boards with built-in Ethernet LAN8742A such as :
- Nucleo-144 (F429ZI, F767ZI)
- Discovery (STM32F746G-DISCOVERY)
- All STM32 boards (STM32F/L/H/G/WB/MP1) with 32K+ Flash, with Built-in Ethernet
- See EthernetWebServer_STM32 Support and Test Results
- STM32F4/F7 boards using Ethernet LAN8720 such as :
- 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)
Arduino IDE 1.8.19+
Arduino Core for STM32 v2.3.0+
for STM32F/L/H/G/WB/MP1 boards.STM32Ethernet library v1.3.0+
for built-in LAN8742A Ethernet on (Nucleo-144, Discovery).LwIP library v2.1.2+
for built-in LAN8742A Ethernet on (Nucleo-144, Discovery).AsyncUDP_STM32 library v1.3.0+
. To install. check .
The suggested way to install is to:
The best way is to use Arduino Library Manager
. Search for AsyncDNSServer_STM32
, then select / install the latest version. You can also use this link for more detailed instructions.
- Navigate to AsyncDNSServer_STM32 page.
- Download the latest release
AsyncDNSServer_STM32-master.zip
. - Extract the zip file to
AsyncDNSServer_STM32-master
directory - Copy the whole
AsyncDNSServer_STM32-master
folder to Arduino libraries' directory such as~/Arduino/libraries/
.
- Install VS Code
- Install PlatformIO
- Install AsyncDNSServer_STM32 library by using Library Manager. Search for AsyncDNSServer_STM32 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
For Generic STM32F4 series
boards, such as STM32F407VE, using LAN8720, please use STM32 core v2.2.0
as breaking core v2.3.0
creates the compile error.
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/2.2.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:
~/.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.
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 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/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.3.0. These files must be copied into the directory:
~/.arduino15/packages/STM32/hardware/stm32/2.3.0/variants/NUCLEO_F767ZI/variant.h
for Nucleo-144 NUCLEO_F767ZI.~/.arduino15/packages/STM32/hardware/stm32/2.3.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, these 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
#include <LwIP.h>
#include <STM32Ethernet.h>
#include <AsyncDNSServer_STM32.h>
#include <AsyncDNSServer_STM32.h>
const byte DNS_PORT = 53;
IPAddress apIP;
AsyncDNSServer dnsServer;
void setup()
{
...
// modify TTL associated with the domain name (in seconds)
// default is 60 seconds
dnsServer.setTTL(300);
// set which return code will be used for all other domains
// (e.g. sending ServerFailure instead of NonExistentDomain will reduce number of queries
// sent by clients). Default is AsyncDNSReplyCode::NonExistentDomain
dnsServer.setErrorReplyCode(AsyncDNSReplyCode::ServerFailure);
// start DNS server for a specific domain name
dnsServer.start(DNS_PORT, "*", Ethernet.localIP());
...
}
void loop()
{
}
This is the Wiring for STM32F4 (BLACK_F407VE, etc.) using LAN8720
LAN8720 PHY | <---> | STM32F4 |
---|---|---|
TX1 | <---> | PB_13 |
TX_EN | <---> | PB_11 |
TX0 | <---> | PB_12 |
RX0 | <---> | PC_4 |
RX1 | <---> | PC_5 |
nINT/RETCLK | <---> | PA_1 |
CRS | <---> | PA_7 |
MDIO | <---> | PA_2 |
MDC | <---> | PC_1 |
GND | <---> | GND |
VCC | <---> | +3.3V |
Connect as follows. To program, use STM32CubeProgrammer or Arduino IDE with
- U(S)ART Support: "Enabled (generic Serial)"
- Upload Method : "STM32CubeProgrammer (SWD)"
STLink | <---> | STM32F4 |
---|---|---|
SWCLK | <---> | SWCLK |
SWDIO | <---> | SWDIO |
RST | <---> | NRST |
GND | <---> | GND |
5v | <---> | 5V |
Connect FDTI (USB to Serial) as follows:
FDTI | <---> | STM32F4 |
---|---|---|
RX | <---> | TX=PA_9 |
TX | <---> | RX=PA_10 |
GND | <---> | GND |
- AsyncCaptivePortalAdvanced_STM32
- AsyncCaptivePortal_STM32
- AsyncDNServerFull_STM32
- AsyncDNSServer_STM32
- AsyncCaptivePortalAdvanced_STM32_LAN8720
- AsyncCaptivePortal_STM32_LAN8720
- AsyncDNServerFull_STM32_LAN8720
- AsyncDNSServer_STM32_LAN8720
Example AsyncDNSServer_STM32
1. File AsyncDNSServer_STM32.ino
2. File defines.h
AsyncDNSServer_STM32/examples/AsyncDNSServer_STM32/defines.h
Lines 12 to 127 in caeee09
Debug is enabled by default on Serial. To disable, use level 0
#define ASYNC_DNS_STM32_DEBUG_PORT Serial
// Use from 0 to 4. Higher number, more debugging messages and memory usage.
#define _ASYNC_DNS_STM32_LOGLEVEL_ 0
You can also change the debugging level from 0 to 4
#define ASYNC_DNS_STM32_DEBUG_PORT Serial
// Use from 0 to 4. Higher number, more debugging messages and memory usage.
#define _ASYNC_DNS_STM32_LOGLEVEL_ 4
If you get compilation errors, more often than not, you may need to install a newer version of Arduino IDE, the Arduino STM32
core or depending libraries.
Sometimes, the library will only work if you update the STM32
core to the latest version because I am always using the latest cores /libraries.
Submit issues to: AsyncDNSServer_STM32 issues
- Fix bug. Add enhancement
- Add support to more Ethernet / WiFi shield
- Add support to more STM32 boards.
- Initial port to STM32 using builtin LAN8742A Etnernet. Tested on STM32F7 Nucleo-144 F767ZI.
- Add more examples.
- Add debugging features.
- Add support to Ethernet LAN8720 using STM32Ethernet library, for boards such as Nucleo-144 (F429ZI, NUCLEO_F746NG, NUCLEO_F746ZG, NUCLEO_F756ZG), Discovery (DISCO_F746NG) and STM32F4 boards (BLACK_F407VE, BLACK_F407VG, BLACK_F407ZE, BLACK_F407ZG, BLACK_F407VE_Mini, DIYMORE_F407VGT, FK407M1)
- Add Table-of-Contents
- Use
allman
astyle
- Based on and modified from Develo's ESPAsyncDNSServer Library.
- Many thanks to Hristo Gochkov for great (ESP)AsyncUDP, (ESP)AsyncTCP, ESPAsyncWebServer Libraries
- Relied on Frederic Pillon's STM32duino LwIP Library.
⭐️⭐️ Hristo Gochkov |
⭐️ Develo |
⭐️ Frederic Pillon |
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
- The library is licensed under MIT
Copyright (c) 2020- Khoi Hoang