Changed FS from SPIFFS to LittleFS
This commit is contained in:
parent
39a13599c3
commit
4d8146e64b
@ -2,22 +2,24 @@
|
|||||||
platform = espressif8266
|
platform = espressif8266
|
||||||
board = esp12e
|
board = esp12e
|
||||||
framework = arduino
|
framework = arduino
|
||||||
|
board_build.filesystem = littlefs
|
||||||
board_build.ldscript = eagle.flash.4m2m.ld
|
board_build.ldscript = eagle.flash.4m2m.ld
|
||||||
lib_deps =
|
lib_deps =
|
||||||
https://github.com/aZholtikov/ZHNetwork
|
https://github.com/aZholtikov/ZHNetwork
|
||||||
https://github.com/aZholtikov/ZHConfig
|
https://github.com/aZholtikov/ZHConfig
|
||||||
|
https://github.com/aZholtikov/Async-Web-Server
|
||||||
https://github.com/bblanchon/ArduinoJson
|
https://github.com/bblanchon/ArduinoJson
|
||||||
https://github.com/me-no-dev/ESPAsyncWebServer
|
|
||||||
|
|
||||||
[env:ESP-12E-OTA]
|
[env:ESP-12E-OTA]
|
||||||
platform = espressif8266
|
platform = espressif8266
|
||||||
board = esp12e
|
board = esp12e
|
||||||
framework = arduino
|
framework = arduino
|
||||||
|
board_build.filesystem = littlefs
|
||||||
board_build.ldscript = eagle.flash.4m2m.ld
|
board_build.ldscript = eagle.flash.4m2m.ld
|
||||||
upload_port = 192.168.4.1
|
upload_port = 192.168.4.1
|
||||||
upload_protocol = espota
|
upload_protocol = espota
|
||||||
lib_deps =
|
lib_deps =
|
||||||
https://github.com/aZholtikov/ZHNetwork
|
https://github.com/aZholtikov/ZHNetwork
|
||||||
https://github.com/aZholtikov/ZHConfig
|
https://github.com/aZholtikov/ZHConfig
|
||||||
|
https://github.com/aZholtikov/Async-Web-Server
|
||||||
https://github.com/bblanchon/ArduinoJson
|
https://github.com/bblanchon/ArduinoJson
|
||||||
https://github.com/me-no-dev/ESPAsyncWebServer
|
|
19
src/main.cpp
19
src/main.cpp
@ -1,6 +1,7 @@
|
|||||||
#include "ArduinoJson.h"
|
#include "ArduinoJson.h"
|
||||||
#include "ArduinoOTA.h"
|
#include "ArduinoOTA.h"
|
||||||
#include "ESPAsyncWebServer.h"
|
#include "ESPAsyncWebServer.h" // https://github.com/aZholtikov/Async-Web-Server
|
||||||
|
#include "LittleFS.h"
|
||||||
#include "Ticker.h"
|
#include "Ticker.h"
|
||||||
#include "ZHNetwork.h"
|
#include "ZHNetwork.h"
|
||||||
#include "ZHConfig.h"
|
#include "ZHConfig.h"
|
||||||
@ -83,7 +84,7 @@ void setup()
|
|||||||
{
|
{
|
||||||
analogWriteRange(255);
|
analogWriteRange(255);
|
||||||
|
|
||||||
SPIFFS.begin();
|
LittleFS.begin();
|
||||||
|
|
||||||
loadConfig();
|
loadConfig();
|
||||||
|
|
||||||
@ -198,6 +199,7 @@ void onConfirmReceiving(const uint8_t *target, const uint16_t id, const bool sta
|
|||||||
{
|
{
|
||||||
espnow_message_t message = espnowMessage[i];
|
espnow_message_t message = espnowMessage[i];
|
||||||
if (message.id == id)
|
if (message.id == id)
|
||||||
|
{
|
||||||
if (status)
|
if (status)
|
||||||
espnowMessage.erase(espnowMessage.begin() + i);
|
espnowMessage.erase(espnowMessage.begin() + i);
|
||||||
else
|
else
|
||||||
@ -205,14 +207,15 @@ void onConfirmReceiving(const uint8_t *target, const uint16_t id, const bool sta
|
|||||||
message.id = myNet.sendUnicastMessage(message.message, gatewayMAC, true);
|
message.id = myNet.sendUnicastMessage(message.message, gatewayMAC, true);
|
||||||
espnowMessage.at(i) = message;
|
espnowMessage.at(i) = message;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadConfig()
|
void loadConfig()
|
||||||
{
|
{
|
||||||
if (!SPIFFS.exists("/config.json"))
|
if (!LittleFS.exists("/config.json"))
|
||||||
saveConfig();
|
saveConfig();
|
||||||
File file = SPIFFS.open("/config.json", "r");
|
File file = LittleFS.open("/config.json", "r");
|
||||||
String jsonFile = file.readString();
|
String jsonFile = file.readString();
|
||||||
StaticJsonDocument<512> json;
|
StaticJsonDocument<512> json;
|
||||||
deserializeJson(json, jsonFile);
|
deserializeJson(json, jsonFile);
|
||||||
@ -252,7 +255,7 @@ void saveConfig()
|
|||||||
json["green"] = green;
|
json["green"] = green;
|
||||||
json["blue"] = blue;
|
json["blue"] = blue;
|
||||||
json["system"] = "empty";
|
json["system"] = "empty";
|
||||||
File file = SPIFFS.open("/config.json", "w");
|
File file = LittleFS.open("/config.json", "w");
|
||||||
serializeJsonPretty(json, file);
|
serializeJsonPretty(json, file);
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
@ -260,7 +263,7 @@ void saveConfig()
|
|||||||
void setupWebServer()
|
void setupWebServer()
|
||||||
{
|
{
|
||||||
webServer.on("/", HTTP_GET, [](AsyncWebServerRequest *request)
|
webServer.on("/", HTTP_GET, [](AsyncWebServerRequest *request)
|
||||||
{ request->send(SPIFFS, "/index.htm"); });
|
{ request->send(LittleFS, "/index.htm"); });
|
||||||
|
|
||||||
webServer.on("/setting", HTTP_GET, [](AsyncWebServerRequest *request)
|
webServer.on("/setting", HTTP_GET, [](AsyncWebServerRequest *request)
|
||||||
{
|
{
|
||||||
@ -282,8 +285,8 @@ void setupWebServer()
|
|||||||
|
|
||||||
webServer.onNotFound([](AsyncWebServerRequest *request)
|
webServer.onNotFound([](AsyncWebServerRequest *request)
|
||||||
{
|
{
|
||||||
if (SPIFFS.exists(request->url()))
|
if (LittleFS.exists(request->url()))
|
||||||
request->send(SPIFFS, request->url());
|
request->send(LittleFS, request->url());
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
request->send(404, "text/plain", "File Not Found");
|
request->send(404, "text/plain", "File Not Found");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user