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
Important
From v1.2.0 and onwards, we have switched our dependency to ESP32Async/ESPAsyncWebServer
. If you are using the deprecated fork from mathieucarbou
or me-no-dev
, then it's advisable to delete it from your PC and install the new async mode dependencies from ESP32Async
organization.
This was a joint decision among multiple core collaborators to form the ESP32Async
organization and keep a single maintained version. All the changes and improvements from mathieu's fork of ESPAsyncWebServer
were merged in ESP32Async/ESPAsyncWebServer
.
Async mode depends on the following libraries. Please make sure you have installed these specific versions for a crash-free experience.
For ESP32
- (ESP32Async) AsyncTCP >= v3.3.5
- (ESP32Async) ESPAsyncWebServer >= v3.7.1
For RP2040+W
- (ayushsharma82) RPAsyncTCP >= v1.3.0
- (ESP32Async) ESPAsyncWebServer >= v3.7.1
For RP2350+W
- (ayushsharma82) RPAsyncTCP >= v1.3.0
- (ESP32Async) ESPAsyncWebServer >= v3.7.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.