v0.3.0 Exchange ESPAsyncWebserver with PsychicHttp
Caution
This update has breaking changes!
This is a major change getting rid of all ESPAsyncTCP and ESPAsyncWebserver dependencies. Despite their popularity they are plagued with countless bugs, since years unmaintained, not SSL capable and simply not suitable for a production build. Although several attempts exist to fix the most pressing bugs even these libraries lead to frequent crashes. This new version replaces them with ESP-IDF based components. PsychicHttp and PsychicMqttClient both wrap the ESP-IDF components in a familiar wrapper for easy porting of the code base. However, this will break existing code and will require some effort on your codebase. In return the stability is improved greatly and the RAM usage more friendly. Now e.g. running Bluetooth in parallel becomes possible.
Added
- Added postscript to platform.io build process to copy, rename and calculate MD5 checksum of *.bin file. These files are ready for uploading to the Github Release page.
- Added more information to SystemStatus API
- Added generateToken API for security settings
- Added Multi-WiFi capability. Add up to five WiFi configurations and connect to either strongest network (default), or by priority.
- Added InfoDialog as a simpler version of the ConfirmDialog for a simple notification modal.
- Added Adafruit certificate repository as the default choice for the X509 certificate bundle.
Changed
- Better route protection for user page with deep link.
- Changed build_interface.py script to check for modified files in the interface sources before re-building the interface. Saves some time on the compilation process.
- Upload firmware binary allows uploading of MD5 checksum file in advance to verify downloaded firmware package.
- GithubFirmwareManager checks against PIO build_target in filename to support Github OTA for binaries build for various targets. You should rename your old release *.bin files on the Github release pages for backward compatibility.
- Changed MQTT Client to an ESP-IDF backed one which supports SSL/TLS X509 root CA bundles and transport over WS.
- Changed the
PROGMEM_WWW
flag toEMBED_WWW
as there is technically speaking no PROGMEM on ESP32's. - Updated dependencies to the latest version. Except SvelteKit.
Fixed
- Fixed reactivity of System Status page.
Removed
- Removed support for Arduino ESP OTA.
- HttpEndpoints and Websocket Server without a securityManager are no longer possible.
Migrate from ESPAsyncWebServer to PsychicHttp
Migrate main.cpp
Change the server and ESPSvelteKit instances to PsychicHttpServer and give the ESP32SvelteKit constructor the number of http endpoints of your project.
PsychicHttpServer server;
ESP32SvelteKit esp32sveltekit(&server, 120);
Remove server.begin();
in void setup()
. This is handled by ESP32SvelteKit now.
Migrate platformio.ini
Remove the following build_flags
:
; Increase queue size of SSE and WS
-D SSE_MAX_QUEUED_MESSAGES=64
-D WS_MAX_QUEUED_MESSAGES=64
-D CONFIG_ASYNC_TCP_RUNNING_CORE=0
-D NO_GLOBAL_ARDUINOOTA
-D PROGMEM_WWW
Add the following build_flags
and adjust to your app, if needed:
-D BUILD_TARGET=\"$PIOENV\"
-D APP_NAME=\"ESP32-Sveltekit\" ; Must only contain characters from [a-zA-Z0-9-_] as this is converted into a filename
-D APP_VERSION=\"0.3.0\" ; semver compatible version string
-D EMBED_WWW
Remove the lib dependency esphome/AsyncTCP-esphome @ ^2.0.0
and add https://github.com/theelims/PsychicMqttClient.git
Consider adjusting board_ssl_cert_source = adafruit
, so that the new MQTT client has universal SSL/TLS support with a wide range of CA root certificates.
Migrate factory_settings.ini
The new MQTT client has slightly renamed factory settings:
; MQTT settings
-D FACTORY_MQTT_ENABLED=false
-D FACTORY_MQTT_URI=\"mqtts://mqtt.eclipseprojects.io:8883\"
-D FACTORY_MQTT_USERNAME=\"\" ; supports placeholders
-D FACTORY_MQTT_PASSWORD=\"\"
-D FACTORY_MQTT_CLIENT_ID=\"#{platform}-#{unique_id}\" ; supports placeholders
-D FACTORY_MQTT_KEEP_ALIVE=120
-D FACTORY_MQTT_CLEAN_SESSION=true
Max Topic Length is no longer needed.
Custom Stateful Services
Adapt the class constructor ((PsychicHttpServer *server, ...
) to PsychicHttpServer.
Due to the loading sequence HttpEndoint and WebsocketServer both have gotten a begin()
function to register their http endpoints with the server. This must be called in your stateful services' own begin()
function:
void LightStateService::begin()
{
_httpEndpoint.begin();
_webSocketServer.begin();
_state.ledOn = DEFAULT_LED_STATE;
onConfigUpdated();
}