Git Product home page Git Product logo

effortless-spiffs's Introduction

Top Languages

effortless-spiffs's People

Contributors

per1234 avatar thebigpotatoe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

effortless-spiffs's Issues

Thil library remove files prom the spiffs

Effortless_SPIFFS when starts removes all files from spiffs on the ESP.
Environment
PlatformIO
thebigpotatoe/Effortless-SPIFFS@^2.3.0

Desktop (please complete the following information):

  • OS: WIN7
  • Browser Firefox
  • Version 89.0.2

To Reproduce
Steps to reproduce the behavior:

  1. Inslall the #include "ESPAsyncWebServer.h" and #include "SPIFFSEditor.h"
  2. upload file (in my case main web-page index.html) in platformio console put: pio run -t uploadfs
  3. Open ESP IP and see your webpage and it will be there.
  4. Install #include <Effortless_SPIFFS.h, put eSPIFFS fileSystem; and fileSystem.openFromFile("/settings.txt", mem_hourtoeat); in the code and try to open index page - there no page because it was removed from spiffs.
  5. Remove #include <Effortless_SPIFFS.h> and then again upload index.html file
  6. Open web-interface (ip of ESP) again and it will open now after deleting Effortless_SPIFFS

Expected behavior
Effortless_SPIFFS when starts clear the spiffs on the ESP i suppose.

Optional delay / consolidating writes

Is your feature request related to a problem? Please describe.
The flash memory in the ESP32 has a limited lifetime, if we write to it in a frequent loop we could kill it in less than a year.

Describe the solution you'd like
It would be nice if I could write a value to spiffs but "queue it" up for a later time. If the same value is "written" multiple times then the queue would just write the latest value. You should be able to set the max delay via a define or something similar.

Describe alternatives you've considered
n/a

delete file?

Hi! Is there any method for delete a file?
Thank you.

ESP8266 SPIFF

What is the reason of using LittleFS instead of SPIFF for ESP8266?
I have encounter problem in parsing Json using SPIFF with large data. and while searching for solution i found your library.
do you have explanation why to use LittleFS?

#if defined(ESP8266)
#include <LittleFS.h>

SD card support

Reading/writing to an SD card would be nice (or maybe as an example).

large file print to serial?

When trying to open a file and dump the contents to the Serial output, a crash occurs if the filesize is too large. In my case it was about 6kB. Running on an ESP32 in Arduino framework.

Function snippet that broke:

  fileSystem.openFromFile(filename, payload);
  Serial.print("File contents: \n");  Serial.println(payload);  

Since I'm still in development, I dump my file to the Serial port at every boot. Once the file grew too large, I got stuck in a reboot/crash loop until I wiped the filesystem.

I think I had plenty of heap available (but my heap debug prints were off), but still hit this wall.

Any way to open a SPIFFS file as a stream instead of a String, etc.?

Unable to store & read back multiple char* values

My intention is that getting WiFi SSID & password (currently hardcoded in code itself) and store it in filesystem and should use the same from next boot onwards. You can see the log that getting last PASSWORD updated value for SSID & PASSWORD too as 'test_passwdtest_passwd12@123'

_fileSystem.openFromFile("/ssid.txt", wifi_ssid);//Issue: getting WiFi password here
fileSystem.openFromFile("/password.txt", wifi_passwd);//getting WiFi password here
Serial.println("FS WiFi details after update");
Serial.println(wifi_ssid);
Serial.println(wifi_passwd);
setup_wifi(wifi_ssid, wifi_passwd);_

Code:

#include <ESP8266WiFi.h>
#include <Effortless_SPIFFS.h>

char *ssid_sta;
char *password_sta;

char* wifi_ssid;
char* wifi_passwd;

// Create fileSystem
eSPIFFS fileSystem;

bool writeToFlash = false;                                   // default value will be overriden by opening file

int run_loop = 0;

void setup() {
  delay(3000);
  Serial.begin(115200);
  Serial.println();

  // Check Flash Size - Always try to incorrperate a check when not debugging to know if you have set the SPIFFS correctly
  if (!fileSystem.checkFlashConfig()) {
    Serial.println("Flash size was not correct! Please check your SPIFFS config and try again");
    delay(1000);
    ESP.restart();
  }  

  // This will change value through reboots
  fileSystem.openFromFile("/writeToFlash.txt", writeToFlash);  // This will open the value of writeToFlash

  password_sta = (char *) malloc(100);
  ssid_sta = (char *) malloc(100);

//Actual: Get it from user webpage; hardcode for now
  String input_message;
  input_message = "test12 wifi detected!!!";
  strcpy(ssid_sta, input_message.c_str());
  input_message = "test_passwdtest_passwd12@123";
  strcpy(password_sta, input_message.c_str());
  
}
void setup_wifi(char *ssid_sta, char *password_sta) {

  static int count = 0;
  // We start by connecting to a WiFi network
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid_sta);

  WiFi.mode(WIFI_STA);
  WiFi.begin(ssid_sta, password_sta);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    //Serial.print(".");
    count++;
    if (count == 20)
      return;
  }
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());
}

void loop() {

  if (writeToFlash == false) {
    Serial.println("Looks like WiFi credentials are entered! or already stored in flash");
    fileSystem.openFromFile("/ssid.txt", wifi_ssid);
    fileSystem.openFromFile("/password.txt", wifi_passwd);
    Serial.println("Local WiFi details");
    Serial.println(ssid_sta);
    Serial.println(password_sta);

    Serial.println("FS WiFi details");
    Serial.println(wifi_ssid);
    Serial.println(wifi_passwd);

    setup_wifi(ssid_sta, password_sta);
    
    {
      IPAddress ipAddr = WiFi.localIP();
      if (ipAddr[0] != 0) {
        Serial.println("IP address is detected!");
        
        writeToFlash = true;
        if (fileSystem.saveToFile("/writeToFlash.txt", writeToFlash))
          Serial.println("Successfully wrote writeToFlash data to file");
          
        wifi_ssid = ssid_sta;
        wifi_passwd = password_sta;

        Serial.println("FS WiFi details before reboot");
        Serial.println(wifi_ssid);
        Serial.println(wifi_passwd);

        
        if (fileSystem.saveToFile("/ssid.txt", wifi_ssid))
          Serial.println("Successfully wrote wifi_ssid data to file");
          
        if (fileSystem.saveToFile("/password.txt", wifi_passwd))
          Serial.println("Successfully wrote wifi_passwd data to file");
          
        ESP.restart();
      }
    }
    
  } else if (run_loop == 0) {
    fileSystem.openFromFile("/ssid.txt", wifi_ssid);
    fileSystem.openFromFile("/password.txt", wifi_passwd);
    Serial.println("FS WiFi details after update");
    Serial.println(wifi_ssid);
    Serial.println(wifi_passwd);
    setup_wifi(wifi_ssid, wifi_passwd);
    run_loop = 1;
  }
}

Log:

Looks like WiFi credentials are entered! or already stored in flash
Local WiFi details
test12 wifi detected!!!
test_passwdtest_passwd12@123
FS WiFi details



Connecting to test12 wifi detected!!!
WiFi connected
IP address: 
192.168.0.184
IP address is detected!
Successfully wrote writeToFlash data to file
FS WiFi details before reboot
test12 wifi detected!!!
test_passwdtest_passwd12@123
Successfully wrote wifi_ssid data to file
Successfully wrote wifi_passwd data to file

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

load 0x4010f000, len 3460, room 16 
tail 4
chksum 0xcc
load 0x3fff20b8, len 40, room 4 
tail 4
chksum 0xc9
csum 0xc9
v0004a6a0
~ld

FS WiFi details after update
test_passwdtest_passwd12@123
test_passwdtest_passwd12@123

Connecting to test_passwdtest_passwd12@123

append to a file?

is it possible to append to a file?

I assume reading from the file, concatenating, and writing would work, but seems heavy duty, especially for larger files.

Store more string variables but receive back only the last

This lib will be a great choose to my wifi radio project to store/change url-s, but i have trouble to store more String. I have altered example so:

#include <Effortless_SPIFFS.h>

eSPIFFS fileSystem;
String Station1;
String Station2;

void setup(){
    Serial.begin(115200);
    Station1 = "http://retro.dancewave.online/retrodance.mp3";
    Station2 = "http://live.topfm.hu:8000/radio.mp3";
    
    // Write the data back to the SPIFFS
    if (fileSystem.saveToFile("/configuration.txt", Station1)) {
        Serial.println("Successfully wrote data to file");
    }
    if (fileSystem.saveToFile("/configuration.txt", Station2)) {
        Serial.println("Successfully wrote data to file");
    }
    
}

void loop() {
    
    if (fileSystem.openFromFile("/configuration.txt", Station1)) {
        Serial.print("Station1 url:");
        Serial.println(Station1);
    }
    delay(1000);
    if (fileSystem.openFromFile("/configuration.txt", Station2)) {
        Serial.print("Station2 url:");
        Serial.println(Station2);
    }
    delay(1000);
    
}

I wait to receive both Station 1 and Station2, but just receive only the second one:

19:43:16.441 -> Station1 url:http://live.topfm.hu:8000/radio.mp3
19:43:17.430 -> Station2 url:http://live.topfm.hu:8000/radio.mp3
19:43:18.423 -> Station1 url:http://live.topfm.hu:8000/radio.mp3
19:43:19.428 -> Station2 url:http://live.topfm.hu:8000/radio.mp3

Library allows store only one String variable?

fileSystem.saveToFile("somefile.txt", "21342314") not saving file

Hello,

I'm trying to use this tool to store values such as MQTT server address in my ESP8266 Wemos D1 Mni. But when I run the fileSystem.saveToFile("somefile.txt", "21342314"), it always returns Fale.

I've tried to send a String, char, char*, etc and it's all the same result. False. So I tried manually writing the string as per the above example and it also just returns False and no the it's stored (I think).

Any idea what's happening?

When I try to safe String or bool values, I also get these compilation errors:

  • no matching function for call to 'eSPIFFS::saveToFile(const char [12], bool)'
  • no matching function for call to 'eSPIFFS::saveToFile(const char [12], String)'

I'm a noob C++ coder. So I wouldn't be surprised if I'm doing something obvious wrong. I'd appreciate if you could point out my mistake if you see any.

thanks

File list

Hi @thebigpotatoe,

Great work on the library!

I have two feature requests.

  1. Add methods to print the list of files already stored in the SPIFFS.
  2. I want to store a large int array of ~12000 elements in the SPIFFS (as the Program memory is not enough). Is there a better way to do this? This is to store an image bytestream and then display it on a e paper screen.

Keep it up!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.