Introduction
Async Mode
One of the features of NetWizard is the async mode, which provides asynchronous web server functionality for handling HTTP requests for the captive portal. This mode should only be enabled if you are strictly using ESPAsyncWebServer library in your sketch/firmware.
Dependencies
Async mode depends on the following libraries. Please make sure you have installed these specific versions for a crash-free experience. We use fork of AsyncWebServer from mathieucarbou which are stable and maintained regularly.
For ESP32
- (mathieucarbou) AsyncTCP @ v3.2.3
- (mathieucarbou) ESPAsyncWebServer - v3.1.1
For RP2040+W
- (khoih-prog) AsyncTCP_RP2040W @ v1.2.0
- (mathieucarbou) ESPAsyncWebServer - v3.1.1
Enabling Async Mode
Async mode is enabled by setting the NETWIZARD_USE_ASYNC_WEBSERVER
macro. Use the approach applicable to your setup:
For Arduino IDE
Go to your Arduino libraries directory
Open
NetWizard
library folder and then opensrc
folderLocate the
NETWIZARD_USE_ASYNC_WEBSERVER
macro in theNetWizard.h
file, and set it to1
:#define NETWIZARD_USE_ASYNC_WEBSERVER 1
Save the changes to the
NetWizard.h
file.You are now ready to use NetWizard in async mode, utilizing the ESPAsyncWebServer library.
For PlatformIO
If you use PlatformIO then we can use a neat trick! You can set build_flags
in your platformio.ini
file that enables async mode of NetWizard for your specific project.
- Open
platformio.ini
file of your project - Paste this line
build_flags=-DNETWIZARD_USE_ASYNC_WEBSERVER=1
at bottom - Done!
PlatformIO will now compile NetWizard in async mode!
Benefits of Async Mode
Enabling async mode for NetWizard offers several advantages:
Non-blocking Operation: In async mode, NetWizard leverages the asynchronous web server capabilities of ESPAsyncWebServer. This means that HTTP requests won't block your device's main loop. It allows your device to continue executing other tasks while handling HTTP requests in the background.
Improved Responsiveness: Your device can remain responsive to user interactions or other processes during requests in the background, ensuring a smoother user experience.
Improved Compatibility: There are a lot of projects and libraries that still AsyncWebServer, therefore this increases NetWizard compatibility to work for you in any case.