Added unmounting of SPIFFS when using OTA. Added /formatspiffs URL

This commit is contained in:
rljonesau 2019-02-11 19:34:11 +11:00
parent 25a238ddad
commit 30220e3e58
2 changed files with 18 additions and 1 deletions

View file

@ -110,6 +110,17 @@ void handleReset() {
wifiEnterConfigPortal(true, true, 3000);
}
void handleFormat() {
server.send(200, "text/plain", "Formatting SPIFFS partition!");
DebugPort.println("Formatting SPIFFS partition");
delay(500);
SPIFFS.format();
//client.disconnect();
// wifi_station_disconnect();
// wm.disconnect();
// wm.resetSettings();
}
void handleBTCNotFound() {
digitalWrite(led, 1);
String message = "File Not Found\n\n";
@ -137,7 +148,8 @@ void initWebServer(void) {
// server.on("/", handleBTCRoot);
server.on("/wmconfig", handleWMConfig);
server.on("/resetwifi",handleReset);
server.on("/resetwifi", handleReset);
server.on("/formatspiffs", handleFormat);
#if USE_SPIFFS == 1
// NOTE: this serves the default home page, and favicon.ico
server.onNotFound([]()

View file

@ -20,6 +20,10 @@
*/
#include "BTCota.h"
#include "../cfg/BTCConfig.h"
#if USE_SPIFFS == 1
#include <SPIFFS.h>
#endif
void initOTA(){
// ArduinoOTA.setHostname("myesp32");
@ -34,6 +38,7 @@ void initOTA(){
type = "filesystem";
// NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
SPIFFS.end();
DebugPort.println("Start updating " + type);
DebugPort.handle(); // keep telnet spy alive
})