Files
IoTManager/src/main.cpp

125 lines
2.6 KiB
C++
Raw Normal View History

2020-09-02 22:34:49 +03:00
#include <SSDP.h>
2020-09-06 23:00:33 +03:00
2020-09-04 18:58:03 +03:00
#include "BufferExecute.h"
2020-09-02 22:34:49 +03:00
#include "Class/CallBackTest.h"
2020-10-18 09:52:17 +03:00
#include "Class/NotAsync.h"
2020-09-02 22:34:49 +03:00
#include "Class/ScenarioClass.h"
#include "Cmd.h"
#include "Global.h"
#include "Init.h"
#include "ItemsList.h"
#include "Utils/StatUtils.h"
2020-09-02 22:34:49 +03:00
#include "Utils/Timings.h"
2020-10-18 09:52:17 +03:00
#include "Utils/WebUtils.h"
2020-09-03 23:29:34 +03:00
#include "items/ButtonInClass.h"
#include "items/LoggingClass.h"
2020-09-30 23:21:46 +03:00
//#include "RemoteOrdersUdp.h"
2020-09-18 00:24:07 +03:00
#include "Bus.h"
2020-09-02 22:34:49 +03:00
void not_async_actions();
Timings metric;
boolean initialized = false;
void setup() {
WiFi.setAutoConnect(false);
WiFi.persistent(false);
Serial.begin(115200);
Serial.flush();
Serial.println();
Serial.println("--------------started----------------");
setChipId();
2020-10-18 09:52:17 +03:00
myNotAsyncActions = new NotAsync(do_LAST);
2020-09-02 22:34:49 +03:00
myScenario = new Scenario();
SerialPrint("I", "FS", "FS Init");
2020-09-02 22:34:49 +03:00
fileSystemInit();
SerialPrint("I", "Conf", "Config Init");
2020-09-02 22:34:49 +03:00
loadConfig();
SerialPrint("I", "Time", "Clock Init");
2020-09-02 22:34:49 +03:00
clock_init();
SerialPrint("I", "CMD", "Commands Init");
2020-09-02 22:34:49 +03:00
cmd_init();
SerialPrint("I", "Sensors", "Sensors Init");
2020-09-02 22:34:49 +03:00
sensorsInit();
SerialPrint("I", "Items", "Items Init");
itemsListInit();
SerialPrint("I", "Init", "Init Init");
2020-09-02 22:34:49 +03:00
all_init();
SerialPrint("I", "WIFI", "Network Init");
2020-10-02 01:14:45 +03:00
routerConnect();
2020-09-02 22:34:49 +03:00
SerialPrint("I", "Uptime", "Uptime Init");
2020-09-02 22:34:49 +03:00
uptime_init();
SerialPrint("I", "Update", "Updater Init");
2020-09-02 22:34:49 +03:00
upgradeInit();
SerialPrint("I", "HTTP", "HttpServer Init");
2020-09-02 22:34:49 +03:00
HttpServer::init();
SerialPrint("I", "Web", "WebAdmin Init");
2020-09-02 22:34:49 +03:00
web_init();
SerialPrint("I", "Stat", "Stat Init");
2020-09-06 23:00:33 +03:00
initSt();
2020-09-30 23:21:46 +03:00
//SerialPrint("I","UDP","Udp Init");
//asyncUdpInit();
2020-09-18 00:24:07 +03:00
SerialPrint("I", "Bus", "Bus Init");
2020-09-18 00:24:07 +03:00
busInit();
2020-10-19 01:21:20 +03:00
#ifdef SSDP_ENABLED
SerialPrint("I", "SSDP", "Ssdp Init");
2020-09-03 02:08:11 +03:00
SsdpInit();
2020-09-03 23:29:34 +03:00
#endif
2020-09-02 22:34:49 +03:00
2020-10-19 01:21:20 +03:00
//esp_log_level_set("esp_littlefs", ESP_LOG_NONE);
2020-09-02 22:34:49 +03:00
ts.add(
TEST, 1000 * 60, [&](void*) {
SerialPrint("I", "System", printMemoryStatus());
2020-09-02 22:34:49 +03:00
},
nullptr, true);
just_load = false;
initialized = true; //this second POST makes the data to be processed (you don't need to connect as "keep-alive" for that to work)
myLogging = new LoggingClass[1](5000, 200, "array");
//myLogging = new LoggingClass(5000, 200, "test");
2020-09-02 22:34:49 +03:00
}
void loop() {
if (!initialized) {
return;
}
#ifdef OTA_UPDATES_ENABLED
ArduinoOTA.handle();
#endif
#ifdef WS_enable
ws.cleanupClients();
#endif
timeNow->loop();
2020-10-02 01:14:45 +03:00
mqttLoop();
2020-09-03 02:07:12 +03:00
myButtonIn.loop();
2020-09-02 22:34:49 +03:00
myScenario->loop();
2020-09-04 18:58:03 +03:00
loopCmdExecute();
//loopSerial();
2020-09-02 22:34:49 +03:00
2020-10-18 09:52:17 +03:00
myNotAsyncActions->loop();
2020-09-02 22:34:49 +03:00
ts.update();
myLogging->loop();
2020-10-20 23:58:23 +03:00
}