Imrpoved web copying
- better output - fixed default ssids.json - auto replace of old website when the version number is different - saved RAM by putting spiffs file names in progmem - updated web converter
This commit is contained in:
parent
c388a61e96
commit
b39fd87191
|
@ -711,8 +711,9 @@ void SerialInterface::runCommand(String input) {
|
|||
// ===== FORMAT ==== //
|
||||
// format
|
||||
else if (eqlsCMD(0, CLI_FORMAT)) {
|
||||
prnt(CLI_FORMATTING_SPIFFS);
|
||||
SPIFFS.format();
|
||||
prntln(CLI_CLEARED_SPIFFS);
|
||||
prntln(SETUP_OK);
|
||||
}
|
||||
|
||||
// ===== DELETE ==== //
|
||||
|
|
|
@ -50,6 +50,7 @@ void Settings::load() {
|
|||
|
||||
if (version != VERSION){
|
||||
//reset();
|
||||
copyWebFiles(true);
|
||||
version = VERSION;
|
||||
changed = true;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ extern "C" {
|
|||
#include "user_interface.h"
|
||||
}
|
||||
|
||||
#define VERSION "v2.0"
|
||||
#define VERSION "v2.0.1"
|
||||
|
||||
extern void checkFile(String path, String data);
|
||||
extern JsonVariant parseJSONFile(String path, DynamicJsonBuffer &jsonBuffer);
|
||||
|
@ -22,6 +22,7 @@ extern void getRandomMac(uint8_t* mac);
|
|||
extern bool strToMac(String macStr, uint8_t* mac);
|
||||
extern void setWifiChannel(uint8_t ch);
|
||||
extern String fixUtf8(String str);
|
||||
extern void copyWebFiles(bool force);
|
||||
|
||||
class Settings {
|
||||
public:
|
||||
|
|
|
@ -311,12 +311,19 @@ String buildString(String left, String right, int maxLen){
|
|||
|
||||
/* ===== SPIFFS ===== */
|
||||
bool progmemToSpiffs(const char* adr, int len, String path) {
|
||||
prnt(str(SETUP_COPYING) + path + str(SETUP_PROGMEM_TO_SPIFFS));
|
||||
File f = SPIFFS.open(path, "w+");
|
||||
if (!f) return false;
|
||||
if (!f){
|
||||
prntln(SETUP_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < len; i++) {
|
||||
f.write(pgm_read_byte_near(adr + i));
|
||||
}
|
||||
f.close();
|
||||
|
||||
prntln(SETUP_OK);
|
||||
}
|
||||
|
||||
bool readFile(String path, String &buf) {
|
||||
|
|
|
@ -165,6 +165,8 @@ static const char SETUP_MOUNT_SPIFFS[] PROGMEM = "Mounting SPIFFS...";
|
|||
static const char SETUP_FORMAT_SPIFFS[] PROGMEM = "Formatting SPIFFS...";
|
||||
static const char SETUP_SERIAL_WARNING[] PROGMEM = "Warning: Serial deactivated";
|
||||
static const char SETUP_STARTED[] PROGMEM = "STARTED! \\o/";
|
||||
static const char SETUP_COPYING[] PROGMEM = "Copying ";
|
||||
static const char SETUP_PROGMEM_TO_SPIFFS[] PROGMEM = " from PROGMEM to SPIFFS...";
|
||||
|
||||
// ===== SERIAL COMMAND LINE INTERFACE ===== //
|
||||
static const char CLI_SCAN[] PROGMEM = "scan"; // scan
|
||||
|
@ -320,7 +322,7 @@ static const char CLI_SYSTEM_SPIFFS_OUT[] PROGMEM = " block size %u bytes
|
|||
static const char CLI_FILES[] PROGMEM = "Files: ";
|
||||
static const char CLI_BYTES[] PROGMEM = " bytes";
|
||||
static const char CLI_SYSTEM_FOOTER[] PROGMEM = "===============================";
|
||||
static const char CLI_CLEARED_SPIFFS[] PROGMEM = "Cleared SPIFFS";
|
||||
static const char CLI_FORMATTING_SPIFFS[] PROGMEM = "Formatting SPIFFS...";
|
||||
static const char CLI_REMOVED[] PROGMEM = "Removed ";
|
||||
static const char CLI_ERROR_REMOVING[] PROGMEM = "ERROR: removing ";
|
||||
static const char CLI_REMOVING_LINES[] PROGMEM = "Removed lines ";
|
||||
|
@ -558,7 +560,7 @@ static const char SS_RANDOM_ENABLED[] PROGMEM = "SSID random mode enabled";
|
|||
static const char SS_RANDOM_DISABLED[] PROGMEM = "SSID random mode deactivated";
|
||||
static const char SS_JSON_SSIDS[] PROGMEM = "ssids";
|
||||
static const char SS_JSON_RANDOM[] PROGMEM = "random";
|
||||
static const char SS_JSON_DEFAULT[] PROGMEM = "{\"random\":false,\"ssids:\"[]}";
|
||||
static const char SS_JSON_DEFAULT[] PROGMEM = "{\"random\":false,\"ssids\":[]}";
|
||||
static const char SS_RANDOM_INFO[] PROGMEM = "Generating new SSIDs... Type \"disable random\" to stop the random mode";
|
||||
|
||||
// ===== SCAN ==== //
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -87,7 +87,7 @@ for file in html_files:
|
|||
hex_formatted_content += "0x" + char + ", "
|
||||
hex_formatted_content = hex_formatted_content[:-2]
|
||||
progmem_definitions += "const char " + array_name + "[] PROGMEM = {" + hex_formatted_content + "};\n"
|
||||
copy_files_function += ' if(!SPIFFS.exists("/web/' + base_file + '.gz")) progmemToSpiffs(' + array_name + ', sizeof(' + array_name + '), "/web/' + base_file + '.gz");\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'
|
||||
|
||||
for file in css_files:
|
||||
base_file = os.path.basename(str(file))
|
||||
|
@ -114,7 +114,7 @@ for file in css_files:
|
|||
hex_formatted_content += "0x" + char + ", "
|
||||
hex_formatted_content = hex_formatted_content[:-2]
|
||||
progmem_definitions += "const char " + array_name + "[] PROGMEM = {" + hex_formatted_content + "};\n"
|
||||
copy_files_function += ' if(!SPIFFS.exists("/web/' + base_file + '.gz")) progmemToSpiffs(' + array_name + ', sizeof(' + array_name + '), "/web/' + base_file + '.gz");\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'
|
||||
|
||||
for file in js_files:
|
||||
q = PurePath('js')
|
||||
|
@ -145,7 +145,7 @@ for file in js_files:
|
|||
hex_formatted_content += "0x" + char + ", "
|
||||
hex_formatted_content = hex_formatted_content[:-2]
|
||||
progmem_definitions += "const char " + array_name + "[] PROGMEM = {" + hex_formatted_content + "};\n"
|
||||
copy_files_function += ' if(!SPIFFS.exists("/web/js/' + base_file + '.gz")) progmemToSpiffs(' + array_name + ', sizeof(' + array_name + '), "/web/js/' + base_file + '.gz");\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'
|
||||
|
||||
for file in lang_files:
|
||||
q = PurePath('lang')
|
||||
|
@ -173,7 +173,7 @@ for file in lang_files:
|
|||
hex_formatted_content += "0x" + char + ", "
|
||||
hex_formatted_content = hex_formatted_content[:-2]
|
||||
progmem_definitions += "const char " + array_name + "[] PROGMEM = {" + hex_formatted_content + "};\n"
|
||||
copy_files_function += ' if(!SPIFFS.exists("/web/lang/' + base_file + '.gz")) progmemToSpiffs(' + array_name + ', sizeof(' + array_name + '), "/web/lang/' + base_file + '.gz");\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'
|
||||
|
||||
base_file = os.path.basename(license_file_path)
|
||||
new_file = str(os.path.join(str(compressed), str("LICENSE")))
|
||||
|
@ -195,7 +195,7 @@ for char in hex_content:
|
|||
hex_formatted_content += "0x" + char + ", "
|
||||
hex_formatted_content = hex_formatted_content[:-2]
|
||||
progmem_definitions += "const char " + array_name + "[] PROGMEM = {" + hex_formatted_content + "};\n"
|
||||
copy_files_function += ' if(!SPIFFS.exists("/web/' + base_file + '.gz")) progmemToSpiffs(' + array_name + ', sizeof(' + array_name + '), "/web/' + base_file + '.gz");\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'
|
||||
|
||||
print("[+] Saving everything into webfiles.h...")
|
||||
f = open(arduino_file_path, 'w')
|
||||
|
@ -209,7 +209,7 @@ f.write("#ifdef USE_PROGMEM_WEB_FILES\n")
|
|||
f.write(progmem_definitions)
|
||||
f.write("#endif\n")
|
||||
f.write("\n")
|
||||
f.write("void copyWebFiles(){\n")
|
||||
f.write("void copyWebFiles(bool force){\n")
|
||||
f.write("#ifdef USE_PROGMEM_WEB_FILES\n")
|
||||
f.write(copy_files_function)
|
||||
f.write("#endif\n")
|
||||
|
|
Loading…
Reference in New Issue