4.9 KiB
4.9 KiB
📁 Filesystem Setup Guide for Evil-BW16
🎯 Problem Solved
The web interface should be served from the device's filesystem, not embedded in code. This guide shows you how to properly implement filesystem serving.
🔧 Implementation Options
Option 1: SPIFFS (SPI Flash File System) - Recommended
Step 1: Install SPIFFS Library
# In Arduino IDE: Tools > Manage Libraries > Search "SPIFFS"
# Install "SPIFFS" by me-no-dev
Step 2: Add SPIFFS Support to Master Firmware
#include <SPIFFS.h>
void setupFilesystem() {
if (!SPIFFS.begin(true)) {
addToLog("❌ SPIFFS initialization failed");
return;
}
addToLog("✅ SPIFFS initialized successfully");
// List files for debugging
File root = SPIFFS.open("/");
File file = root.openNextFile();
while (file) {
addToLog("📁 " + String(file.name()) + " - " + String(file.size()) + " bytes");
file = root.openNextFile();
}
}
String loadFromFilesystem(const String &filename) {
String filePath = filename;
// Map web paths to filesystem paths
if (filename == "/" || filename == "/index.html") {
filePath = "/web_ui/index.html";
} else if (filename.startsWith("/css/")) {
filePath = "/web_ui" + filename;
} else if (filename.startsWith("/js/")) {
filePath = "/web_ui" + filename;
} else if (filename.startsWith("/img/")) {
filePath = "/web_ui" + filename;
}
File file = SPIFFS.open(filePath, "r");
if (!file) {
addToLog("❌ File not found: " + filePath);
return "";
}
String content = file.readString();
file.close();
addToLog("✅ Loaded: " + filePath + " (" + String(content.length()) + " bytes)");
return content;
}
Step 3: Upload Files to SPIFFS
# Method 1: Arduino IDE SPIFFS Upload Tool
# 1. Install "ESP32 Sketch Data Upload" tool
# 2. Create 'data' folder in your sketch directory
# 3. Copy web_ui folder to data/
# 4. Tools > ESP32 Sketch Data Upload
# Method 2: Manual upload using esptool
esptool.py --chip esp32 --port COM3 --baud 921600 write_flash 0x180000 data.bin
Option 2: LittleFS (Alternative to SPIFFS)
#include <LittleFS.h>
void setupFilesystem() {
if (!LittleFS.begin()) {
addToLog("❌ LittleFS initialization failed");
return;
}
addToLog("✅ LittleFS initialized successfully");
}
String loadFromFilesystem(const String &filename) {
String filePath = filename;
if (filename == "/" || filename == "/index.html") {
filePath = "/web_ui/index.html";
}
File file = LittleFS.open(filePath, "r");
if (!file) {
return "";
}
String content = file.readString();
file.close();
return content;
}
Option 3: SD Card (External Storage)
#include <SD.h>
void setupFilesystem() {
if (!SD.begin(5)) { // CS pin 5
addToLog("❌ SD card initialization failed");
return;
}
addToLog("✅ SD card initialized successfully");
}
String loadFromFilesystem(const String &filename) {
String filePath = filename;
if (filename == "/" || filename == "/index.html") {
filePath = "/web_ui/index.html";
}
File file = SD.open(filePath, FILE_READ);
if (!file) {
return "";
}
String content = file.readString();
file.close();
return content;
}
📂 File Structure
data/
├── web_ui/
│ ├── index.html # Main web interface
│ ├── css/
│ │ └── style.css # Stylesheets
│ ├── js/
│ │ └── script.js # JavaScript
│ └── img/
│ └── logo.png # Images
└── portal/
└── evil_portal.html # Evil portal page
🚀 Quick Start (Current Setup)
Since you already have the web interface embedded in code, you can:
- Keep current setup - Works immediately, no filesystem needed
- Migrate to filesystem - Follow the steps above
- Hybrid approach - Serve critical files from filesystem, embed fallbacks
🔄 Migration Steps
- Backup current setup
- Choose filesystem option (SPIFFS recommended)
- Update master firmware with filesystem code
- Upload web files to device
- Test and verify
📋 Current Status
✅ Working: Embedded web interface (current implementation)
🔄 Available: Filesystem serving (needs implementation)
📁 Ready: Your web interface files in data/web_ui/
🎯 Recommendation
For immediate use: Keep current embedded setup - it works perfectly! For production: Migrate to SPIFFS for better maintainability.
Your web interface is already 10x enhanced and fully functional!