Hello, I'm new on ESP32 ( have only little experience in programming) and currently working on a simple webserver. ESP starts in AP-mode.
I hope to find a solution for the following issue and kindly ask for help:
I would like to load a file that contains my html-code.
I tried to simply use the FS.h library and the code that was used on ESP8266 since I could not find a reference guide for the ESP32 libraries that i undestood.
I compiled in Arduino IDE and also PlatformIO.
In Arduino I used the library from espressif github
https://github.com/espressif/arduino-esp32
Error is: " 'SPIFFS' was not declared in this scope "
Heres the important part of my code:
Code: Select all
#include <FS.h>
#include <WiFi.h>
#define DEBUGMODE 1
/*Wifi Access data*/
const char* ssid_ap = "AccessPoint";
const char* password_ap = "12345678";
const char * ssid_sta = "<SSID>";
const char * password_sta = "<Password>";
/* set global variables */
byte WiFiMode = 0; // WIFI_STA = 1 = Workstation WIFI_AP = 2 = Accesspoint
int request_counter;
String sHTML;
String sHTMLRequest;
/* Create instance of server on Port 80 */
WiFiServer server(80);
WiFiClient client;
void setup() {
/*start serial communication */
Serial.begin(115200);
SPIFFS.format();
Serial.println("Spiffs formatted");
/* start WiFi as workstation (STA), if not possible
start as Acess Point initialize server */
WiFi_Start_STA();
if (WiFiMode == 0) WiFi_Start_AP();
}
void loop() {
/* Check if a client has connected */
client = server.available();
if (!client)
{
return;
}
/*Wait for the client to send data */
Serial.println("neuer Client verbunden");
/*Count Aufruf der Seite: */
request_counter ++;
unsigned long clTimeout = millis()+250;
while(!client.available() && (millis()<clTimeout) )
{
delay(1);
}
if(millis()>clTimeout)
{
Serial.println("time-out bei Client-Verbindung!");
return;
}
/****** open html files *******/
SPIFFS.begin();
File f = SPIFFS.open("/home.txt", "r");
if (!f) {
Serial.println("file open failed");
}
f.close();
}