2020-09-02 22:34:49 +03:00
|
|
|
|
|
|
|
|
#include <SSDP.h>
|
2020-12-20 17:44:40 +01:00
|
|
|
|
2020-09-04 18:58:03 +03:00
|
|
|
#include "BufferExecute.h"
|
2020-11-01 04:48:35 +03:00
|
|
|
#include "Bus.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-11-07 01:11:32 +03:00
|
|
|
#include "Class/ScenarioClass3.h"
|
2020-09-02 22:34:49 +03:00
|
|
|
#include "Cmd.h"
|
2020-12-20 17:44:40 +01:00
|
|
|
#include "FileSystem.h"
|
2020-09-02 22:34:49 +03:00
|
|
|
#include "Global.h"
|
|
|
|
|
#include "Init.h"
|
|
|
|
|
#include "ItemsList.h"
|
2020-11-01 04:48:35 +03:00
|
|
|
#include "RemoteOrdersUdp.h"
|
2020-12-20 17:44:40 +01:00
|
|
|
#include "SoftUART.h"
|
|
|
|
|
#include "Telegram.h"
|
|
|
|
|
#include "Tests.h"
|
2020-10-10 01:44:11 +03:00
|
|
|
#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"
|
2020-12-20 17:44:40 +01:00
|
|
|
#include "items/vCountDown.h"
|
2020-11-15 01:44:25 +03:00
|
|
|
#include "items/vImpulsOut.h"
|
2020-12-20 17:44:40 +01:00
|
|
|
#include "items/vLogging.h"
|
|
|
|
|
#include "items/vSensorAnalog.h"
|
2020-11-15 01:44:25 +03:00
|
|
|
#include "items/vSensorDallas.h"
|
2020-12-21 01:46:11 +01:00
|
|
|
#include "items/vSensorDht.h"
|
2020-12-24 01:41:15 +01:00
|
|
|
#include "items/vSensorUltrasonic.h"
|
2020-12-26 01:22:43 +01:00
|
|
|
#include "items/vSensorBme280.h"
|
|
|
|
|
#include "items/vSensorBmp280.h"
|
2020-11-01 16:50:44 +03:00
|
|
|
|
2020-09-02 22:34:49 +03:00
|
|
|
void not_async_actions();
|
|
|
|
|
|
|
|
|
|
Timings metric;
|
|
|
|
|
boolean initialized = false;
|
|
|
|
|
|
|
|
|
|
void setup() {
|
|
|
|
|
Serial.begin(115200);
|
|
|
|
|
Serial.flush();
|
|
|
|
|
Serial.println();
|
2020-11-17 01:01:42 +03:00
|
|
|
Serial.println(F("--------------started----------------"));
|
2020-09-02 22:34:49 +03:00
|
|
|
|
2020-10-18 09:52:17 +03:00
|
|
|
myNotAsyncActions = new NotAsync(do_LAST);
|
2020-09-02 22:34:49 +03:00
|
|
|
myScenario = new Scenario();
|
|
|
|
|
|
2020-12-10 19:12:15 +03:00
|
|
|
//=========================================initialisation==============================================================
|
|
|
|
|
setChipId();
|
2020-09-02 22:34:49 +03:00
|
|
|
fileSystemInit();
|
|
|
|
|
loadConfig();
|
2020-12-16 13:59:01 +01:00
|
|
|
#ifdef uartEnable
|
2020-12-10 19:12:15 +03:00
|
|
|
uartInit();
|
2020-12-16 13:59:01 +01:00
|
|
|
#endif
|
2020-12-10 19:12:15 +03:00
|
|
|
clockInit();
|
|
|
|
|
timeInit();
|
2020-10-10 01:44:11 +03:00
|
|
|
itemsListInit();
|
2020-12-10 19:12:15 +03:00
|
|
|
espInit();
|
2020-10-02 01:14:45 +03:00
|
|
|
routerConnect();
|
2020-12-16 19:28:44 +01:00
|
|
|
#ifdef telegramEnable
|
2020-11-04 23:48:21 +03:00
|
|
|
telegramInit();
|
2020-12-16 13:59:01 +01:00
|
|
|
#endif
|
2020-09-02 22:34:49 +03:00
|
|
|
uptime_init();
|
|
|
|
|
upgradeInit();
|
|
|
|
|
HttpServer::init();
|
|
|
|
|
web_init();
|
2020-09-06 23:00:33 +03:00
|
|
|
initSt();
|
2020-12-10 19:12:15 +03:00
|
|
|
busInit();
|
2020-12-10 20:19:21 +03:00
|
|
|
wifiSignalInit();
|
2020-11-01 04:48:35 +03:00
|
|
|
#ifdef UDP_ENABLED
|
2020-11-01 02:52:57 +03:00
|
|
|
asyncUdpInit();
|
2020-11-01 04:48:35 +03:00
|
|
|
#endif
|
2020-10-19 01:21:20 +03:00
|
|
|
#ifdef SSDP_ENABLED
|
2020-09-03 02:08:11 +03:00
|
|
|
SsdpInit();
|
2020-09-03 23:29:34 +03:00
|
|
|
#endif
|
2020-12-18 23:52:35 +01:00
|
|
|
getFSInfo();
|
2020-12-20 17:08:16 +01:00
|
|
|
|
2020-12-20 17:44:40 +01:00
|
|
|
testsPerform();
|
2020-12-20 17:08:16 +01:00
|
|
|
|
2020-09-02 22:34:49 +03:00
|
|
|
just_load = false;
|
2020-11-16 13:58:26 +03:00
|
|
|
initialized = true;
|
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();
|
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();
|
2020-10-27 02:13:45 +03:00
|
|
|
|
2020-12-16 19:28:44 +01:00
|
|
|
#ifdef telegramEnable
|
2020-11-04 23:48:21 +03:00
|
|
|
handleTelegram();
|
2020-12-16 13:59:01 +01:00
|
|
|
#endif
|
2020-11-04 23:48:21 +03:00
|
|
|
|
2020-12-16 13:59:01 +01:00
|
|
|
#ifdef uartEnable
|
2020-12-06 02:08:37 +03:00
|
|
|
uartHandle();
|
2020-12-16 13:59:01 +01:00
|
|
|
#endif
|
2020-12-06 02:08:37 +03:00
|
|
|
|
2020-11-01 00:03:08 +03:00
|
|
|
if (myLogging != nullptr) {
|
|
|
|
|
for (unsigned int i = 0; i < myLogging->size(); i++) {
|
|
|
|
|
myLogging->at(i).loop();
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-11-01 16:50:44 +03:00
|
|
|
if (myImpulsOut != nullptr) {
|
|
|
|
|
for (unsigned int i = 0; i < myImpulsOut->size(); i++) {
|
|
|
|
|
myImpulsOut->at(i).loop();
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-11-03 19:07:22 +03:00
|
|
|
if (mySensorDallas2 != nullptr) {
|
|
|
|
|
for (unsigned int i = 0; i < mySensorDallas2->size(); i++) {
|
|
|
|
|
mySensorDallas2->at(i).loop();
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-06 00:34:30 +03:00
|
|
|
if (mySensorUltrasonic != nullptr) {
|
|
|
|
|
for (unsigned int i = 0; i < mySensorUltrasonic->size(); i++) {
|
|
|
|
|
mySensorUltrasonic->at(i).loop();
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-11-18 03:25:05 +03:00
|
|
|
if (myCountDown != nullptr) {
|
|
|
|
|
for (unsigned int i = 0; i < myCountDown->size(); i++) {
|
|
|
|
|
myCountDown->at(i).loop();
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-20 17:44:40 +01:00
|
|
|
if (mySensorAnalog != nullptr) {
|
|
|
|
|
for (unsigned int i = 0; i < mySensorAnalog->size(); i++) {
|
|
|
|
|
mySensorAnalog->at(i).loop();
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-24 01:41:15 +01:00
|
|
|
if (mySensorDht != nullptr) {
|
|
|
|
|
for (unsigned int i = 0; i < mySensorDht->size(); i++) {
|
|
|
|
|
mySensorDht->at(i).loop();
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-12-26 01:22:43 +01:00
|
|
|
if (mySensorBme280 != nullptr) {
|
|
|
|
|
for (unsigned int i = 0; i < mySensorBme280->size(); i++) {
|
|
|
|
|
mySensorBme280->at(i).loop();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (mySensorBmp280 != nullptr) {
|
|
|
|
|
for (unsigned int i = 0; i < mySensorBmp280->size(); i++) {
|
|
|
|
|
mySensorBmp280->at(i).loop();
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-10-20 23:58:23 +03:00
|
|
|
}
|