Skip to content

Commit

Permalink
ESP8266 LittleFS error with PROGMEM
Browse files Browse the repository at this point in the history
  • Loading branch information
cotestatnt committed Jan 7, 2024
1 parent fb214e3 commit 51c31df
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
3 changes: 2 additions & 1 deletion examples/customHTML/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"files.associations": {
"*.tcc": "cpp"
"*.tcc": "cpp",
"ostream": "cpp"
}
}
2 changes: 1 addition & 1 deletion examples/customHTML/customHTML.ino
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void setup() {
// Add custom page title to /setup
server.setSetupPageTitle("Test setup page");
// Add custom logo to /setup page with custom size
server.setLogoBase64(base64_logo, "128", "128", /*overwite file*/ true);
server.setLogoBase64(base64_logo, "128", "128", /*overwite file*/ false);

// Enable ACE FS file web editor and add FS info callback fucntion
server.enableFsCodeEditor();
Expand Down
15 changes: 9 additions & 6 deletions src/AsyncFsWebServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,24 +266,26 @@ void AsyncFsWebServer::setLogoBase64(const char* logo, const char* width, const
strcat(filename, "_");
strcat(filename, height);
strcat(filename, ".txt");

optionToFile(filename, logo, overwrite);
addOption("img-logo", filename);
}

bool AsyncFsWebServer::optionToFile(const char* filename, const char* str, bool overWrite) {
// Check if file is already saved
File file = m_filesystem->open(filename, "r");
if (file && !overWrite) {
file.close();
if (m_filesystem->exists(filename) && !overWrite) {
return true;
}
// Create or overwrite option file
else {
file.close();
file = m_filesystem->open(filename, "w");

File file = m_filesystem->open(filename, "w");
if (file) {
#if defined(ESP8266)
String _str = str;
file.print(_str);
#else
file.print(str);
#endif
file.close();
log_debug("File %s saved", filename);
return true;
Expand All @@ -306,6 +308,7 @@ void AsyncFsWebServer::addSource(const char* source, const char* tag, bool overW
path += ".css";
else if (strstr(tag, "javascript") != NULL)
path += ".js";

optionToFile(path.c_str(), source, overWrite);
addOption(tag, path.c_str(), false);
}
Expand Down
2 changes: 1 addition & 1 deletion src/AsyncFsWebServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#define CONFIG_FILE "/config.json"

#define DBG_OUTPUT_PORT Serial
#define LOG_LEVEL 3 // (0 disable, 1 error, 2 info, 3 debug)
#define LOG_LEVEL 2 // (0 disable, 1 error, 2 info, 3 debug)
#include "SerialLog.h"
#include "CaptiverPortal.hpp"

Expand Down

0 comments on commit 51c31df

Please sign in to comment.