From 401aaa727e9a42f0555388d05a9fd70ea4b8a44e Mon Sep 17 00:00:00 2001 From: Dmitry Borisenko <49808844+DmitryBorisenko33@users.noreply.github.com> Date: Thu, 23 Dec 2021 22:56:45 +0100 Subject: [PATCH] =?UTF-8?q?=D1=84=D0=B8=D0=BD=D0=B0=D0=BB=D1=8C=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D1=8F=20=D1=81=20?= =?UTF-8?q?=D0=B4=D0=B2=D1=83=D0=BC=D1=8F=20=D1=81=D0=B5=D1=80=D0=B2=D0=B5?= =?UTF-8?q?=D1=80=D0=B0=D0=BC=D0=B8=20esp8266=20=D0=B8=20esp32?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/AsyncWebServer.h | 1 - include/Const.h | 3 +++ include/Global.h | 10 ++++++++++ include/StandWebServer.h | 2 +- platformio.ini | 2 +- src/Global.cpp | 5 +++++ src/StandWebServer.cpp | 4 ++-- 7 files changed, 22 insertions(+), 5 deletions(-) diff --git a/include/AsyncWebServer.h b/include/AsyncWebServer.h index f6d31635..f3fcb8f3 100644 --- a/include/AsyncWebServer.h +++ b/include/AsyncWebServer.h @@ -3,7 +3,6 @@ #ifdef ASYNC_WEB_SERVER extern AsyncWebSocket ws; extern AsyncEventSource events; - void asyncWebServerInit(); void asyncWebSocketsInit(); void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len); diff --git a/include/Const.h b/include/Const.h index 0c5b660b..72cb9b1e 100644 --- a/include/Const.h +++ b/include/Const.h @@ -1,9 +1,12 @@ #pragma once +//Это версия прошивки #define FIRMWARE_VERSION 400 +//Размер буфера json #define JSON_BUFFER_SIZE 4096 +//выбор сервера //#define ASYNC_WEB_SERVER #define STANDARD_WEB_SERVER diff --git a/include/Global.h b/include/Global.h index af561423..fa979512 100644 --- a/include/Global.h +++ b/include/Global.h @@ -23,9 +23,14 @@ #endif #ifdef STANDARD_WEB_SERVER +#ifdef ESP8266 #include #include #endif +#ifdef ESP32 +#include +#endif +#endif #include @@ -41,9 +46,14 @@ extern AsyncWebServer server; #endif #ifdef STANDARD_WEB_SERVER +#ifdef ESP8266 extern ESP8266WebServer HTTP; extern ESP8266HTTPUpdateServer httpUpdater; #endif +#ifdef ESP32 +extern WebServer HTTP; +#endif +#endif //глобальные переменные extern String settingsFlashJson; diff --git a/include/StandWebServer.h b/include/StandWebServer.h index 7d933446..58fdea00 100644 --- a/include/StandWebServer.h +++ b/include/StandWebServer.h @@ -7,7 +7,7 @@ extern void standWebServerFiles(); extern bool handleFileRead(String path); extern String getContentType(String filename); -#ifdef RSET_FILE_OPERATIONS +#ifdef REST_FILE_OPERATIONS extern void handleFileUpload(); extern void handleFileDelete(); extern void handleFileCreate(); diff --git a/platformio.ini b/platformio.ini index bbf774be..de41a0ff 100644 --- a/platformio.ini +++ b/platformio.ini @@ -10,7 +10,7 @@ [platformio] -default_envs = esp8266_4mb +default_envs = esp32_4mb data_dir = data_svelte [common_env_data] diff --git a/src/Global.cpp b/src/Global.cpp index 59564de5..2c634201 100644 --- a/src/Global.cpp +++ b/src/Global.cpp @@ -7,9 +7,14 @@ AsyncWebServer server(80); #endif #ifdef STANDARD_WEB_SERVER +#ifdef ESP8266 ESP8266HTTPUpdateServer httpUpdater; ESP8266WebServer HTTP(80); #endif +#ifdef ESP32 +WebServer HTTP(80); +#endif +#endif //глобальные переменные String settingsFlashJson = "{}"; //переменная в которой хранятся все настройки, находится в оперативной памяти и синхронизированна с flash памятью diff --git a/src/StandWebServer.cpp b/src/StandWebServer.cpp index 3682eb38..2fb0dc19 100644 --- a/src/StandWebServer.cpp +++ b/src/StandWebServer.cpp @@ -24,7 +24,7 @@ void standWebServerInit() { File fsUploadFile; void standWebServerFiles() { -#ifdef RSET_FILE_OPERATIONS +#ifdef REST_FILE_OPERATIONS SPIFFS.begin(); { Dir dir = SPIFFS.openDir("/"); @@ -107,7 +107,7 @@ String getContentType(String filename) { return "text/plain"; } -#ifdef RSET_FILE_OPERATIONS +#ifdef REST_FILE_OPERATIONS // Здесь функции для работы с файловой системой void handleFileUpload() { if (HTTP.uri() != "/edit") return;