ws started

This commit is contained in:
Dmitry Borisenko
2021-12-04 22:19:03 +01:00
parent eae59e3947
commit 2573e73b3a
5 changed files with 29 additions and 39 deletions

View File

@@ -55,7 +55,7 @@
#define DEVICE_SCENARIO_FILE "s.scen.txt"
//#define OTA_UPDATES_ENABLED
//#define MDNS_ENABLED
//#define WEBSOCKET_ENABLED
#define WEBSOCKET_ENABLED
//#define LAYOUT_IN_RAM
//#define UDP_ENABLED
//#define SSDP_ENABLED

View File

@@ -1,7 +1,7 @@
#pragma once
#ifdef ESP8266
#include <ESP8266WebServer.h>
//#include <ESP8266WebServer.h>
#include <ESP8266httpUpdate.h>
#include "ESPAsyncTCP.h"
#include "ESPAsyncWebServer.h"

View File

@@ -1,8 +1,6 @@
#pragma once
//===================Libraries===================================================================================================================================================
#include "Consts.h"
#include <Arduino.h>
#include "CTBot.h"
#include <ArduinoJson.h>
#include <ArduinoOTA.h>
#include <PubSubClient.h>
@@ -10,13 +8,15 @@
#include <TickerScheduler.h>
#include <Wire.h>
#include <time.h>
#include "CTBot.h"
#include "Clock.h"
#include "Consts.h"
#include "ESP32.h"
#include "ESP8266.h"
#include "GyverFilters.h"
#include "MqttClient.h"
#include "Upgrade.h"
#include "Utils/FileUtils.h"
#include "Utils/JsonUtils.h"
#include "Utils/SerialPrint.h"
@@ -26,25 +26,20 @@
#ifdef WEBSOCKET_ENABLED
extern AsyncWebSocket ws;
//extern AsyncEventSource events;
extern AsyncEventSource events;
#endif
extern TickerScheduler ts;
extern WiFiClient espClient;
extern PubSubClient mqtt;
extern StringCommand sCmd;
extern AsyncWebServer server;
// Global vars
extern boolean just_load;
extern boolean telegramInitBeen;
extern boolean savedFromWeb;
// Json
extern String configSetupJson; //все настройки
extern String configLiveJson; //все данные с датчиков (связан с mqtt)
@@ -101,12 +96,9 @@ extern String logging_KeyList;
extern int logging_EnterCounter;
//=========================================
extern String itemName;
extern String presetName;
extern int scenario_line_status[40];
extern int lastVersion;

View File

@@ -1,12 +1,12 @@
#include "HttpServer.h"
#include "BufferExecute.h"
#include "FSEditor.h"
#include "HttpServer.h"
#include "Utils/FileUtils.h"
#include "Utils/WebUtils.h"
#include "FSEditor.h"
AsyncWebSocket ws("/ws");
AsyncEventSource events("/events");
namespace HttpServer {
/* Forward declaration */
void initOta();
void initMDNS();
@@ -74,8 +74,6 @@ void init() {
request->send(200, "text/html", "OK");
});
server.begin();
initOta();

View File

@@ -84,8 +84,8 @@ void setup() {
just_load = false;
initialized = true;
const int capacity = JSON_OBJECT_SIZE(35);
SerialPrint("I", F("Test"), String(capacity));
// const int capacity = JSON_OBJECT_SIZE(35);
// SerialPrint("I", F("Test"), String(capacity));
ts.add(
MYTEST, 5000, [&](void*) {