mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-29 05:21:37 +03:00
Deprecate SPIFFS, move examples to LittleFS (#7263)
* Deprecate SPIFFS, move examples to LittleFS SPIFFS has been a great filesystem, but it has significant problems in many cases (and it's also pretty slow). Development seems to have slowed/stopped on the upstream version, and we're not able to provide support or fix the known issues with it as-is. Deprecate SPIFFS variable. Update all examples to use LittleFS instead of SPIFFS. Also, minor cleanup on very old examples which has obsolete delays waiting for the Serial port to come up, or which were stuck at 9600 baud because of their ancient AVR heritage. Fixes #7095 * Remove leftover debug code * Clean up comments in some examples * Update documentation on SPIFFS deprecation * Fix host tests to avoid deprecation warnings * Fix cut-n-paste error * Restore SpeedTest.ino, adjust to allow custom FSes Co-authored-by: Develo <deveyes@gmail.com>
This commit is contained in:
committed by
GitHub
parent
9845deb283
commit
83166f948b
@ -56,7 +56,7 @@ unsigned int status = WL_IDLE_STATUS;
|
||||
|
||||
void setup() {
|
||||
delay(1000);
|
||||
Serial.begin(9600);
|
||||
Serial.begin(115200);
|
||||
Serial.println();
|
||||
Serial.println("Configuring access point...");
|
||||
/* You can remove the password parameter if you want the AP to be open. */
|
||||
|
@ -15,9 +15,6 @@ byte value;
|
||||
void setup() {
|
||||
// initialize serial and wait for port to open:
|
||||
Serial.begin(115200);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
EEPROM.begin(512);
|
||||
}
|
||||
|
||||
|
@ -8,8 +8,6 @@
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266HTTPClient.h>
|
||||
|
||||
#define USE_SERIAL Serial
|
||||
|
||||
/* this can be run with an emulated server on host:
|
||||
cd esp8266-core-root-dir
|
||||
cd tests/host
|
||||
@ -27,21 +25,21 @@
|
||||
|
||||
void setup() {
|
||||
|
||||
USE_SERIAL.begin(115200);
|
||||
Serial.begin(115200);
|
||||
|
||||
USE_SERIAL.println();
|
||||
USE_SERIAL.println();
|
||||
USE_SERIAL.println();
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
|
||||
WiFi.begin(STASSID, STAPSK);
|
||||
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(500);
|
||||
USE_SERIAL.print(".");
|
||||
Serial.print(".");
|
||||
}
|
||||
USE_SERIAL.println("");
|
||||
USE_SERIAL.print("Connected! IP address: ");
|
||||
USE_SERIAL.println(WiFi.localIP());
|
||||
Serial.println("");
|
||||
Serial.print("Connected! IP address: ");
|
||||
Serial.println(WiFi.localIP());
|
||||
|
||||
}
|
||||
|
||||
@ -52,29 +50,29 @@ void loop() {
|
||||
WiFiClient client;
|
||||
HTTPClient http;
|
||||
|
||||
USE_SERIAL.print("[HTTP] begin...\n");
|
||||
Serial.print("[HTTP] begin...\n");
|
||||
// configure traged server and url
|
||||
http.begin(client, "http://" SERVER_IP "/postplain/"); //HTTP
|
||||
http.addHeader("Content-Type", "application/json");
|
||||
|
||||
USE_SERIAL.print("[HTTP] POST...\n");
|
||||
Serial.print("[HTTP] POST...\n");
|
||||
// start connection and send HTTP header and body
|
||||
int httpCode = http.POST("{\"hello\":\"world\"}");
|
||||
|
||||
// httpCode will be negative on error
|
||||
if (httpCode > 0) {
|
||||
// HTTP header has been send and Server response header has been handled
|
||||
USE_SERIAL.printf("[HTTP] POST... code: %d\n", httpCode);
|
||||
Serial.printf("[HTTP] POST... code: %d\n", httpCode);
|
||||
|
||||
// file found at server
|
||||
if (httpCode == HTTP_CODE_OK) {
|
||||
const String& payload = http.getString();
|
||||
USE_SERIAL.println("received payload:\n<<");
|
||||
USE_SERIAL.println(payload);
|
||||
USE_SERIAL.println(">>");
|
||||
Serial.println("received payload:\n<<");
|
||||
Serial.println(payload);
|
||||
Serial.println(">>");
|
||||
}
|
||||
} else {
|
||||
USE_SERIAL.printf("[HTTP] POST... failed, error: %s\n", http.errorToString(httpCode).c_str());
|
||||
Serial.printf("[HTTP] POST... failed, error: %s\n", http.errorToString(httpCode).c_str());
|
||||
}
|
||||
|
||||
http.end();
|
||||
|
@ -25,8 +25,8 @@
|
||||
|
||||
// Select the FileSystem by uncommenting one of the lines below
|
||||
|
||||
#define USE_SPIFFS
|
||||
//#define USE_LITTLEFS
|
||||
//#define USE_SPIFFS
|
||||
#define USE_LITTLEFS
|
||||
//#define USE_SDFS
|
||||
|
||||
// Uncomment the following line to embed a version of the web page in the code
|
||||
|
@ -7,10 +7,11 @@
|
||||
1. Creating a secure web server using ESP8266ESP8266WebServerSecure
|
||||
2. Use of HTTP authentication on this secure server
|
||||
3. A simple web interface to allow an authenticated user to change Credentials
|
||||
4. Persisting those credentials through a reboot of the ESP by saving them to SPIFFS without storing them as plain text
|
||||
4. Persisting those credentials through a reboot of the ESP by saving them to LittleFS without storing them as plain text
|
||||
*/
|
||||
|
||||
#include <FS.h>
|
||||
#include <LittleFS.h>
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESP8266WebServerSecure.h>
|
||||
|
||||
@ -23,8 +24,8 @@
|
||||
const char* ssid = STASSID;
|
||||
const char* wifi_pw = STAPSK;
|
||||
|
||||
const String file_credentials = R"(/credentials.txt)"; //SPIFFS file name for the saved credentials
|
||||
const String change_creds = "changecreds"; //address for a credential change
|
||||
const String file_credentials = R"(/credentials.txt)"; // LittleFS file name for the saved credentials
|
||||
const String change_creds = "changecreds"; // Address for a credential change
|
||||
|
||||
//The ESP8266WebServerSecure requires an encryption certificate and matching key.
|
||||
//These can generated with the bash script available in the ESP8266 Arduino repository.
|
||||
@ -83,7 +84,7 @@ gz5JWYhbD6c38khSzJb0pNXCo3EuYAVa36kDM96k1BtWuhRS10Q1VXk=
|
||||
|
||||
ESP8266WebServerSecure server(443);
|
||||
|
||||
//These are temporary credentials that will only be used if none are found saved in SPIFFS.
|
||||
//These are temporary credentials that will only be used if none are found saved in LittleFS.
|
||||
String login = "admin";
|
||||
const String realm = "global";
|
||||
String H1 = "";
|
||||
@ -92,9 +93,9 @@ String authentication_failed = "User authentication has failed.";
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
//Initialize SPIFFS to save credentials
|
||||
if(!SPIFFS.begin()){
|
||||
Serial.println("SPIFFS initialization error, programmer flash configured?");
|
||||
//Initialize LittleFS to save credentials
|
||||
if(!LittleFS.begin()){
|
||||
Serial.println("LittleFS initialization error, programmer flash configured?");
|
||||
ESP.restart();
|
||||
}
|
||||
|
||||
@ -187,16 +188,16 @@ void showcredentialpage(){
|
||||
server.send(200, "text/html", page);
|
||||
}
|
||||
|
||||
//Saves credentials to SPIFFS
|
||||
//Saves credentials to LittleFS
|
||||
void savecredentials(String new_login, String new_password)
|
||||
{
|
||||
//Set global variables to new values
|
||||
login=new_login;
|
||||
H1=ESP8266WebServer::credentialHash(new_login,realm,new_password);
|
||||
|
||||
//Save new values to SPIFFS for loading on next reboot
|
||||
//Save new values to LittleFS for loading on next reboot
|
||||
Serial.println("Saving credentials.");
|
||||
File f=SPIFFS.open(file_credentials,"w"); //open as a brand new file, discard old contents
|
||||
File f=LittleFS.open(file_credentials,"w"); //open as a brand new file, discard old contents
|
||||
if(f){
|
||||
Serial.println("Modifying credentials in file system.");
|
||||
f.println(login);
|
||||
@ -208,12 +209,12 @@ void savecredentials(String new_login, String new_password)
|
||||
Serial.println("Credentials saved.");
|
||||
}
|
||||
|
||||
//loads credentials from SPIFFS
|
||||
//loads credentials from LittleFS
|
||||
void loadcredentials()
|
||||
{
|
||||
Serial.println("Searching for credentials.");
|
||||
File f;
|
||||
f=SPIFFS.open(file_credentials,"r");
|
||||
f=LittleFS.open(file_credentials,"r");
|
||||
if(f){
|
||||
Serial.println("Loading credentials from file system.");
|
||||
String mod=f.readString(); //read the file to a String
|
||||
|
@ -2,11 +2,11 @@
|
||||
//
|
||||
// Before running, you must download the set of certs using
|
||||
// the script "certs-from-mozilla.py" (no parameters)
|
||||
// and then uploading the generated .AR file to SPIFFS or SD.
|
||||
// and then uploading the generated .AR file to LittleFS or SD.
|
||||
//
|
||||
// You do not need to generate the ".IDX" file listed below,
|
||||
// it is generated automatically when the CertStore object
|
||||
// is created and written to SD or SPIFFS by the ESP8266.
|
||||
// is created and written to SD or LittleFS by the ESP8266.
|
||||
//
|
||||
// Why would you need a CertStore?
|
||||
//
|
||||
@ -37,6 +37,7 @@
|
||||
#include <CertStoreBearSSL.h>
|
||||
#include <time.h>
|
||||
#include <FS.h>
|
||||
#include <LittleFS.h>
|
||||
|
||||
#ifndef STASSID
|
||||
#define STASSID "your-ssid"
|
||||
@ -117,8 +118,7 @@ void setup() {
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
|
||||
SPIFFS.begin();
|
||||
// If using a SD card or LittleFS, call the appropriate ::begin instead
|
||||
LittleFS.begin();
|
||||
|
||||
// We start by connecting to a WiFi network
|
||||
Serial.print("Connecting to ");
|
||||
@ -138,10 +138,10 @@ void setup() {
|
||||
|
||||
setClock(); // Required for X.509 validation
|
||||
|
||||
int numCerts = certStore.initCertStore(SPIFFS, PSTR("/certs.idx"), PSTR("/certs.ar"));
|
||||
int numCerts = certStore.initCertStore(LittleFS, PSTR("/certs.idx"), PSTR("/certs.ar"));
|
||||
Serial.printf("Number of CA certs read: %d\n", numCerts);
|
||||
if (numCerts == 0) {
|
||||
Serial.printf("No certs found. Did you run certs-from-mozilla.py and upload the SPIFFS directory before running?\n");
|
||||
Serial.printf("No certs found. Did you run certs-from-mozilla.py and upload the LittleFS directory before running?\n");
|
||||
return; // Can't connect to anything w/o certs!
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
# This script pulls the list of Mozilla trusted certificate authorities
|
||||
# from the web at the "mozurl" below, parses the file to grab the PEM
|
||||
# for each cert, and then generates DER files in a new ./data directory
|
||||
# Upload these to a SPIFFS filesystem and use the CertManager to parse
|
||||
# Upload these to an on-chip filesystem and use the CertManager to parse
|
||||
# and use them for your outgoing SSL connections.
|
||||
#
|
||||
# Script by Earle F. Philhower, III. Released to the public domain.
|
||||
|
@ -23,8 +23,6 @@ BearSSL KEYWORD1
|
||||
X509List KEYWORD1
|
||||
PrivateKey KEYWORD1
|
||||
PublicKey KEYWORD1
|
||||
CertStoreSPIFFSBearSSL KEYWORD1
|
||||
CertStoreSDBearSSL KEYWORD1
|
||||
Session KEYWORD1
|
||||
ESP8266WiFiGratuitous KEYWORD1
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <FS.h>
|
||||
|
||||
// Base class for the certificate stores, which allow use
|
||||
// of a large set of certificates stored on SPIFFS of SD card to
|
||||
// of a large set of certificates stored on FS or SD card to
|
||||
// be dynamically used when validating a X509 certificate
|
||||
|
||||
namespace BearSSL {
|
||||
|
@ -13,8 +13,6 @@
|
||||
#include <ESP8266HTTPClient.h>
|
||||
#include <ESP8266httpUpdate.h>
|
||||
|
||||
#define USE_SERIAL Serial
|
||||
|
||||
#ifndef APSSID
|
||||
#define APSSID "APSSID"
|
||||
#define APPSK "APPSK"
|
||||
@ -24,16 +22,16 @@ ESP8266WiFiMulti WiFiMulti;
|
||||
|
||||
void setup() {
|
||||
|
||||
USE_SERIAL.begin(115200);
|
||||
// USE_SERIAL.setDebugOutput(true);
|
||||
Serial.begin(115200);
|
||||
// Serial.setDebugOutput(true);
|
||||
|
||||
USE_SERIAL.println();
|
||||
USE_SERIAL.println();
|
||||
USE_SERIAL.println();
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
|
||||
for (uint8_t t = 4; t > 0; t--) {
|
||||
USE_SERIAL.printf("[SETUP] WAIT %d...\n", t);
|
||||
USE_SERIAL.flush();
|
||||
Serial.printf("[SETUP] WAIT %d...\n", t);
|
||||
Serial.flush();
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
@ -44,19 +42,19 @@ void setup() {
|
||||
}
|
||||
|
||||
void update_started() {
|
||||
USE_SERIAL.println("CALLBACK: HTTP update process started");
|
||||
Serial.println("CALLBACK: HTTP update process started");
|
||||
}
|
||||
|
||||
void update_finished() {
|
||||
USE_SERIAL.println("CALLBACK: HTTP update process finished");
|
||||
Serial.println("CALLBACK: HTTP update process finished");
|
||||
}
|
||||
|
||||
void update_progress(int cur, int total) {
|
||||
USE_SERIAL.printf("CALLBACK: HTTP update process at %d of %d bytes...\n", cur, total);
|
||||
Serial.printf("CALLBACK: HTTP update process at %d of %d bytes...\n", cur, total);
|
||||
}
|
||||
|
||||
void update_error(int err) {
|
||||
USE_SERIAL.printf("CALLBACK: HTTP update fatal error code %d\n", err);
|
||||
Serial.printf("CALLBACK: HTTP update fatal error code %d\n", err);
|
||||
}
|
||||
|
||||
|
||||
@ -86,15 +84,15 @@ void loop() {
|
||||
|
||||
switch (ret) {
|
||||
case HTTP_UPDATE_FAILED:
|
||||
USE_SERIAL.printf("HTTP_UPDATE_FAILD Error (%d): %s\n", ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str());
|
||||
Serial.printf("HTTP_UPDATE_FAILD Error (%d): %s\n", ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str());
|
||||
break;
|
||||
|
||||
case HTTP_UPDATE_NO_UPDATES:
|
||||
USE_SERIAL.println("HTTP_UPDATE_NO_UPDATES");
|
||||
Serial.println("HTTP_UPDATE_NO_UPDATES");
|
||||
break;
|
||||
|
||||
case HTTP_UPDATE_OK:
|
||||
USE_SERIAL.println("HTTP_UPDATE_OK");
|
||||
Serial.println("HTTP_UPDATE_OK");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
httpUpdateSPIFFS.ino
|
||||
httpUpdateLittleFS.ino
|
||||
|
||||
Created on: 05.12.2015
|
||||
|
||||
@ -13,8 +13,6 @@
|
||||
#include <ESP8266HTTPClient.h>
|
||||
#include <ESP8266httpUpdate.h>
|
||||
|
||||
#define USE_SERIAL Serial
|
||||
|
||||
ESP8266WiFiMulti WiFiMulti;
|
||||
|
||||
#ifndef APSSID
|
||||
@ -24,16 +22,16 @@ ESP8266WiFiMulti WiFiMulti;
|
||||
|
||||
void setup() {
|
||||
|
||||
USE_SERIAL.begin(115200);
|
||||
// USE_SERIAL.setDebugOutput(true);
|
||||
Serial.begin(115200);
|
||||
// Serial.setDebugOutput(true);
|
||||
|
||||
USE_SERIAL.println();
|
||||
USE_SERIAL.println();
|
||||
USE_SERIAL.println();
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
|
||||
for (uint8_t t = 4; t > 0; t--) {
|
||||
USE_SERIAL.printf("[SETUP] WAIT %d...\n", t);
|
||||
USE_SERIAL.flush();
|
||||
Serial.printf("[SETUP] WAIT %d...\n", t);
|
||||
Serial.flush();
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
@ -46,7 +44,7 @@ void loop() {
|
||||
// wait for WiFi connection
|
||||
if ((WiFiMulti.run() == WL_CONNECTED)) {
|
||||
|
||||
USE_SERIAL.println("Update SPIFFS...");
|
||||
Serial.println("Update LittleFS...");
|
||||
|
||||
WiFiClient client;
|
||||
|
||||
@ -58,22 +56,22 @@ void loop() {
|
||||
// value is used to put the LED on. If the LED is on with HIGH, that value should be passed
|
||||
ESPhttpUpdate.setLedPin(LED_BUILTIN, LOW);
|
||||
|
||||
t_httpUpdate_return ret = ESPhttpUpdate.updateSpiffs(client, "http://server/spiffs.bin");
|
||||
t_httpUpdate_return ret = ESPhttpUpdate.updateFS(client, "http://server/spiffs.bin");
|
||||
if (ret == HTTP_UPDATE_OK) {
|
||||
USE_SERIAL.println("Update sketch...");
|
||||
Serial.println("Update sketch...");
|
||||
ret = ESPhttpUpdate.update(client, "http://server/file.bin");
|
||||
|
||||
switch (ret) {
|
||||
case HTTP_UPDATE_FAILED:
|
||||
USE_SERIAL.printf("HTTP_UPDATE_FAILED Error (%d): %s", ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str());
|
||||
Serial.printf("HTTP_UPDATE_FAILED Error (%d): %s", ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str());
|
||||
break;
|
||||
|
||||
case HTTP_UPDATE_NO_UPDATES:
|
||||
USE_SERIAL.println("HTTP_UPDATE_NO_UPDATES");
|
||||
Serial.println("HTTP_UPDATE_NO_UPDATES");
|
||||
break;
|
||||
|
||||
case HTTP_UPDATE_OK:
|
||||
USE_SERIAL.println("HTTP_UPDATE_OK");
|
||||
Serial.println("HTTP_UPDATE_OK");
|
||||
break;
|
||||
}
|
||||
}
|
@ -14,8 +14,7 @@
|
||||
#include <time.h>
|
||||
|
||||
#include <FS.h>
|
||||
|
||||
#define USE_SERIAL Serial
|
||||
#include <LittleFS.h>
|
||||
|
||||
#ifndef APSSID
|
||||
#define APSSID "APSSID"
|
||||
@ -34,46 +33,47 @@ BearSSL::CertStore certStore;
|
||||
void setClock() {
|
||||
configTime(0, 0, "pool.ntp.org", "time.nist.gov"); // UTC
|
||||
|
||||
USE_SERIAL.print(F("Waiting for NTP time sync: "));
|
||||
Serial.print(F("Waiting for NTP time sync: "));
|
||||
time_t now = time(nullptr);
|
||||
while (now < 8 * 3600 * 2) {
|
||||
yield();
|
||||
delay(500);
|
||||
USE_SERIAL.print(F("."));
|
||||
Serial.print(F("."));
|
||||
now = time(nullptr);
|
||||
}
|
||||
|
||||
USE_SERIAL.println(F(""));
|
||||
Serial.println(F(""));
|
||||
struct tm timeinfo;
|
||||
gmtime_r(&now, &timeinfo);
|
||||
USE_SERIAL.print(F("Current time: "));
|
||||
USE_SERIAL.print(asctime(&timeinfo));
|
||||
Serial.print(F("Current time: "));
|
||||
Serial.print(asctime(&timeinfo));
|
||||
}
|
||||
|
||||
void setup() {
|
||||
|
||||
USE_SERIAL.begin(115200);
|
||||
// USE_SERIAL.setDebugOutput(true);
|
||||
Serial.begin(115200);
|
||||
// Serial.setDebugOutput(true);
|
||||
|
||||
USE_SERIAL.println();
|
||||
USE_SERIAL.println();
|
||||
USE_SERIAL.println();
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
Serial.println();
|
||||
|
||||
for (uint8_t t = 4; t > 0; t--) {
|
||||
USE_SERIAL.printf("[SETUP] WAIT %d...\n", t);
|
||||
USE_SERIAL.flush();
|
||||
Serial.printf("[SETUP] WAIT %d...\n", t);
|
||||
Serial.flush();
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFiMulti.addAP(APSSID, APPSK);
|
||||
|
||||
SPIFFS.begin();
|
||||
LittleFS.begin();
|
||||
|
||||
int numCerts = certStore.initCertStore(SPIFFS, PSTR("/certs.idx"), PSTR("/certs.ar"));
|
||||
USE_SERIAL.print(F("Number of CA certs read: ")); USE_SERIAL.println(numCerts);
|
||||
int numCerts = certStore.initCertStore(LittleFS, PSTR("/certs.idx"), PSTR("/certs.ar"));
|
||||
Serial.print(F("Number of CA certs read: "));
|
||||
Serial.println(numCerts);
|
||||
if (numCerts == 0) {
|
||||
USE_SERIAL.println(F("No certs found. Did you run certs-from-mozill.py and upload the SPIFFS directory before running?"));
|
||||
Serial.println(F("No certs found. Did you run certs-from-mozill.py and upload the LittleFS directory before running?"));
|
||||
return; // Can't connect to anything w/o certs!
|
||||
}
|
||||
}
|
||||
@ -86,7 +86,7 @@ void loop() {
|
||||
|
||||
BearSSL::WiFiClientSecure client;
|
||||
bool mfln = client.probeMaxFragmentLength("server", 443, 1024); // server must be the same as in ESPhttpUpdate.update()
|
||||
USE_SERIAL.printf("MFLN supported: %s\n", mfln ? "yes" : "no");
|
||||
Serial.printf("MFLN supported: %s\n", mfln ? "yes" : "no");
|
||||
if (mfln) {
|
||||
client.setBufferSizes(1024, 1024);
|
||||
}
|
||||
@ -107,15 +107,15 @@ void loop() {
|
||||
|
||||
switch (ret) {
|
||||
case HTTP_UPDATE_FAILED:
|
||||
USE_SERIAL.printf("HTTP_UPDATE_FAILED Error (%d): %s\n", ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str());
|
||||
Serial.printf("HTTP_UPDATE_FAILED Error (%d): %s\n", ESPhttpUpdate.getLastError(), ESPhttpUpdate.getLastErrorString().c_str());
|
||||
break;
|
||||
|
||||
case HTTP_UPDATE_NO_UPDATES:
|
||||
USE_SERIAL.println("HTTP_UPDATE_NO_UPDATES");
|
||||
Serial.println("HTTP_UPDATE_NO_UPDATES");
|
||||
break;
|
||||
|
||||
case HTTP_UPDATE_OK:
|
||||
USE_SERIAL.println("HTTP_UPDATE_OK");
|
||||
Serial.println("HTTP_UPDATE_OK");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ HTTPUpdateResult ESP8266HTTPUpdate::updateSpiffs(const String& url, const String
|
||||
}
|
||||
#endif
|
||||
|
||||
HTTPUpdateResult ESP8266HTTPUpdate::updateSpiffs(WiFiClient& client, const String& url, const String& currentVersion)
|
||||
HTTPUpdateResult ESP8266HTTPUpdate::updateFS(WiFiClient& client, const String& url, const String& currentVersion)
|
||||
{
|
||||
HTTPClient http;
|
||||
http.begin(client, url);
|
||||
|
@ -146,7 +146,10 @@ public:
|
||||
t_httpUpdate_return updateSpiffs(const String& url, const String& currentVersion, const String& httpsFingerprint) __attribute__((deprecated));
|
||||
t_httpUpdate_return updateSpiffs(const String& url, const String& currentVersion, const uint8_t httpsFingerprint[20]) __attribute__((deprecated)); // BearSSL
|
||||
#endif
|
||||
t_httpUpdate_return updateSpiffs(WiFiClient& client, const String& url, const String& currentVersion = "");
|
||||
t_httpUpdate_return updateFS(WiFiClient& client, const String& url, const String& currentVersion = "");
|
||||
t_httpUpdate_return updateSpiffs(WiFiClient& client, const String& url, const String& currentVersion = "") __attribute__((deprecated)) {
|
||||
return updateFS(client, url, currentVersion);
|
||||
};
|
||||
|
||||
// Notification callbacks
|
||||
void onStart(HTTPUpdateStartCB cbOnStart) { _cbStart = cbOnStart; }
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
@file OTA-mDNS-SPIFFS.ino
|
||||
@file OTA-mDNS-LittleFS.ino
|
||||
|
||||
@author Pascal Gollor (http://www.pgollor.de/cms/)
|
||||
@date 2015-09-18
|
||||
@ -22,6 +22,7 @@
|
||||
#include <ESP8266mDNS.h>
|
||||
#include <WiFiUdp.h>
|
||||
#include <FS.h>
|
||||
#include <LittleFS.h>
|
||||
#include <ArduinoOTA.h>
|
||||
|
||||
|
||||
@ -55,7 +56,7 @@ const char* ap_default_psk = STAPSK; ///< Default PSK.
|
||||
*/
|
||||
bool loadConfig(String *ssid, String *pass) {
|
||||
// open file for reading.
|
||||
File configFile = SPIFFS.open("/cl_conf.txt", "r");
|
||||
File configFile = LittleFS.open("/cl_conf.txt", "r");
|
||||
if (!configFile) {
|
||||
Serial.println("Failed to open cl_conf.txt.");
|
||||
|
||||
@ -115,7 +116,7 @@ bool loadConfig(String *ssid, String *pass) {
|
||||
*/
|
||||
bool saveConfig(String *ssid, String *pass) {
|
||||
// Open config file for writing.
|
||||
File configFile = SPIFFS.open("/cl_conf.txt", "w");
|
||||
File configFile = LittleFS.open("/cl_conf.txt", "w");
|
||||
if (!configFile) {
|
||||
Serial.println("Failed to open cl_conf.txt for writing");
|
||||
|
||||
@ -158,7 +159,7 @@ void setup() {
|
||||
|
||||
|
||||
// Initialize file system.
|
||||
if (!SPIFFS.begin()) {
|
||||
if (!LittleFS.begin()) {
|
||||
Serial.println("Failed to mount file system");
|
||||
return;
|
||||
}
|
@ -1,8 +1,17 @@
|
||||
// Simple speed test for filesystem objects
|
||||
// Released to the public domain by Earle F. Philhower, III
|
||||
|
||||
#include <FS.h>
|
||||
#include <LittleFS.h>
|
||||
|
||||
// Choose the filesystem to test
|
||||
// WARNING: The filesystem will be formatted at the start of the test!
|
||||
|
||||
#define TESTFS LittleFS
|
||||
//#define TESTFS SPIFFS
|
||||
//#define TESTFS SDFS
|
||||
|
||||
// How large of a file to test
|
||||
#define TESTSIZEKB 512
|
||||
|
||||
void DoTest(FS *fs) {
|
||||
@ -112,12 +121,9 @@ void DoTest(FS *fs) {
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
Serial.printf("Beginning LittleFS test\n");
|
||||
Serial.printf("Beginning test\n");
|
||||
Serial.flush();
|
||||
DoTest(&LittleFS);
|
||||
Serial.printf("Beginning SPIFFS test\n");
|
||||
Serial.flush();
|
||||
DoTest(&SPIFFS);
|
||||
DoTest(&TESTFS);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
@ -27,11 +27,7 @@ const int chipSelect = 4;
|
||||
|
||||
void setup() {
|
||||
// Open serial communications and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
Serial.begin(115200);
|
||||
|
||||
Serial.print("Initializing SD card...");
|
||||
|
||||
|
@ -27,11 +27,7 @@ const int chipSelect = 4;
|
||||
|
||||
void setup() {
|
||||
// Open serial communications and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
Serial.begin(115200);
|
||||
|
||||
Serial.print("Initializing SD card...");
|
||||
|
||||
|
@ -24,11 +24,7 @@ File myFile;
|
||||
|
||||
void setup() {
|
||||
// Open serial communications and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
Serial.begin(115200);
|
||||
|
||||
Serial.print("Initializing SD card...");
|
||||
|
||||
|
@ -25,11 +25,7 @@ File myFile;
|
||||
|
||||
void setup() {
|
||||
// Open serial communications and wait for port to open:
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for Leonardo only
|
||||
}
|
||||
|
||||
Serial.begin(115200);
|
||||
|
||||
Serial.print("Initializing SD card...");
|
||||
|
||||
|
@ -42,7 +42,7 @@ File bmpFile;
|
||||
|
||||
void setup() {
|
||||
|
||||
Serial.begin(9600);
|
||||
Serial.begin(115200);
|
||||
|
||||
pinMode(PIN_SD_CS, OUTPUT);
|
||||
digitalWrite(PIN_SD_CS, HIGH);
|
||||
|
@ -9,9 +9,10 @@
|
||||
|
||||
#include <ArduinoJson.h>
|
||||
#include "FS.h"
|
||||
#include <LittleFS.h>
|
||||
|
||||
bool loadConfig() {
|
||||
File configFile = SPIFFS.open("/config.json", "r");
|
||||
File configFile = LittleFS.open("/config.json", "r");
|
||||
if (!configFile) {
|
||||
Serial.println("Failed to open config file");
|
||||
return false;
|
||||
@ -56,7 +57,7 @@ bool saveConfig() {
|
||||
doc["serverName"] = "api.example.com";
|
||||
doc["accessToken"] = "128du9as8du12eoue8da98h123ueh9h98";
|
||||
|
||||
File configFile = SPIFFS.open("/config.json", "w");
|
||||
File configFile = LittleFS.open("/config.json", "w");
|
||||
if (!configFile) {
|
||||
Serial.println("Failed to open config file for writing");
|
||||
return false;
|
||||
@ -72,7 +73,7 @@ void setup() {
|
||||
delay(1000);
|
||||
Serial.println("Mounting FS...");
|
||||
|
||||
if (!SPIFFS.begin()) {
|
||||
if (!LittleFS.begin()) {
|
||||
Serial.println("Failed to mount file system");
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user