- Why do we need this AsyncDNSServer_RP2040W library
- Changelog
- Prerequisites
- Installation
- HOWTO Fix
Multiple Definitions
Linker Error - HOWTO Setting up the Async DNS Server
- Examples
- Example AsyncDNSServer
- Debug
- Troubleshooting
- Issues
- TO DO
- DONE
- Contributions and Thanks
- Contributing
- License
- Copyright
Why do we need this AsyncDNSServer_RP2040W library
This AsyncDNSServer_RP2040W library is a fully asynchronous DNSServer library, designed for a trouble-free, multi-connection network environment, for RASPBERRY_PI_PICO_W using CYW43439 WiFi.
This library is based on, modified from:
to apply the better and faster asynchronous feature into RASPBERRY_PI_PICO_W using CYW43439 WiFi.
- 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
- RASPBERRY_PI_PICO_W with CYW43439 WiFi using arduino-pico core
Arduino IDE 1.8.19+
for Arduino.Earle Philhower's arduino-pico core v2.6.3+
for RASPBERRY_PI_PICO_W with CYW43439 WiFi, etc.AsyncUDP_RP2040W library v1.0.0+
for RASPBERRY_PI_PICO_W with CYW43439 WiFi. To install. check
The suggested way to install is to:
The best way is to use Arduino Library Manager
. Search for AsyncDNSServer_RP2040W
, then select / install the latest version. You can also use this link for more detailed instructions.
- Navigate to AsyncDNSServer_RP2040W page.
- Download the latest release
AsyncDNSServer_RP2040W-main.zip
. - Extract the zip file to
AsyncDNSServer_RP2040W-main
directory - Copy the whole
AsyncDNSServer_RP2040W-main
folder to Arduino libraries' directory such as~/Arduino/libraries/
.
- Install VS Code
- Install PlatformIO
- Install AsyncDNSServer_RP2040W library by using Library Manager. Search for AsyncDNSServer_RP2040W 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
The current library implementation, using xyz-Impl.h
instead of standard xyz.cpp
, possibly creates certain Multiple Definitions
Linker error in certain use cases.
You can include this .hpp
file
// Can be included as many times as necessary, without `Multiple Definitions` Linker Error
#include "AsyncDNSServer_RP2040W.hpp" //https://github.com/khoih-prog/AsyncDNSServer_RP2040W
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
// To be included only in main(), .ino with setup() to avoid `Multiple Definitions` Linker Error
#include "AsyncDNSServer_RP2040W.h" //https://github.com/khoih-prog/AsyncDNSServer_RP2040W
Check the new multiFileProject example for a HOWTO
demo.
Have a look at the discussion in Different behaviour using the src_cpp or src_h lib #80
#include <AsyncDNSServer_RP2040W.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()
{
}
Example AsyncDNSServer
1. File AsyncDNSServer.ino
AsyncDNSServer_RP2040W/examples/AsyncDNSServer/AsyncDNSServer.ino
Lines 10 to 119 in c9325a8
2. File defines.h
AsyncDNSServer_RP2040W/examples/AsyncDNSServer/defines.h
Lines 1 to 29 in c9325a8
Debug is enabled by default on Serial. To disable, use level 0
#define ASYNC_DNS_RP2040W_DEBUG_PORT Serial
// Use from 0 to 4. Higher number, more debugging messages and memory usage.
#define _ASYNC_DNS_RP2040W_LOGLEVEL_ 0
You can also change the debugging level from 0 to 4
#define ASYNC_DNS_RP2040W_DEBUG_PORT Serial
// Use from 0 to 4. Higher number, more debugging messages and memory usage.
#define _ASYNC_DNS_RP2040W_LOGLEVEL_ 4
If you get compilation errors, more often than not, you may need to install a newer version of the arduino-pico core
Sometimes, the library will only work if you update the arduino-pico core core to the latest version because I am using newly added functions.
Submit issues to: AsyncDNSServer_RP2040W issues
- Fix bug. Add enhancement
- Add support to RASPBERRY_PI_PICO_W using CYW43439 WiFi
- Add more examples.
- Add debugging features
- Add astyle using
allman
style. Restyle the library
- Based on and modified from Develo's ESPAsyncDNSServer Library.
⭐️ Develo |
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 GPLv3
- Copyright (c) 2016- Develo
- Copyright (c) 2022- Khoi Hoang