Skip to content

Commit 51c31df

Browse files
committed
ESP8266 LittleFS error with PROGMEM
1 parent fb214e3 commit 51c31df

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"files.associations": {
3-
"*.tcc": "cpp"
3+
"*.tcc": "cpp",
4+
"ostream": "cpp"
45
}
56
}

examples/customHTML/customHTML.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ void setup() {
212212
// Add custom page title to /setup
213213
server.setSetupPageTitle("Test setup page");
214214
// Add custom logo to /setup page with custom size
215-
server.setLogoBase64(base64_logo, "128", "128", /*overwite file*/ true);
215+
server.setLogoBase64(base64_logo, "128", "128", /*overwite file*/ false);
216216

217217
// Enable ACE FS file web editor and add FS info callback fucntion
218218
server.enableFsCodeEditor();

src/AsyncFsWebServer.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -266,24 +266,26 @@ void AsyncFsWebServer::setLogoBase64(const char* logo, const char* width, const
266266
strcat(filename, "_");
267267
strcat(filename, height);
268268
strcat(filename, ".txt");
269+
269270
optionToFile(filename, logo, overwrite);
270271
addOption("img-logo", filename);
271272
}
272273

273274
bool AsyncFsWebServer::optionToFile(const char* filename, const char* str, bool overWrite) {
274275
// Check if file is already saved
275-
File file = m_filesystem->open(filename, "r");
276-
if (file && !overWrite) {
277-
file.close();
276+
if (m_filesystem->exists(filename) && !overWrite) {
278277
return true;
279278
}
280279
// Create or overwrite option file
281280
else {
282-
file.close();
283-
file = m_filesystem->open(filename, "w");
284-
281+
File file = m_filesystem->open(filename, "w");
285282
if (file) {
283+
#if defined(ESP8266)
284+
String _str = str;
285+
file.print(_str);
286+
#else
286287
file.print(str);
288+
#endif
287289
file.close();
288290
log_debug("File %s saved", filename);
289291
return true;
@@ -306,6 +308,7 @@ void AsyncFsWebServer::addSource(const char* source, const char* tag, bool overW
306308
path += ".css";
307309
else if (strstr(tag, "javascript") != NULL)
308310
path += ".js";
311+
309312
optionToFile(path.c_str(), source, overWrite);
310313
addOption(tag, path.c_str(), false);
311314
}

src/AsyncFsWebServer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
#define CONFIG_FILE "/config.json"
3131

3232
#define DBG_OUTPUT_PORT Serial
33-
#define LOG_LEVEL 3 // (0 disable, 1 error, 2 info, 3 debug)
33+
#define LOG_LEVEL 2 // (0 disable, 1 error, 2 info, 3 debug)
3434
#include "SerialLog.h"
3535
#include "CaptiverPortal.hpp"
3636

0 commit comments

Comments
 (0)