mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
финальная версия с двумя серверами esp8266 и esp32
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
//Это версия прошивки
|
||||
#define FIRMWARE_VERSION 400
|
||||
|
||||
//Размер буфера json
|
||||
#define JSON_BUFFER_SIZE 4096
|
||||
|
||||
//выбор сервера
|
||||
//#define ASYNC_WEB_SERVER
|
||||
#define STANDARD_WEB_SERVER
|
||||
|
||||
|
||||
@@ -23,9 +23,14 @@
|
||||
#endif
|
||||
|
||||
#ifdef STANDARD_WEB_SERVER
|
||||
#ifdef ESP8266
|
||||
#include <ESP8266WebServer.h>
|
||||
#include <ESP8266HTTPUpdateServer.h>
|
||||
#endif
|
||||
#ifdef ESP32
|
||||
#include <WebServer.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <FS.h>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
[platformio]
|
||||
default_envs = esp8266_4mb
|
||||
default_envs = esp32_4mb
|
||||
data_dir = data_svelte
|
||||
|
||||
[common_env_data]
|
||||
|
||||
@@ -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 памятью
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user