Description
Board
ESP32-S3 on custom PCB
Device Description
Described issue is device independant
Hardware Configuration
Independant
Version
v2.0.17
IDE Name
platformio
Operating System
Windows 11
Flash frequency
?
PSRAM enabled
no
Upload speed
921600
Description
After several years of "works as expected" I now have crashes inside the Webserver.
(WebServer.h. "Now" means: Change from framework-arduinoespressif32 @ 3.20014 to framework-arduinoespressif32 @ 3.20017)
WbServer.h offers the method
void on(const Uri &uri, HTTPMethod method, THandlerFunction fn, THandlerFunction ufn); //ufn handles file uploads
to define two callbacks "Function" and "Uploads Function".
As said, until V 3.20014 everything worked as expected. From 3.20017 on, when exceuting a POST to the fn, THE UFN is called. NOT THE FN. (And my system then crashes because of wrong handling ...)
To demonstrate I provide:
- Demo-Program
- platformio.ini
- HTML Test-File
DEMO PROGRAM
(see below)
PLATFORMIO.INI
(I use a custom board file. Substitude it by an own board for ESP32-S3)
[platformio]
default_envs = esp32S3-with-6-10-0
[env]
framework = arduino
monitor_speed = 115200
upload_speed = 921600
monitor_filters = time, default
[env:esp32S3-with-6-10-0]
build_flags =
-D CORE_DEBUG_LEVEL=0
platform = espressif32@6.10.0
board = esp32s3_4MB_NOPSRAM_CDC
[env:esp32S3-with-6-6-0]
build_flags =
-D CORE_DEBUG_LEVEL=0
platform = espressif32@6.6.0
board = esp32s3_4MB_NOPSRAM_CDC
HTML FILE
<!DOCTYPE html>
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="content-type">
<title>CALL FN</title>
</head>
<body>
</body>
<script>
alert("Now excecute FN Call");
var xhttp = new XMLHttpRequest();
//CAUTION: Change to your Webserver IP Address!!
xhttp.open("POST", "http:/192.168.0.105/test", true);
xhttp.send();
</script>
</html>
Why?
Can someone verify? Or provide a solution?
Thank you !
P.S.
There is a change in RequestHandlersImpl.h. in the class FunctionRequestHandler.
There appears two new methods canRaw and raw that do not exist in Version
3.20014. And they do something with the _ufn parameter. But I did not digg into deeper ...
Sketch
#include <Arduino.h>
#include <WiFi.h>
#include <WebServer.h>
WebServer clWebServer(80);
// Change this!!
const char* ssid = "???"; // <----------- YOUR SSID
const char* password = "???"; // <----------- YOUR PW
void CB_FN()
{
Serial.println("Hello! I am the FN-Callback");
}
void CB_UFN()
{
Serial.println("Hello! I am the UFN-Callback");
}
void NotFound()
{
Serial.println("Sorry ... did not found");
}
boolean connectWifi(){
boolean state = true;
int i = 0;
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
Serial.println("");
Serial.println("Connecting to WiFi");
// Wait for connection
Serial.print("Connecting...");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
if (i > 20){
state = false; break;
}
i++;
}
Serial.println("");
if (state){
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
else {
Serial.println("Connection failed.");
}
return state;
}
void setup()
{
Serial.begin(115200);
Serial.println("\n\nSTART");
if (connectWifi())
{
clWebServer.on("/test" ,
HTTP_POST,
CB_FN ,
CB_UFN );
clWebServer.onNotFound(NotFound);
clWebServer.begin();
}
else
{
while(1)
{
Serial.print("?..");
delay(1000);
}
}
}
void loop()
{
clWebServer.handleClient();
}
Debug Message
No Debug messages.
Other Steps to Reproduce
0.) (Substitude SSID/PW in program for your needs!)
1.) Build the project with project environment esp32S3-with-6-6-0 (which comes with Version 2.14)
2.) Run and see the connected IP
3.) Substitude IP in HTML-File
4.) Open Brower and execute HTML-File
5.) See in PIO Terminal, that Function FN ist called
---> Works as expected
6.) Change to project environment esp32S3-with-6-10-0 (which comes with Version 2.17) and build
... rest the same as before
---> See in PIO Terminal, that Function UFN ist called. (... and than FN...?)
I have checked existing issues, online documentation and the Troubleshooting Guide
- I confirm I have checked existing issues, online documentation and Troubleshooting guide.