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 DEVICE_SCENARIO_FILE "s.scen.txt"
//#define OTA_UPDATES_ENABLED //#define OTA_UPDATES_ENABLED
//#define MDNS_ENABLED //#define MDNS_ENABLED
//#define WEBSOCKET_ENABLED #define WEBSOCKET_ENABLED
//#define LAYOUT_IN_RAM //#define LAYOUT_IN_RAM
//#define UDP_ENABLED //#define UDP_ENABLED
//#define SSDP_ENABLED //#define SSDP_ENABLED

View File

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

View File

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

View File

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

View File

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