Replaced SPIFFS with LittleFS

This commit is contained in:
Spacehuhn 2020-07-05 15:49:44 +02:00
parent 8fc2bbcd95
commit 3affb69cb5
12 changed files with 72 additions and 72 deletions

View File

@ -1,5 +1,5 @@
#include <EEPROM.h> #include <EEPROM.h>
#include <FS.h> #include <LittleFS.h>
/* /*
Upload this sketch to your ESP8266 to erase Upload this sketch to your ESP8266 to erase
@ -25,10 +25,10 @@ void setup() {
Serial.println("EEPROM cleaned"); Serial.println("EEPROM cleaned");
SPIFFS.begin(); LittleFS.begin();
Serial.println("SPIFFS initialized"); Serial.println("SPIFFS initialized");
SPIFFS.format(); LittleFS.format();
Serial.println("SPIFFS cleaned"); Serial.println("SPIFFS cleaned");
ESP.eraseConfig(); ESP.eraseConfig();
@ -44,4 +44,4 @@ void setup() {
void loop() { void loop() {
} }

View File

@ -1,5 +1,6 @@
#include "CLI.h" #include "CLI.h"
#include <LittleFS.h>
#include "settings.h" #include "settings.h"
/* /*
@ -852,7 +853,7 @@ void CLI::runCommand(String input) {
prntln(macToStr(mac)); prntln(macToStr(mac));
FSInfo fs_info; FSInfo fs_info;
SPIFFS.info(fs_info); LittleFS.info(fs_info);
sprintf(s, str( sprintf(s, str(
CLI_SYSTEM_RAM_OUT).c_str(), fs_info.usedBytes, fs_info.usedBytes / (fs_info.totalBytes / 100), fs_info.totalBytes - fs_info.usedBytes, CLI_SYSTEM_RAM_OUT).c_str(), fs_info.usedBytes, fs_info.usedBytes / (fs_info.totalBytes / 100), fs_info.totalBytes - fs_info.usedBytes,
(fs_info.totalBytes - fs_info.usedBytes) / (fs_info.totalBytes / 100), fs_info.totalBytes); (fs_info.totalBytes - fs_info.usedBytes) / (fs_info.totalBytes / 100), fs_info.totalBytes);
@ -860,7 +861,7 @@ void CLI::runCommand(String input) {
sprintf(s, str(CLI_SYSTEM_SPIFFS_OUT).c_str(), fs_info.blockSize, fs_info.pageSize); sprintf(s, str(CLI_SYSTEM_SPIFFS_OUT).c_str(), fs_info.blockSize, fs_info.pageSize);
prnt(String(s)); prnt(String(s));
prntln(CLI_FILES); prntln(CLI_FILES);
Dir dir = SPIFFS.openDir(String(SLASH)); Dir dir = LittleFS.openDir(String(SLASH));
while (dir.next()) { while (dir.next()) {
prnt(String(SPACE) + String(SPACE) + dir.fileName() + String(SPACE)); prnt(String(SPACE) + String(SPACE) + dir.fileName() + String(SPACE));
@ -896,7 +897,7 @@ void CLI::runCommand(String input) {
// format // format
else if (eqlsCMD(0, CLI_FORMAT)) { else if (eqlsCMD(0, CLI_FORMAT)) {
prnt(CLI_FORMATTING_SPIFFS); prnt(CLI_FORMATTING_SPIFFS);
SPIFFS.format(); LittleFS.format();
prntln(SETUP_OK); prntln(SETUP_OK);
} }

View File

@ -3,7 +3,6 @@
#include "Arduino.h" #include "Arduino.h"
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include <FS.h>
extern "C" { extern "C" {
#include "user_interface.h" #include "user_interface.h"
} }

View File

@ -1,5 +1,7 @@
#include "Names.h" #include "Names.h"
#include <LittleFS.h>
Names::Names() { Names::Names() {
list = new SimpleList<Device>; list = new SimpleList<Device>;
} }

View File

@ -1,8 +1,6 @@
#ifndef Names_h #ifndef Names_h
#define Names_h #define Names_h
#include "Arduino.h"
#include <FS.h>
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
extern "C" { extern "C" {
#include "user_interface.h" #include "user_interface.h"

View File

@ -1,5 +1,6 @@
#include "SSIDs.h" #include "SSIDs.h"
#include <LittleFS.h>
#include "settings.h" #include "settings.h"
SSIDs::SSIDs() { SSIDs::SSIDs() {

View File

@ -3,7 +3,6 @@
#include "Arduino.h" #include "Arduino.h"
#include <ESP8266WiFi.h> #include <ESP8266WiFi.h>
#include <FS.h>
extern "C" { extern "C" {
#include "user_interface.h" #include "user_interface.h"
} }

View File

@ -65,7 +65,7 @@ void setup() {
// start SPIFFS // start SPIFFS
prnt(SETUP_MOUNT_SPIFFS); prnt(SETUP_MOUNT_SPIFFS);
bool spiffsError = !SPIFFS.begin(); bool spiffsError = !LittleFS.begin();
prntln(spiffsError ? SETUP_ERROR : SETUP_OK); prntln(spiffsError ? SETUP_ERROR : SETUP_OK);
// Start EEPROM // Start EEPROM
@ -73,7 +73,7 @@ void setup() {
#ifdef FORMAT_SPIFFS #ifdef FORMAT_SPIFFS
prnt(SETUP_FORMAT_SPIFFS); prnt(SETUP_FORMAT_SPIFFS);
SPIFFS.format(); LittleFS.format();
prntln(SETUP_OK); prntln(SETUP_OK);
#endif // ifdef FORMAT_SPIFFS #endif // ifdef FORMAT_SPIFFS
@ -86,7 +86,7 @@ void setup() {
// Format SPIFFS when in boot-loop // Format SPIFFS when in boot-loop
if (spiffsError || !EEPROMHelper::checkBootNum(BOOT_COUNTER_ADDR)) { if (spiffsError || !EEPROMHelper::checkBootNum(BOOT_COUNTER_ADDR)) {
prnt(SETUP_FORMAT_SPIFFS); prnt(SETUP_FORMAT_SPIFFS);
SPIFFS.format(); LittleFS.format();
prntln(SETUP_OK); prntln(SETUP_OK);
prnt(SETUP_FORMAT_EEPROM); prnt(SETUP_FORMAT_EEPROM);

View File

@ -2,7 +2,7 @@
#define functions_h #define functions_h
#include "Arduino.h" #include "Arduino.h"
#include <FS.h> #include <LittleFS.h>
extern "C" { extern "C" {
#include "user_interface.h" #include "user_interface.h"
} }
@ -546,7 +546,7 @@ String leftRight(String a, String b, int len) {
/* ===== SPIFFS ===== */ /* ===== SPIFFS ===== */
bool progmemToSpiffs(const char* adr, int len, String path) { bool progmemToSpiffs(const char* adr, int len, String path) {
prnt(str(SETUP_COPYING) + path + str(SETUP_PROGMEM_TO_SPIFFS)); prnt(str(SETUP_COPYING) + path + str(SETUP_PROGMEM_TO_SPIFFS));
File f = SPIFFS.open(path, "w+"); File f = LittleFS.open(path, "w+");
if (!f) { if (!f) {
prntln(SETUP_ERROR); prntln(SETUP_ERROR);
@ -565,7 +565,7 @@ bool progmemToSpiffs(const char* adr, int len, String path) {
bool readFile(String path, String& buf) { bool readFile(String path, String& buf) {
if (path.charAt(0) != SLASH) path = String(SLASH) + path; if (path.charAt(0) != SLASH) path = String(SLASH) + path;
File f = SPIFFS.open(path, "r"); File f = LittleFS.open(path, "r");
if (!f) return false; if (!f) return false;
@ -580,7 +580,7 @@ bool readFile(String path, String& buf) {
void readFileToSerial(String path, bool showLineNum) { void readFileToSerial(String path, bool showLineNum) {
if (path.charAt(0) != SLASH) path = String(SLASH) + path; if (path.charAt(0) != SLASH) path = String(SLASH) + path;
File f = SPIFFS.open(path, "r"); File f = LittleFS.open(path, "r");
if (!f) { if (!f) {
prnt(F_ERROR_READING_FILE); prnt(F_ERROR_READING_FILE);
@ -613,14 +613,14 @@ bool copyFile(String pathFrom, String pathTo) {
if (pathTo.charAt(0) != SLASH) pathTo = String(SLASH) + pathTo; if (pathTo.charAt(0) != SLASH) pathTo = String(SLASH) + pathTo;
if (!SPIFFS.exists(pathFrom)) { if (!LittleFS.exists(pathFrom)) {
prnt(F_ERROR_FILE); prnt(F_ERROR_FILE);
prntln(pathFrom); prntln(pathFrom);
return false; return false;
} }
File f1 = SPIFFS.open(pathFrom, "r"); File f1 = LittleFS.open(pathFrom, "r");
File f2 = SPIFFS.open(pathTo, "w+"); File f2 = LittleFS.open(pathTo, "w+");
if (!f1 || !f2) return false; if (!f1 || !f2) return false;
@ -636,19 +636,19 @@ bool renameFile(String pathFrom, String pathTo) {
if (pathTo.charAt(0) != SLASH) pathTo = String(SLASH) + pathTo; if (pathTo.charAt(0) != SLASH) pathTo = String(SLASH) + pathTo;
if (!SPIFFS.exists(pathFrom)) { if (!LittleFS.exists(pathFrom)) {
prnt(F_ERROR_FILE); prnt(F_ERROR_FILE);
prntln(pathFrom); prntln(pathFrom);
return false; return false;
} }
SPIFFS.rename(pathFrom, pathTo); LittleFS.rename(pathFrom, pathTo);
return true; return true;
} }
bool writeFile(String path, String& buf) { bool writeFile(String path, String& buf) {
if (path.charAt(0) != SLASH) path = String(SLASH) + path; if (path.charAt(0) != SLASH) path = String(SLASH) + path;
File f = SPIFFS.open(path, "w+"); File f = LittleFS.open(path, "w+");
if (!f) return false; if (!f) return false;
@ -662,7 +662,7 @@ bool writeFile(String path, String& buf) {
bool appendFile(String path, String& buf) { bool appendFile(String path, String& buf) {
if (path.charAt(0) != SLASH) path = String(SLASH) + path; if (path.charAt(0) != SLASH) path = String(SLASH) + path;
File f = SPIFFS.open(path, "a+"); File f = LittleFS.open(path, "a+");
if (!f) return false; if (!f) return false;
@ -677,7 +677,7 @@ bool appendFile(String path, String& buf) {
void checkFile(String path, String data) { void checkFile(String path, String data) {
if (path.charAt(0) != SLASH) path = String(SLASH) + path; if (path.charAt(0) != SLASH) path = String(SLASH) + path;
if (!SPIFFS.exists(path)) writeFile(path, data); if (!LittleFS.exists(path)) writeFile(path, data);
} }
bool removeLines(String path, int lineFrom, int lineTo) { bool removeLines(String path, int lineFrom, int lineTo) {
@ -688,8 +688,8 @@ bool removeLines(String path, int lineFrom, int lineTo) {
String tmpPath = str(F_TMP) + path + str(F_COPY); String tmpPath = str(F_TMP) + path + str(F_COPY);
File f = SPIFFS.open(path, "r"); File f = LittleFS.open(path, "r");
File f2 = SPIFFS.open(tmpPath, "w"); File f2 = LittleFS.open(tmpPath, "w");
if (!f || !f2) return false; if (!f || !f2) return false;
@ -703,8 +703,8 @@ bool removeLines(String path, int lineFrom, int lineTo) {
f.close(); f.close();
f2.close(); f2.close();
SPIFFS.remove(path); LittleFS.remove(path);
SPIFFS.rename(tmpPath, path); LittleFS.rename(tmpPath, path);
return true; return true;
} }
@ -717,8 +717,8 @@ bool replaceLine(String path, int line, String& buf) {
String tmpPath = "/tmp" + path + "_copy"; String tmpPath = "/tmp" + path + "_copy";
File f = SPIFFS.open(path, "r"); File f = LittleFS.open(path, "r");
File f2 = SPIFFS.open(tmpPath, "w"); File f2 = LittleFS.open(tmpPath, "w");
if (!f || !f2) return false; if (!f || !f2) return false;
@ -738,8 +738,8 @@ bool replaceLine(String path, int line, String& buf) {
f.close(); f.close();
f2.close(); f2.close();
SPIFFS.remove(path); LittleFS.remove(path);
SPIFFS.rename(tmpPath, path); LittleFS.rename(tmpPath, path);
return true; return true;
} }
@ -775,7 +775,7 @@ JsonVariant parseJSONFile(String path, DynamicJsonBuffer& jsonBuffer) {
bool removeFile(String path) { bool removeFile(String path) {
if (path.charAt(0) != SLASH) path = String(SLASH) + path; if (path.charAt(0) != SLASH) path = String(SLASH) + path;
return SPIFFS.remove(path); return LittleFS.remove(path);
} }
void saveJSONFile(String path, JsonObject& root) { void saveJSONFile(String path, JsonObject& root) {

View File

@ -33,31 +33,31 @@ const char LICENSE[] PROGMEM = {0x1f, 0x8b, 0x08, 0x08, 0x7d, 0x98, 0xab, 0x5d,
void copyWebFiles(bool force){ void copyWebFiles(bool force){
#ifdef USE_PROGMEM_WEB_FILES #ifdef USE_PROGMEM_WEB_FILES
if(settings.getWebSettings().use_spiffs){ if(settings::getWebSettings().use_spiffs){
if(!SPIFFS.exists(String(F("/web/attack.html.gz"))) || force) progmemToSpiffs(attackhtml, sizeof(attackhtml), String(F("/web/attack.html.gz"))); if(!LittleFS.exists(String(F("/web/attack.html.gz"))) || force) progmemToSpiffs(attackhtml, sizeof(attackhtml), String(F("/web/attack.html.gz")));
if(!SPIFFS.exists(String(F("/web/index.html.gz"))) || force) progmemToSpiffs(indexhtml, sizeof(indexhtml), String(F("/web/index.html.gz"))); if(!LittleFS.exists(String(F("/web/index.html.gz"))) || force) progmemToSpiffs(indexhtml, sizeof(indexhtml), String(F("/web/index.html.gz")));
if(!SPIFFS.exists(String(F("/web/info.html.gz"))) || force) progmemToSpiffs(infohtml, sizeof(infohtml), String(F("/web/info.html.gz"))); if(!LittleFS.exists(String(F("/web/info.html.gz"))) || force) progmemToSpiffs(infohtml, sizeof(infohtml), String(F("/web/info.html.gz")));
if(!SPIFFS.exists(String(F("/web/scan.html.gz"))) || force) progmemToSpiffs(scanhtml, sizeof(scanhtml), String(F("/web/scan.html.gz"))); if(!LittleFS.exists(String(F("/web/scan.html.gz"))) || force) progmemToSpiffs(scanhtml, sizeof(scanhtml), String(F("/web/scan.html.gz")));
if(!SPIFFS.exists(String(F("/web/settings.html.gz"))) || force) progmemToSpiffs(settingshtml, sizeof(settingshtml), String(F("/web/settings.html.gz"))); if(!LittleFS.exists(String(F("/web/settings.html.gz"))) || force) progmemToSpiffs(settingshtml, sizeof(settingshtml), String(F("/web/settings.html.gz")));
if(!SPIFFS.exists(String(F("/web/ssids.html.gz"))) || force) progmemToSpiffs(ssidshtml, sizeof(ssidshtml), String(F("/web/ssids.html.gz"))); if(!LittleFS.exists(String(F("/web/ssids.html.gz"))) || force) progmemToSpiffs(ssidshtml, sizeof(ssidshtml), String(F("/web/ssids.html.gz")));
if(!SPIFFS.exists(String(F("/web/style.css.gz"))) || force) progmemToSpiffs(stylecss, sizeof(stylecss), String(F("/web/style.css.gz"))); if(!LittleFS.exists(String(F("/web/style.css.gz"))) || force) progmemToSpiffs(stylecss, sizeof(stylecss), String(F("/web/style.css.gz")));
if(!SPIFFS.exists(String(F("/web/js/attack.js.gz"))) || force) progmemToSpiffs(attackjs, sizeof(attackjs), String(F("/web/js/attack.js.gz"))); if(!LittleFS.exists(String(F("/web/js/attack.js.gz"))) || force) progmemToSpiffs(attackjs, sizeof(attackjs), String(F("/web/js/attack.js.gz")));
if(!SPIFFS.exists(String(F("/web/js/scan.js.gz"))) || force) progmemToSpiffs(scanjs, sizeof(scanjs), String(F("/web/js/scan.js.gz"))); if(!LittleFS.exists(String(F("/web/js/scan.js.gz"))) || force) progmemToSpiffs(scanjs, sizeof(scanjs), String(F("/web/js/scan.js.gz")));
if(!SPIFFS.exists(String(F("/web/js/settings.js.gz"))) || force) progmemToSpiffs(settingsjs, sizeof(settingsjs), String(F("/web/js/settings.js.gz"))); if(!LittleFS.exists(String(F("/web/js/settings.js.gz"))) || force) progmemToSpiffs(settingsjs, sizeof(settingsjs), String(F("/web/js/settings.js.gz")));
if(!SPIFFS.exists(String(F("/web/js/site.js.gz"))) || force) progmemToSpiffs(sitejs, sizeof(sitejs), String(F("/web/js/site.js.gz"))); if(!LittleFS.exists(String(F("/web/js/site.js.gz"))) || force) progmemToSpiffs(sitejs, sizeof(sitejs), String(F("/web/js/site.js.gz")));
if(!SPIFFS.exists(String(F("/web/js/ssids.js.gz"))) || force) progmemToSpiffs(ssidsjs, sizeof(ssidsjs), String(F("/web/js/ssids.js.gz"))); if(!LittleFS.exists(String(F("/web/js/ssids.js.gz"))) || force) progmemToSpiffs(ssidsjs, sizeof(ssidsjs), String(F("/web/js/ssids.js.gz")));
if(!SPIFFS.exists(String(F("/web/lang/cn.lang.gz"))) || force) progmemToSpiffs(cnlang, sizeof(cnlang), String(F("/web/lang/cn.lang.gz"))); if(!LittleFS.exists(String(F("/web/lang/cn.lang.gz"))) || force) progmemToSpiffs(cnlang, sizeof(cnlang), String(F("/web/lang/cn.lang.gz")));
if(!SPIFFS.exists(String(F("/web/lang/cs.lang.gz"))) || force) progmemToSpiffs(cslang, sizeof(cslang), String(F("/web/lang/cs.lang.gz"))); if(!LittleFS.exists(String(F("/web/lang/cs.lang.gz"))) || force) progmemToSpiffs(cslang, sizeof(cslang), String(F("/web/lang/cs.lang.gz")));
if(!SPIFFS.exists(String(F("/web/lang/de.lang.gz"))) || force) progmemToSpiffs(delang, sizeof(delang), String(F("/web/lang/de.lang.gz"))); if(!LittleFS.exists(String(F("/web/lang/de.lang.gz"))) || force) progmemToSpiffs(delang, sizeof(delang), String(F("/web/lang/de.lang.gz")));
if(!SPIFFS.exists(String(F("/web/lang/en.lang.gz"))) || force) progmemToSpiffs(enlang, sizeof(enlang), String(F("/web/lang/en.lang.gz"))); if(!LittleFS.exists(String(F("/web/lang/en.lang.gz"))) || force) progmemToSpiffs(enlang, sizeof(enlang), String(F("/web/lang/en.lang.gz")));
if(!SPIFFS.exists(String(F("/web/lang/es.lang.gz"))) || force) progmemToSpiffs(eslang, sizeof(eslang), String(F("/web/lang/es.lang.gz"))); if(!LittleFS.exists(String(F("/web/lang/es.lang.gz"))) || force) progmemToSpiffs(eslang, sizeof(eslang), String(F("/web/lang/es.lang.gz")));
if(!SPIFFS.exists(String(F("/web/lang/fi.lang.gz"))) || force) progmemToSpiffs(filang, sizeof(filang), String(F("/web/lang/fi.lang.gz"))); if(!LittleFS.exists(String(F("/web/lang/fi.lang.gz"))) || force) progmemToSpiffs(filang, sizeof(filang), String(F("/web/lang/fi.lang.gz")));
if(!SPIFFS.exists(String(F("/web/lang/fr.lang.gz"))) || force) progmemToSpiffs(frlang, sizeof(frlang), String(F("/web/lang/fr.lang.gz"))); if(!LittleFS.exists(String(F("/web/lang/fr.lang.gz"))) || force) progmemToSpiffs(frlang, sizeof(frlang), String(F("/web/lang/fr.lang.gz")));
if(!SPIFFS.exists(String(F("/web/lang/it.lang.gz"))) || force) progmemToSpiffs(itlang, sizeof(itlang), String(F("/web/lang/it.lang.gz"))); if(!LittleFS.exists(String(F("/web/lang/it.lang.gz"))) || force) progmemToSpiffs(itlang, sizeof(itlang), String(F("/web/lang/it.lang.gz")));
if(!SPIFFS.exists(String(F("/web/lang/ro.lang.gz"))) || force) progmemToSpiffs(rolang, sizeof(rolang), String(F("/web/lang/ro.lang.gz"))); if(!LittleFS.exists(String(F("/web/lang/ro.lang.gz"))) || force) progmemToSpiffs(rolang, sizeof(rolang), String(F("/web/lang/ro.lang.gz")));
if(!SPIFFS.exists(String(F("/web/lang/ru.lang.gz"))) || force) progmemToSpiffs(rulang, sizeof(rulang), String(F("/web/lang/ru.lang.gz"))); if(!LittleFS.exists(String(F("/web/lang/ru.lang.gz"))) || force) progmemToSpiffs(rulang, sizeof(rulang), String(F("/web/lang/ru.lang.gz")));
if(!SPIFFS.exists(String(F("/web/lang/tlh.lang.gz"))) || force) progmemToSpiffs(tlhlang, sizeof(tlhlang), String(F("/web/lang/tlh.lang.gz"))); if(!LittleFS.exists(String(F("/web/lang/tlh.lang.gz"))) || force) progmemToSpiffs(tlhlang, sizeof(tlhlang), String(F("/web/lang/tlh.lang.gz")));
if(!SPIFFS.exists(String(F("/web/LICENSE.gz"))) || force) progmemToSpiffs(LICENSE, sizeof(LICENSE), String(F("/web/LICENSE.gz"))); if(!LittleFS.exists(String(F("/web/LICENSE.gz"))) || force) progmemToSpiffs(LICENSE, sizeof(LICENSE), String(F("/web/LICENSE.gz")));
} }
#endif #endif
} }

View File

@ -7,7 +7,7 @@
#include <ESP8266WebServer.h> #include <ESP8266WebServer.h>
#include <DNSServer.h> #include <DNSServer.h>
#include <ESP8266mDNS.h> #include <ESP8266mDNS.h>
#include <FS.h> #include <LittleFS.h>
extern "C" { extern "C" {
#include "user_interface.h" #include "user_interface.h"
} }
@ -139,10 +139,10 @@ bool handleFileRead(String path) {
String contentType = getContentType(path); String contentType = getContentType(path);
if (!SPIFFS.exists(path)) { if (!LittleFS.exists(path)) {
if (SPIFFS.exists(path + str(W_DOT_GZIP))) path += str(W_DOT_GZIP); if (LittleFS.exists(path + str(W_DOT_GZIP))) path += str(W_DOT_GZIP);
else if (SPIFFS.exists(wifi_config_path + path)) path = wifi_config_path + path; else if (LittleFS.exists(wifi_config_path + path)) path = wifi_config_path + path;
else if (SPIFFS.exists(wifi_config_path + path + str(W_DOT_GZIP))) path = wifi_config_path + path + str( else if (LittleFS.exists(wifi_config_path + path + str(W_DOT_GZIP))) path = wifi_config_path + path + str(
W_DOT_GZIP); W_DOT_GZIP);
else { else {
// prntln(W_NOT_FOUND); // prntln(W_NOT_FOUND);
@ -150,7 +150,7 @@ bool handleFileRead(String path) {
} }
} }
File file = SPIFFS.open(path, "r"); File file = LittleFS.open(path, "r");
server.streamFile(file, contentType); server.streamFile(file, contentType);
file.close(); file.close();
// prnt(SPACE); // prnt(SPACE);
@ -167,7 +167,7 @@ void handleFileList() {
String path = server.arg("dir"); String path = server.arg("dir");
// Serial.println("handleFileList: " + path); // Serial.println("handleFileList: " + path);
Dir dir = SPIFFS.openDir(path); Dir dir = LittleFS.openDir(path);
String output = String(OPEN_BRACKET); // { String output = String(OPEN_BRACKET); // {
File entry; File entry;

View File

@ -89,7 +89,7 @@ for file in html_files:
hex_formatted_content += "0x" + char + ", " hex_formatted_content += "0x" + char + ", "
hex_formatted_content = hex_formatted_content[:-2] hex_formatted_content = hex_formatted_content[:-2]
progmem_definitions += "const char " + array_name + "[] PROGMEM = {" + hex_formatted_content + "};\n" progmem_definitions += "const char " + array_name + "[] PROGMEM = {" + hex_formatted_content + "};\n"
copy_files_function += ' if(!SPIFFS.exists(String(F("/web/' + base_file + '.gz"))) || force) progmemToSpiffs(' + array_name + ', sizeof(' + array_name + '), String(F("/web/' + base_file + '.gz")));\n' copy_files_function += ' if(!LittleFS.exists(String(F("/web/' + base_file + '.gz"))) || force) progmemToSpiffs(' + array_name + ', sizeof(' + array_name + '), String(F("/web/' + base_file + '.gz")));\n'
webserver_events += 'server.on(String(F("/' + base_file + '")).c_str(), HTTP_GET, [](){\n sendProgmem(' + array_name + ', sizeof(' + array_name + '), W_HTML);\n});\n' webserver_events += 'server.on(String(F("/' + base_file + '")).c_str(), HTTP_GET, [](){\n sendProgmem(' + array_name + ', sizeof(' + array_name + '), W_HTML);\n});\n'
for file in css_files: for file in css_files:
@ -117,7 +117,7 @@ for file in css_files:
hex_formatted_content += "0x" + char + ", " hex_formatted_content += "0x" + char + ", "
hex_formatted_content = hex_formatted_content[:-2] hex_formatted_content = hex_formatted_content[:-2]
progmem_definitions += "const char " + array_name + "[] PROGMEM = {" + hex_formatted_content + "};\n" progmem_definitions += "const char " + array_name + "[] PROGMEM = {" + hex_formatted_content + "};\n"
copy_files_function += ' if(!SPIFFS.exists(String(F("/web/' + base_file + '.gz"))) || force) progmemToSpiffs(' + array_name + ', sizeof(' + array_name + '), String(F("/web/' + base_file + '.gz")));\n' copy_files_function += ' if(!LittleFS.exists(String(F("/web/' + base_file + '.gz"))) || force) progmemToSpiffs(' + array_name + ', sizeof(' + array_name + '), String(F("/web/' + base_file + '.gz")));\n'
webserver_events += 'server.on(String(F("/' + base_file + '")).c_str(), HTTP_GET, [](){\n sendProgmem(' + array_name + ', sizeof(' + array_name + '), W_CSS);\n});\n' webserver_events += 'server.on(String(F("/' + base_file + '")).c_str(), HTTP_GET, [](){\n sendProgmem(' + array_name + ', sizeof(' + array_name + '), W_CSS);\n});\n'
for file in js_files: for file in js_files:
@ -149,7 +149,7 @@ for file in js_files:
hex_formatted_content += "0x" + char + ", " hex_formatted_content += "0x" + char + ", "
hex_formatted_content = hex_formatted_content[:-2] hex_formatted_content = hex_formatted_content[:-2]
progmem_definitions += "const char " + array_name + "[] PROGMEM = {" + hex_formatted_content + "};\n" progmem_definitions += "const char " + array_name + "[] PROGMEM = {" + hex_formatted_content + "};\n"
copy_files_function += ' if(!SPIFFS.exists(String(F("/web/js/' + base_file + '.gz"))) || force) progmemToSpiffs(' + array_name + ', sizeof(' + array_name + '), String(F("/web/js/' + base_file + '.gz")));\n' copy_files_function += ' if(!LittleFS.exists(String(F("/web/js/' + base_file + '.gz"))) || force) progmemToSpiffs(' + array_name + ', sizeof(' + array_name + '), String(F("/web/js/' + base_file + '.gz")));\n'
webserver_events += 'server.on(String(F("/js/' + base_file + '")).c_str(), HTTP_GET, [](){\n sendProgmem(' + array_name + ', sizeof(' + array_name + '), W_JS);\n});\n' webserver_events += 'server.on(String(F("/js/' + base_file + '")).c_str(), HTTP_GET, [](){\n sendProgmem(' + array_name + ', sizeof(' + array_name + '), W_JS);\n});\n'
for file in lang_files: for file in lang_files:
@ -179,7 +179,7 @@ for file in lang_files:
hex_formatted_content += "0x" + char + ", " hex_formatted_content += "0x" + char + ", "
hex_formatted_content = hex_formatted_content[:-2] hex_formatted_content = hex_formatted_content[:-2]
progmem_definitions += "const char " + array_name + "[] PROGMEM = {" + hex_formatted_content + "};\n" progmem_definitions += "const char " + array_name + "[] PROGMEM = {" + hex_formatted_content + "};\n"
copy_files_function += ' if(!SPIFFS.exists(String(F("/web/lang/' + base_file + '.gz"))) || force) progmemToSpiffs(' + array_name + ', sizeof(' + array_name + '), String(F("/web/lang/' + base_file + '.gz")));\n' copy_files_function += ' if(!LittleFS.exists(String(F("/web/lang/' + base_file + '.gz"))) || force) progmemToSpiffs(' + array_name + ', sizeof(' + array_name + '), String(F("/web/lang/' + base_file + '.gz")));\n'
webserver_events += 'server.on(String(F("/lang/' + base_file + '")).c_str(), HTTP_GET, [](){\n sendProgmem(' + array_name + ', sizeof(' + array_name + '), W_JSON);\n});\n' webserver_events += 'server.on(String(F("/lang/' + base_file + '")).c_str(), HTTP_GET, [](){\n sendProgmem(' + array_name + ', sizeof(' + array_name + '), W_JSON);\n});\n'
if(len(load_lang) > 0): if(len(load_lang) > 0):
load_lang += ' else if(settings::getLang() == String(F("'+lang_name+'"))) sendProgmem(' + array_name + ', sizeof(' + array_name + '), W_JSON);\n' load_lang += ' else if(settings::getLang() == String(F("'+lang_name+'"))) sendProgmem(' + array_name + ', sizeof(' + array_name + '), W_JSON);\n'
@ -206,7 +206,7 @@ for char in hex_content:
hex_formatted_content += "0x" + char + ", " hex_formatted_content += "0x" + char + ", "
hex_formatted_content = hex_formatted_content[:-2] hex_formatted_content = hex_formatted_content[:-2]
progmem_definitions += "const char " + array_name + "[] PROGMEM = {" + hex_formatted_content + "};\n" progmem_definitions += "const char " + array_name + "[] PROGMEM = {" + hex_formatted_content + "};\n"
copy_files_function += ' if(!SPIFFS.exists(String(F("/web/' + base_file + '.gz"))) || force) progmemToSpiffs(' + array_name + ', sizeof(' + array_name + '), String(F("/web/' + base_file + '.gz")));\n' copy_files_function += ' if(!LittleFS.exists(String(F("/web/' + base_file + '.gz"))) || force) progmemToSpiffs(' + array_name + ', sizeof(' + array_name + '), String(F("/web/' + base_file + '.gz")));\n'
print("[+] Saving everything into webfiles.h...") print("[+] Saving everything into webfiles.h...")
f = open(arduino_file_path, 'w') f = open(arduino_file_path, 'w')