mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 20:09:14 +03:00
финальная версия с двумя серверами esp8266 и esp32
This commit is contained in:
@@ -3,7 +3,6 @@
|
|||||||
#ifdef ASYNC_WEB_SERVER
|
#ifdef ASYNC_WEB_SERVER
|
||||||
extern AsyncWebSocket ws;
|
extern AsyncWebSocket ws;
|
||||||
extern AsyncEventSource events;
|
extern AsyncEventSource events;
|
||||||
|
|
||||||
void asyncWebServerInit();
|
void asyncWebServerInit();
|
||||||
void asyncWebSocketsInit();
|
void asyncWebSocketsInit();
|
||||||
void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len);
|
void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len);
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
//Это версия прошивки
|
||||||
#define FIRMWARE_VERSION 400
|
#define FIRMWARE_VERSION 400
|
||||||
|
|
||||||
|
//Размер буфера json
|
||||||
#define JSON_BUFFER_SIZE 4096
|
#define JSON_BUFFER_SIZE 4096
|
||||||
|
|
||||||
|
//выбор сервера
|
||||||
//#define ASYNC_WEB_SERVER
|
//#define ASYNC_WEB_SERVER
|
||||||
#define STANDARD_WEB_SERVER
|
#define STANDARD_WEB_SERVER
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,14 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef STANDARD_WEB_SERVER
|
#ifdef STANDARD_WEB_SERVER
|
||||||
|
#ifdef ESP8266
|
||||||
#include <ESP8266WebServer.h>
|
#include <ESP8266WebServer.h>
|
||||||
#include <ESP8266HTTPUpdateServer.h>
|
#include <ESP8266HTTPUpdateServer.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ESP32
|
||||||
|
#include <WebServer.h>
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <FS.h>
|
#include <FS.h>
|
||||||
|
|
||||||
@@ -41,9 +46,14 @@ extern AsyncWebServer server;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef STANDARD_WEB_SERVER
|
#ifdef STANDARD_WEB_SERVER
|
||||||
|
#ifdef ESP8266
|
||||||
extern ESP8266WebServer HTTP;
|
extern ESP8266WebServer HTTP;
|
||||||
extern ESP8266HTTPUpdateServer httpUpdater;
|
extern ESP8266HTTPUpdateServer httpUpdater;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ESP32
|
||||||
|
extern WebServer HTTP;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
//глобальные переменные
|
//глобальные переменные
|
||||||
extern String settingsFlashJson;
|
extern String settingsFlashJson;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ extern void standWebServerFiles();
|
|||||||
extern bool handleFileRead(String path);
|
extern bool handleFileRead(String path);
|
||||||
extern String getContentType(String filename);
|
extern String getContentType(String filename);
|
||||||
|
|
||||||
#ifdef RSET_FILE_OPERATIONS
|
#ifdef REST_FILE_OPERATIONS
|
||||||
extern void handleFileUpload();
|
extern void handleFileUpload();
|
||||||
extern void handleFileDelete();
|
extern void handleFileDelete();
|
||||||
extern void handleFileCreate();
|
extern void handleFileCreate();
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
|
|
||||||
[platformio]
|
[platformio]
|
||||||
default_envs = esp8266_4mb
|
default_envs = esp32_4mb
|
||||||
data_dir = data_svelte
|
data_dir = data_svelte
|
||||||
|
|
||||||
[common_env_data]
|
[common_env_data]
|
||||||
|
|||||||
@@ -7,9 +7,14 @@ AsyncWebServer server(80);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef STANDARD_WEB_SERVER
|
#ifdef STANDARD_WEB_SERVER
|
||||||
|
#ifdef ESP8266
|
||||||
ESP8266HTTPUpdateServer httpUpdater;
|
ESP8266HTTPUpdateServer httpUpdater;
|
||||||
ESP8266WebServer HTTP(80);
|
ESP8266WebServer HTTP(80);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ESP32
|
||||||
|
WebServer HTTP(80);
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
//глобальные переменные
|
//глобальные переменные
|
||||||
String settingsFlashJson = "{}"; //переменная в которой хранятся все настройки, находится в оперативной памяти и синхронизированна с flash памятью
|
String settingsFlashJson = "{}"; //переменная в которой хранятся все настройки, находится в оперативной памяти и синхронизированна с flash памятью
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ void standWebServerInit() {
|
|||||||
File fsUploadFile;
|
File fsUploadFile;
|
||||||
|
|
||||||
void standWebServerFiles() {
|
void standWebServerFiles() {
|
||||||
#ifdef RSET_FILE_OPERATIONS
|
#ifdef REST_FILE_OPERATIONS
|
||||||
SPIFFS.begin();
|
SPIFFS.begin();
|
||||||
{
|
{
|
||||||
Dir dir = SPIFFS.openDir("/");
|
Dir dir = SPIFFS.openDir("/");
|
||||||
@@ -107,7 +107,7 @@ String getContentType(String filename) {
|
|||||||
return "text/plain";
|
return "text/plain";
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef RSET_FILE_OPERATIONS
|
#ifdef REST_FILE_OPERATIONS
|
||||||
// Здесь функции для работы с файловой системой
|
// Здесь функции для работы с файловой системой
|
||||||
void handleFileUpload() {
|
void handleFileUpload() {
|
||||||
if (HTTP.uri() != "/edit") return;
|
if (HTTP.uri() != "/edit") return;
|
||||||
|
|||||||
Reference in New Issue
Block a user