From 30220e3e588da7862157f324d3876926d17ef7b9 Mon Sep 17 00:00:00 2001 From: rljonesau Date: Mon, 11 Feb 2019 19:34:11 +1100 Subject: [PATCH] Added unmounting of SPIFFS when using OTA. Added /formatspiffs URL --- Arduino/BTCDieselHeater/src/WiFi/BTCWebServer.cpp | 14 +++++++++++++- Arduino/BTCDieselHeater/src/WiFi/BTCota.cpp | 5 +++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Arduino/BTCDieselHeater/src/WiFi/BTCWebServer.cpp b/Arduino/BTCDieselHeater/src/WiFi/BTCWebServer.cpp index a1cb52a..54e0a71 100644 --- a/Arduino/BTCDieselHeater/src/WiFi/BTCWebServer.cpp +++ b/Arduino/BTCDieselHeater/src/WiFi/BTCWebServer.cpp @@ -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([]() diff --git a/Arduino/BTCDieselHeater/src/WiFi/BTCota.cpp b/Arduino/BTCDieselHeater/src/WiFi/BTCota.cpp index 5531c4f..6606e3c 100644 --- a/Arduino/BTCDieselHeater/src/WiFi/BTCota.cpp +++ b/Arduino/BTCDieselHeater/src/WiFi/BTCota.cpp @@ -20,6 +20,10 @@ */ #include "BTCota.h" +#include "../cfg/BTCConfig.h" +#if USE_SPIFFS == 1 +#include +#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 })