Thank you again.
Hard to solve^^. But i think i am one step further
So. I created a file called indextest.htm. When i click on the file, my browser opens i see the text.
<Hello World and so!>. Like i would expect it.
I uploaded the file to my SPIFFS and tested it with:
void setup() {
Serial.begin(115200); // <-- always use this, forget about 9600
if(!SPIFFS.begin(true)){
Serial.println("An Error has occurred while mounting SPIFFS");
return;
}
File file = SPIFFS.open("/indextest.htm", FILE_WRITE);
if(!file){
Serial.println("There was an error opening the file for writing");
return;
}
if(file.print("arduinotestYes")){
Serial.println("File was written");;
} else {
Serial.println("File write failed");
}
file.close();
File file2 = SPIFFS.open("/indextest.htm");
if(!file2){
Serial.println("Failed to open file for reading");
return;
}
Serial.println("File Content:");
while(file2.available()) Serial.write(file2.read());
file2.close();
}
void loop() {}
My serial monitor says:
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5828
entry 0x400806ac
File was written
File Content:
arduinotestYes
So as far as i see it. It should be ok.
I now uploaded this scetch to test further, if it works.
#include "WiFi.h"
#include "SPIFFS.h"
#include "ESPAsyncWebServer.h"
const char* ssid = "****";
const char* password = "*****";
AsyncWebServer server(80);
void setup(){
Serial.begin(115200);
if(!SPIFFS.begin()){
Serial.println("An Error has occurred while mounting SPIFFS");
return;
}
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi..");
}
Serial.println(WiFi.localIP());
server.on("/html", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(SPIFFS, "/indextest.htm", "text/plain");
});
server.on("/hello", HTTP_GET, [](AsyncWebServerRequest *request)
{request->send(200, "text/plain", "Hello testest");});
File file2 = SPIFFS.open("/indextest.htm", FILE_READ);
while (file2.available()) Serial.print(file2.read());
Serial.println();
server.begin();
}
void loop(){}
Result: myIp/hello = Hello testest
Result. myIp/html = arduinotestYes
So it seems that my "overright" worked and i can read the file.
My next step was that i uploaded the file indextest.htm again, so that i contains the original content:
<!DOCTYPE html>
<html lang="en">
<head>
<title>A simple HTML document</title>
</head>
<body>
<p>Hello World and so!<p>
</body>
</html>
After that the same problem that nothing appears is back
I tried it with both
server.on("/html", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(SPIFFS, "/indextest.htm", "text/html");
});
and
server.on("/html", HTTP_GET, [](AsyncWebServerRequest *request){
request->send(SPIFFS, "/indextest.htm", "text/plain");
});
and my serial monitor is showing wrong things like:
j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�j�
Can u extract something out of it with this information?
Thank you