The first issue is my lack of understanding of using the AsyncWebServer and FreeRTOS. I am trying to keep all my communications running on core 0, but at this time I am not sure what is happening. I will write another post about ASWS in the future, but because I don't understand, I am not sure if my big problem is affected by how I am implementing my second issue which is much more serious.
My big problem is that I have a SPA(single page application) with several large(200K-2M)files that I need to send from the SD Card to the client. I am able to send My index.htm file to the client just fine, but when is loads it then asks for several files.
Code: Untitled.html Select all
<html>
<head>
<meta charset=utf-8>
<meta name=viewport content="width=device-width,initial-scale=1">
<title>1X Verifier</title>
<link href=/static/css/app.css rel=stylesheet></head>
<body><div id=app></div>
<script type=text/javascript src=/static/js/app.js></script>
< script type=text/javascript src=/static/js/manifest.js></script >
<script type=text/javascript src=/static/js/vendor.js></script>
</body>
</html>I have tried several pattern, but none work.
I don't think FreeRTOS is the issue, I am able to Serial.write() 200K files within the server.on request handler.
Below is one of the simpler patterns that I have tried.
Code: Untitled.cpp Select all
server.on("/static/css/app.css",[](AsyncWebServerRequest *request){
Serial.println("Sending /static/css/app.css");
// request->send(200, "text/html", "<html><body><h1>Hello Heat!</h1></body></html>");
sd1File = SD.open("/static/css/app.css"); // Is the file there?
if (sd1File) {
Serial.println("File /static/css/app.css found");
//Serial.write(sd1File.read()):
request->send(sd1File, "/static/css/app.css", "text/css");
}
sd1File.close();
});Suggestions, of the method in what class to use would help, an example would be great.
Thanks