Compare commits

...

2 Commits

Author SHA1 Message Date
24ba0a09f4 Version 1.26
Changed FS from SPIFFS to LittleFS.
2023-02-04 10:52:52 +03:00
eebaca38b7 Minor changes 2023-01-28 14:07:38 +03:00
2 changed files with 28 additions and 24 deletions

View File

@ -2,48 +2,52 @@
platform = espressif8266 platform = espressif8266
board = nodemcuv2 board = nodemcuv2
framework = arduino framework = arduino
board_build.filesystem = littlefs
lib_deps = lib_deps =
https://github.com/aZholtikov/ZHNetwork https://github.com/aZholtikov/ZHNetwork
https://github.com/aZholtikov/ZHConfig https://github.com/aZholtikov/ZHConfig
bblanchon/ArduinoJson@^6.19.4 https://github.com/aZholtikov/Async-Web-Server
me-no-dev/ESP Async WebServer@^1.2.3 https://github.com/bblanchon/ArduinoJson
marvinroger/AsyncMqttClient@^0.9.0 https://github.com/marvinroger/async-mqtt-client
[env:ESP8266-OTA] [env:ESP8266-OTA]
platform = espressif8266 platform = espressif8266
board = nodemcuv2 board = nodemcuv2
framework = arduino framework = arduino
board_build.filesystem = littlefs
upload_port = 192.168.1.113 upload_port = 192.168.1.113
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
bblanchon/ArduinoJson@^6.19.4 https://github.com/aZholtikov/Async-Web-Server
me-no-dev/ESP Async WebServer@^1.2.3 https://github.com/bblanchon/ArduinoJson
marvinroger/AsyncMqttClient@^0.9.0 https://github.com/marvinroger/async-mqtt-client
[env:ESP32] [env:ESP32]
platform = espressif32 platform = espressif32
board = az-delivery-devkit-v4 board = az-delivery-devkit-v4
framework = arduino framework = arduino
board_build.filesystem = littlefs
lib_deps = lib_deps =
https://github.com/aZholtikov/ZHNetwork https://github.com/aZholtikov/ZHNetwork
https://github.com/aZholtikov/ZHConfig https://github.com/aZholtikov/ZHConfig
bblanchon/ArduinoJson@^6.19.4 https://github.com/aZholtikov/Async-Web-Server
me-no-dev/ESP Async WebServer@^1.2.3 https://github.com/bblanchon/ArduinoJson
marvinroger/AsyncMqttClient@^0.9.0 https://github.com/marvinroger/async-mqtt-client
luc-github/ESP32SSDP@^1.2.0 https://github.com/luc-github/ESP32SSDP
[env:ESP32-OTA] [env:ESP32-OTA]
platform = espressif32 platform = espressif32
board = az-delivery-devkit-v4 board = az-delivery-devkit-v4
framework = arduino framework = arduino
board_build.filesystem = littlefs
upload_port = 192.168.1.110 upload_port = 192.168.1.110
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
bblanchon/ArduinoJson@^6.19.4 https://github.com/aZholtikov/Async-Web-Server
me-no-dev/ESP Async WebServer@^1.2.3 https://github.com/bblanchon/ArduinoJson
marvinroger/AsyncMqttClient@^0.9.0 https://github.com/marvinroger/async-mqtt-client
luc-github/ESP32SSDP@^1.2.0 https://github.com/luc-github/ESP32SSDP

View File

@ -1,7 +1,8 @@
#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 "AsyncMQTTClient.h" #include "AsyncMQTTClient.h"
#include "LittleFS.h"
#include "Ticker.h" #include "Ticker.h"
#include "ZHNetwork.h" #include "ZHNetwork.h"
#include "ZHConfig.h" #include "ZHConfig.h"
@ -9,7 +10,6 @@
#include "ESP8266SSDP.h" #include "ESP8266SSDP.h"
#endif #endif
#if defined(ESP32) #if defined(ESP32)
#include "SPIFFS.h"
#include "ESP32SSDP.h" #include "ESP32SSDP.h"
#endif #endif
@ -34,7 +34,7 @@ void setupWebServer(void);
void connectToMqtt(void); void connectToMqtt(void);
const String firmware{"1.25"}; const String firmware{"1.26"};
String espnowNetName{"DEFAULT"}; String espnowNetName{"DEFAULT"};
@ -72,7 +72,7 @@ void attributesMessageTimerCallback(void);
void setup() void setup()
{ {
SPIFFS.begin(); LittleFS.begin();
loadConfig(); loadConfig();
@ -433,9 +433,9 @@ String getValue(String data, char separator, uint8_t index)
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<1024> json; StaticJsonDocument<1024> json;
deserializeJson(json, jsonFile); deserializeJson(json, jsonFile);
@ -465,7 +465,7 @@ void saveConfig()
json["mqttUserPassword"] = mqttUserPassword; json["mqttUserPassword"] = mqttUserPassword;
json["topicPrefix"] = topicPrefix; json["topicPrefix"] = topicPrefix;
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();
} }
@ -505,7 +505,7 @@ void setupWebServer()
request->send(200, "text/xml", ssdpSend); }); request->send(200, "text/xml", ssdpSend); });
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)
{ {
@ -528,8 +528,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");