From 0427421cbde254bdd2e6ae7b033e078419bf6a2f Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Thu, 7 Oct 2021 12:38:47 -0700 Subject: [PATCH 1/7] prepare to migrate to LittleFS --- README.md | 8 +++----- data/js/app.js | 2 +- data/js/simple.js | 2 +- esp8266-fastled-webserver/FSBrowser.h | 19 ++++++++++--------- .../esp8266-fastled-webserver.ino | 18 ++++++++++++------ 5 files changed, 27 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index d17ee7a8..062aac7a 100644 --- a/README.md +++ b/README.md @@ -52,12 +52,10 @@ Web App Patterns are requested by the app from the ESP8266, so as new patterns are added, they're automatically listed in the app. -The web app is stored in SPIFFS (on-board flash memory). +The web app is stored in a file system in on-board flash memory. The file system used is LittleFS *(Note: prior versions used SPIFFS)*. The web app is a single page app that uses [jQuery](https://jquery.com) and [Bootstrap](http://getbootstrap.com). It has buttons for On/Off, a slider for brightness, a pattern selector, and a color picker (using [jQuery MiniColors](http://labs.abeautifulsite.net/jquery-minicolors)). Event handlers for the controls are wired up, so you don't have to click a 'Send' button after making changes. The brightness slider and the color picker use a delayed event handler, to prevent from flooding the ESP8266 web server with too many requests too quickly. -The only drawback to SPIFFS that I've found so far is uploading the files can be extremely slow, requiring several minutes, sometimes regardless of how large the files are. It can be so slow that I've been just developing the web app and debugging locally on my desktop (with a hard-coded IP for the ESP8266), before uploading to SPIFFS and testing on the ESP8266. - Installing ----------- The app is installed via the Arduino IDE which can be [downloaded here](https://www.arduino.cc/en/main/software). The ESP8266 boards will need to be added to the Arduino IDE which is achieved as follows. Click File > Preferences and copy and paste the URL "http://arduino.esp8266.com/stable/package_esp8266com_index.json" into the Additional Boards Manager URLs field. Click OK. Click Tools > Boards: ... > Boards Manager. Find and click on ESP8266 (using the Search function may expedite this). Click on Install. After installation, click on Close and then select your ESP8266 board from the Tools > Board: ... menu. @@ -74,14 +72,14 @@ Here are the board settings I use: ![image](https://user-images.githubusercontent.com/3598755/135755572-52d4d0db-1dba-4388-a86c-a293e4f13878.png) -The web app needs to be uploaded to the ESP8266's SPIFFS. You can do this within the Arduino IDE after installing the [Arduino ESP8266FS tool](http://esp8266.github.io/Arduino/versions/2.3.0/doc/filesystem.html#uploading-files-to-file-system). +The web app needs to be uploaded to the ESP8266's file system. You can do this within the Arduino IDE after installing the [Arduino ESP8266FS tool](http://esp8266.github.io/Arduino/versions/2.3.0/doc/filesystem.html#uploading-files-to-file-system). With ESP8266FS installed upload the web app using `ESP8266 Sketch Data Upload` command in the Arduino Tools menu. Compression ----------- -The web app files can be gzip compressed before uploading to SPIFFS by running the following command: +The web app files can be gzip compressed before uploading to the ESP8266's file system by running the following command: `gzip -r data/` diff --git a/data/js/app.js b/data/js/app.js index 9c40c44d..13c5e8ee 100644 --- a/data/js/app.js +++ b/data/js/app.js @@ -2,7 +2,7 @@ var address = location.hostname; var urlBase = ""; -// used when hosting the site somewhere other than the ESP8266 (handy for testing without waiting forever to upload to SPIFFS) +// used when hosting the site somewhere other than the ESP8266 (handy for testing without waiting forever to upload to SPIFFS/LittleFS) // var address = "192.168.86.36"; // var urlBase = "http://" + address + "/"; diff --git a/data/js/simple.js b/data/js/simple.js index df2c5ce8..e3b5d7ff 100644 --- a/data/js/simple.js +++ b/data/js/simple.js @@ -2,7 +2,7 @@ var address = location.hostname; var urlBase = ""; -// used when hosting the site somewhere other than the ESP8266 (handy for testing without waiting forever to upload to SPIFFS) +// used when hosting the site somewhere other than the ESP8266 (handy for testing without waiting forever to upload to SPIFFS/LittleFS) // var address = "192.168.1.13"; // var urlBase = "http://" + address + "/"; diff --git a/esp8266-fastled-webserver/FSBrowser.h b/esp8266-fastled-webserver/FSBrowser.h index 4cf82945..f68e97ad 100644 --- a/esp8266-fastled-webserver/FSBrowser.h +++ b/esp8266-fastled-webserver/FSBrowser.h @@ -1,3 +1,4 @@ + //holds the current upload File fsUploadFile; @@ -36,10 +37,10 @@ bool handleFileRead(String path){ if(path.endsWith("/")) path += "index.htm"; String contentType = getContentType(path); String pathWithGz = path + ".gz"; - if(SPIFFS.exists(pathWithGz) || SPIFFS.exists(path)){ - if(SPIFFS.exists(pathWithGz)) + if(MYFS.exists(pathWithGz) || MYFS.exists(path)){ + if(MYFS.exists(pathWithGz)) path += ".gz"; - File file = SPIFFS.open(path, "r"); + File file = MYFS.open(path, "r"); (void)webServer.streamFile(file, contentType); file.close(); @@ -55,7 +56,7 @@ void handleFileUpload(){ String filename = upload.filename; if(!filename.startsWith("/")) filename = "/"+filename; Serial.print("handleFileUpload Name: "); Serial.println(filename); - fsUploadFile = SPIFFS.open(filename, "w"); + fsUploadFile = MYFS.open(filename, "w"); filename = String(); } else if(upload.status == UPLOAD_FILE_WRITE){ //Serial.print("handleFileUpload Data: "); Serial.println(upload.currentSize); @@ -74,9 +75,9 @@ void handleFileDelete(){ Serial.println("handleFileDelete: " + path); if(path == "/") return webServer.send(500, "text/plain", "BAD PATH"); - if(!SPIFFS.exists(path)) + if(!MYFS.exists(path)) return webServer.send(404, "text/plain", "FileNotFound"); - SPIFFS.remove(path); + MYFS.remove(path); webServer.send(200, "text/plain", ""); path = String(); } @@ -88,9 +89,9 @@ void handleFileCreate(){ Serial.println("handleFileCreate: " + path); if(path == "/") return webServer.send(500, "text/plain", "BAD PATH"); - if(SPIFFS.exists(path)) + if(MYFS.exists(path)) return webServer.send(500, "text/plain", "FILE EXISTS"); - File file = SPIFFS.open(path, "w"); + File file = MYFS.open(path, "w"); if(file) file.close(); else @@ -104,7 +105,7 @@ void handleFileList() { String path = webServer.arg("dir"); Serial.println("handleFileList: " + path); - Dir dir = SPIFFS.openDir(path); + Dir dir = MYFS.openDir(path); path = String(); String output = "["; diff --git a/esp8266-fastled-webserver/esp8266-fastled-webserver.ino b/esp8266-fastled-webserver/esp8266-fastled-webserver.ino index bd73be14..e5c1ce24 100644 --- a/esp8266-fastled-webserver/esp8266-fastled-webserver.ino +++ b/esp8266-fastled-webserver/esp8266-fastled-webserver.ino @@ -27,13 +27,18 @@ extern "C" { #include "user_interface.h" } +#include +//#include +#define MYFS SPIFFS + + #include #include #include #include #include //#include -#include + #include //#include #include // https://github.com/tzapu/WiFiManager/tree/development @@ -249,11 +254,12 @@ void setup() { Serial.print( F("MAC Address: ") ); Serial.println(WiFi.macAddress()); Serial.println(); - SPIFFS.begin(); - { - Serial.println("SPIFFS contents:"); + if (!MYFS.begin()) { + Serial.println(F("An error occurred when attempting to mount the flash file system")); + } else { + Serial.println("FS contents:"); - Dir dir = SPIFFS.openDir("/"); + Dir dir = MYFS.openDir("/"); while (dir.next()) { String fileName = dir.fileName(); size_t fileSize = dir.fileSize(); @@ -477,7 +483,7 @@ void setup() { webServer.send(200, "text/plain", ""); }, handleFileUpload); - webServer.serveStatic("/", SPIFFS, "/", "max-age=86400"); + webServer.serveStatic("/", MYFS, "/", "max-age=86400"); MDNS.begin(nameChar); MDNS.setHostname(nameChar); From 7f39a83a140a7e980f7a3394d63b436a22e4938d Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Thu, 7 Oct 2021 12:57:41 -0700 Subject: [PATCH 2/7] Transition to using LittleFS --- esp8266-fastled-webserver/esp8266-fastled-webserver.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/esp8266-fastled-webserver/esp8266-fastled-webserver.ino b/esp8266-fastled-webserver/esp8266-fastled-webserver.ino index e5c1ce24..30f6a85d 100644 --- a/esp8266-fastled-webserver/esp8266-fastled-webserver.ino +++ b/esp8266-fastled-webserver/esp8266-fastled-webserver.ino @@ -27,9 +27,9 @@ extern "C" { #include "user_interface.h" } -#include -//#include -#define MYFS SPIFFS +// #include +#include +#define MYFS LittleFS #include From 4ca6afd66297a86eec87a2683166a45413ec6cc9 Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Thu, 7 Oct 2021 13:02:28 -0700 Subject: [PATCH 3/7] In Arduino, upload tool required data to be subdirectory of sketch --- .../data}/css/bootstrap.min.css | 0 .../data}/css/minicolors.min.css | 0 .../data}/css/simple.css | 0 .../data}/css/styles.css | 0 {data => esp8266-fastled-webserver/data}/edit.htm | 0 .../data}/favicon.ico | Bin .../data}/fonts/glyphicons.eot | Bin .../data}/fonts/glyphicons.svg | 0 .../data}/fonts/glyphicons.ttf | Bin .../data}/fonts/glyphicons.woff | Bin .../data}/fonts/glyphicons.woff2 | Bin .../data}/images/atom196.png | Bin .../data}/images/github.ico | Bin {data => esp8266-fastled-webserver/data}/index.htm | 0 .../data}/js/FileSaver.min.js | 0 {data => esp8266-fastled-webserver/data}/js/app.js | 0 .../data}/js/bootstrap.min.js | 0 .../data}/js/jquery-3.1.1.min.js | 0 .../data}/js/minicolors.min.js | 0 .../data}/js/r-websocket.min.js | 0 .../data}/js/simple.js | 0 {data => esp8266-fastled-webserver/data}/simple.htm | 0 {data => esp8266-fastled-webserver/data}/wifi.htm | 0 23 files changed, 0 insertions(+), 0 deletions(-) rename {data => esp8266-fastled-webserver/data}/css/bootstrap.min.css (100%) rename {data => esp8266-fastled-webserver/data}/css/minicolors.min.css (100%) rename {data => esp8266-fastled-webserver/data}/css/simple.css (100%) rename {data => esp8266-fastled-webserver/data}/css/styles.css (100%) rename {data => esp8266-fastled-webserver/data}/edit.htm (100%) rename {data => esp8266-fastled-webserver/data}/favicon.ico (100%) rename {data => esp8266-fastled-webserver/data}/fonts/glyphicons.eot (100%) rename {data => esp8266-fastled-webserver/data}/fonts/glyphicons.svg (100%) rename {data => esp8266-fastled-webserver/data}/fonts/glyphicons.ttf (100%) rename {data => esp8266-fastled-webserver/data}/fonts/glyphicons.woff (100%) rename {data => esp8266-fastled-webserver/data}/fonts/glyphicons.woff2 (100%) rename {data => esp8266-fastled-webserver/data}/images/atom196.png (100%) rename {data => esp8266-fastled-webserver/data}/images/github.ico (100%) rename {data => esp8266-fastled-webserver/data}/index.htm (100%) rename {data => esp8266-fastled-webserver/data}/js/FileSaver.min.js (100%) rename {data => esp8266-fastled-webserver/data}/js/app.js (100%) rename {data => esp8266-fastled-webserver/data}/js/bootstrap.min.js (100%) rename {data => esp8266-fastled-webserver/data}/js/jquery-3.1.1.min.js (100%) rename {data => esp8266-fastled-webserver/data}/js/minicolors.min.js (100%) rename {data => esp8266-fastled-webserver/data}/js/r-websocket.min.js (100%) rename {data => esp8266-fastled-webserver/data}/js/simple.js (100%) rename {data => esp8266-fastled-webserver/data}/simple.htm (100%) rename {data => esp8266-fastled-webserver/data}/wifi.htm (100%) diff --git a/data/css/bootstrap.min.css b/esp8266-fastled-webserver/data/css/bootstrap.min.css similarity index 100% rename from data/css/bootstrap.min.css rename to esp8266-fastled-webserver/data/css/bootstrap.min.css diff --git a/data/css/minicolors.min.css b/esp8266-fastled-webserver/data/css/minicolors.min.css similarity index 100% rename from data/css/minicolors.min.css rename to esp8266-fastled-webserver/data/css/minicolors.min.css diff --git a/data/css/simple.css b/esp8266-fastled-webserver/data/css/simple.css similarity index 100% rename from data/css/simple.css rename to esp8266-fastled-webserver/data/css/simple.css diff --git a/data/css/styles.css b/esp8266-fastled-webserver/data/css/styles.css similarity index 100% rename from data/css/styles.css rename to esp8266-fastled-webserver/data/css/styles.css diff --git a/data/edit.htm b/esp8266-fastled-webserver/data/edit.htm similarity index 100% rename from data/edit.htm rename to esp8266-fastled-webserver/data/edit.htm diff --git a/data/favicon.ico b/esp8266-fastled-webserver/data/favicon.ico similarity index 100% rename from data/favicon.ico rename to esp8266-fastled-webserver/data/favicon.ico diff --git a/data/fonts/glyphicons.eot b/esp8266-fastled-webserver/data/fonts/glyphicons.eot similarity index 100% rename from data/fonts/glyphicons.eot rename to esp8266-fastled-webserver/data/fonts/glyphicons.eot diff --git a/data/fonts/glyphicons.svg b/esp8266-fastled-webserver/data/fonts/glyphicons.svg similarity index 100% rename from data/fonts/glyphicons.svg rename to esp8266-fastled-webserver/data/fonts/glyphicons.svg diff --git a/data/fonts/glyphicons.ttf b/esp8266-fastled-webserver/data/fonts/glyphicons.ttf similarity index 100% rename from data/fonts/glyphicons.ttf rename to esp8266-fastled-webserver/data/fonts/glyphicons.ttf diff --git a/data/fonts/glyphicons.woff b/esp8266-fastled-webserver/data/fonts/glyphicons.woff similarity index 100% rename from data/fonts/glyphicons.woff rename to esp8266-fastled-webserver/data/fonts/glyphicons.woff diff --git a/data/fonts/glyphicons.woff2 b/esp8266-fastled-webserver/data/fonts/glyphicons.woff2 similarity index 100% rename from data/fonts/glyphicons.woff2 rename to esp8266-fastled-webserver/data/fonts/glyphicons.woff2 diff --git a/data/images/atom196.png b/esp8266-fastled-webserver/data/images/atom196.png similarity index 100% rename from data/images/atom196.png rename to esp8266-fastled-webserver/data/images/atom196.png diff --git a/data/images/github.ico b/esp8266-fastled-webserver/data/images/github.ico similarity index 100% rename from data/images/github.ico rename to esp8266-fastled-webserver/data/images/github.ico diff --git a/data/index.htm b/esp8266-fastled-webserver/data/index.htm similarity index 100% rename from data/index.htm rename to esp8266-fastled-webserver/data/index.htm diff --git a/data/js/FileSaver.min.js b/esp8266-fastled-webserver/data/js/FileSaver.min.js similarity index 100% rename from data/js/FileSaver.min.js rename to esp8266-fastled-webserver/data/js/FileSaver.min.js diff --git a/data/js/app.js b/esp8266-fastled-webserver/data/js/app.js similarity index 100% rename from data/js/app.js rename to esp8266-fastled-webserver/data/js/app.js diff --git a/data/js/bootstrap.min.js b/esp8266-fastled-webserver/data/js/bootstrap.min.js similarity index 100% rename from data/js/bootstrap.min.js rename to esp8266-fastled-webserver/data/js/bootstrap.min.js diff --git a/data/js/jquery-3.1.1.min.js b/esp8266-fastled-webserver/data/js/jquery-3.1.1.min.js similarity index 100% rename from data/js/jquery-3.1.1.min.js rename to esp8266-fastled-webserver/data/js/jquery-3.1.1.min.js diff --git a/data/js/minicolors.min.js b/esp8266-fastled-webserver/data/js/minicolors.min.js similarity index 100% rename from data/js/minicolors.min.js rename to esp8266-fastled-webserver/data/js/minicolors.min.js diff --git a/data/js/r-websocket.min.js b/esp8266-fastled-webserver/data/js/r-websocket.min.js similarity index 100% rename from data/js/r-websocket.min.js rename to esp8266-fastled-webserver/data/js/r-websocket.min.js diff --git a/data/js/simple.js b/esp8266-fastled-webserver/data/js/simple.js similarity index 100% rename from data/js/simple.js rename to esp8266-fastled-webserver/data/js/simple.js diff --git a/data/simple.htm b/esp8266-fastled-webserver/data/simple.htm similarity index 100% rename from data/simple.htm rename to esp8266-fastled-webserver/data/simple.htm diff --git a/data/wifi.htm b/esp8266-fastled-webserver/data/wifi.htm similarity index 100% rename from data/wifi.htm rename to esp8266-fastled-webserver/data/wifi.htm From a30efa8e5876d58f38118cb20a6289af49ad38b4 Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Thu, 7 Oct 2021 13:20:35 -0700 Subject: [PATCH 4/7] More cleanup in preparation --- .../web-app-simple-thumb.png | Bin web-app-simple.png => Images/web-app-simple.png | Bin web-app-thumb.png => Images/web-app-thumb.png | Bin web-app.png => Images/web-app.png | Bin webapp.png => Images/webapp.png | Bin deployapp.sh => scripts/deployapp.sh | 0 deployfirmware.sh => scripts/deployfirmware.sh | 0 uploadfile.sh => scripts/uploadfile.sh | 0 8 files changed, 0 insertions(+), 0 deletions(-) rename web-app-simple-thumb.png => Images/web-app-simple-thumb.png (100%) rename web-app-simple.png => Images/web-app-simple.png (100%) rename web-app-thumb.png => Images/web-app-thumb.png (100%) rename web-app.png => Images/web-app.png (100%) rename webapp.png => Images/webapp.png (100%) rename deployapp.sh => scripts/deployapp.sh (100%) rename deployfirmware.sh => scripts/deployfirmware.sh (100%) rename uploadfile.sh => scripts/uploadfile.sh (100%) diff --git a/web-app-simple-thumb.png b/Images/web-app-simple-thumb.png similarity index 100% rename from web-app-simple-thumb.png rename to Images/web-app-simple-thumb.png diff --git a/web-app-simple.png b/Images/web-app-simple.png similarity index 100% rename from web-app-simple.png rename to Images/web-app-simple.png diff --git a/web-app-thumb.png b/Images/web-app-thumb.png similarity index 100% rename from web-app-thumb.png rename to Images/web-app-thumb.png diff --git a/web-app.png b/Images/web-app.png similarity index 100% rename from web-app.png rename to Images/web-app.png diff --git a/webapp.png b/Images/webapp.png similarity index 100% rename from webapp.png rename to Images/webapp.png diff --git a/deployapp.sh b/scripts/deployapp.sh similarity index 100% rename from deployapp.sh rename to scripts/deployapp.sh diff --git a/deployfirmware.sh b/scripts/deployfirmware.sh similarity index 100% rename from deployfirmware.sh rename to scripts/deployfirmware.sh diff --git a/uploadfile.sh b/scripts/uploadfile.sh similarity index 100% rename from uploadfile.sh rename to scripts/uploadfile.sh From b130a4e1e322979c6b0da45c002adba7b72e3ab3 Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Thu, 7 Oct 2021 13:30:50 -0700 Subject: [PATCH 5/7] Update scripts --- scripts/deployapp.sh | 6 ++++++ scripts/deployfirmware.sh | 6 ++++++ scripts/uploadfile.sh | 7 +++++++ 3 files changed, 19 insertions(+) diff --git a/scripts/deployapp.sh b/scripts/deployapp.sh index 00c6bed6..900be476 100755 --- a/scripts/deployapp.sh +++ b/scripts/deployapp.sh @@ -20,6 +20,10 @@ declare -a filenames=( # "images/atom196.png" # "favicon.ico" +# TODO -- update to be based on script's own directory +# TODO -- update to switch to build directory +pushd ../esp8266-fastled-webserver > /dev/null + for filename in "${filenames[@]}" do # add --trace-ascii curl.log for logging @@ -31,3 +35,5 @@ do rm -f data/$filename.gz done + +popd > /dev/null diff --git a/scripts/deployfirmware.sh b/scripts/deployfirmware.sh index 526b0717..7de502a5 100755 --- a/scripts/deployfirmware.sh +++ b/scripts/deployfirmware.sh @@ -3,4 +3,10 @@ binFilename=tree-v2.ino.bin ip=${1:-"192.168.86.36"} url="http://$ip/update" +# TODO -- update to be based on script's own directory +# TODO -- update to switch to build directory +pushd ../esp8266-fastled-webserver > /dev/null + curl -v --form "file=@$outputDir/$binFilename;filename=$binFilename" $url + +popd > /dev/null diff --git a/scripts/uploadfile.sh b/scripts/uploadfile.sh index 4ae8b6a7..7718ee21 100755 --- a/scripts/uploadfile.sh +++ b/scripts/uploadfile.sh @@ -10,9 +10,16 @@ filename=$2 # add --trace-ascii curl.log for logging +# TODO -- update to be based on script's own directory +# TODO -- update to switch to build directory +pushd ../esp8266-fastled-webserver > /dev/null + gzip -kf data/$filename echo $filename curl --form "file=@data/$filename.gz;filename=$filename.gz" $url rm -f data/$filename.gz + +popd > /dev/null + From e8d718cde95aca2b7d7cb283917f5b3596fc2ea2 Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Thu, 7 Oct 2021 13:55:13 -0700 Subject: [PATCH 6/7] Update tool for uploading LittleFS --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 062aac7a..2864800d 100644 --- a/README.md +++ b/README.md @@ -72,9 +72,10 @@ Here are the board settings I use: ![image](https://user-images.githubusercontent.com/3598755/135755572-52d4d0db-1dba-4388-a86c-a293e4f13878.png) -The web app needs to be uploaded to the ESP8266's file system. You can do this within the Arduino IDE after installing the [Arduino ESP8266FS tool](http://esp8266.github.io/Arduino/versions/2.3.0/doc/filesystem.html#uploading-files-to-file-system). +The web app needs to be uploaded to the ESP8266's file system. +You can do this within the Arduino IDE after installing the [Arduino ESP8266 LittleFS](https://github.com/earlephilhower/arduino-esp8266littlefs-plugin). -With ESP8266FS installed upload the web app using `ESP8266 Sketch Data Upload` command in the Arduino Tools menu. +With the upload tool installed, upload the web app using `ESP8266 LittleFS Data Upload` command in the Arduino Tools menu. Compression ----------- From 8cb78f7b56022826db21340a26ba41be9e9ae172 Mon Sep 17 00:00:00 2001 From: Henry Gabryjelski Date: Thu, 7 Oct 2021 21:20:59 -0700 Subject: [PATCH 7/7] SPIFFS vs. LittleFS regression fix --- esp8266-fastled-webserver/FSBrowser.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/esp8266-fastled-webserver/FSBrowser.h b/esp8266-fastled-webserver/FSBrowser.h index f68e97ad..08fa4f7d 100644 --- a/esp8266-fastled-webserver/FSBrowser.h +++ b/esp8266-fastled-webserver/FSBrowser.h @@ -113,10 +113,12 @@ void handleFileList() { File entry = dir.openFile("r"); if (output != "[") output += ','; bool isDir = false; + //bool isDir = entry.isDirectory(); + output += "{\"type\":\""; output += (isDir)?"dir":"file"; output += "\",\"name\":\""; - output += String(entry.name()).substring(1); + output += String(entry.name()); output += "\"}"; entry.close(); }