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"
|
|
|
|
|
#include "Class/NotAsinc.h"
|
|
|
|
|
#include "Class/ScenarioClass.h"
|
2020-09-15 23:50:08 +03:00
|
|
|
#include "Utils/StatUtils.h"
|
2020-09-02 22:34:49 +03:00
|
|
|
#include "Cmd.h"
|
|
|
|
|
#include "Global.h"
|
|
|
|
|
#include "Init.h"
|
|
|
|
|
#include "ItemsList.h"
|
|
|
|
|
#include "Utils/Timings.h"
|
|
|
|
|
#include "Utils\WebUtils.h"
|
2020-09-03 23:29:34 +03:00
|
|
|
#include "items/ButtonInClass.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();
|
|
|
|
|
|
|
|
|
|
myNotAsincActions = new NotAsinc(do_LAST);
|
|
|
|
|
myScenario = new Scenario();
|
|
|
|
|
|
2020-09-17 21:51:56 +03:00
|
|
|
SerialPrint("I","FS","FS Init");
|
2020-09-02 22:34:49 +03:00
|
|
|
fileSystemInit();
|
|
|
|
|
|
2020-09-17 21:51:56 +03:00
|
|
|
SerialPrint("I","Conf","Config Init");
|
2020-09-02 22:34:49 +03:00
|
|
|
loadConfig();
|
|
|
|
|
|
2020-09-17 21:51:56 +03:00
|
|
|
SerialPrint("I","Time","Clock Init");
|
2020-09-02 22:34:49 +03:00
|
|
|
clock_init();
|
|
|
|
|
|
2020-09-17 21:51:56 +03:00
|
|
|
SerialPrint("I","CMD","Commands Init");
|
2020-09-02 22:34:49 +03:00
|
|
|
cmd_init();
|
|
|
|
|
|
2020-09-17 21:51:56 +03:00
|
|
|
SerialPrint("I","Sensors","Sensors Init");
|
2020-09-02 22:34:49 +03:00
|
|
|
sensorsInit();
|
|
|
|
|
|
2020-09-17 21:51:56 +03:00
|
|
|
SerialPrint("I","Init","Init Init");
|
2020-09-02 22:34:49 +03:00
|
|
|
all_init();
|
|
|
|
|
|
2020-09-17 21:51:56 +03:00
|
|
|
SerialPrint("I","WIFI","Network Init");
|
2020-09-02 22:34:49 +03:00
|
|
|
startSTAMode();
|
|
|
|
|
|
2020-09-17 21:51:56 +03:00
|
|
|
SerialPrint("I","Uptime","Uptime Init");
|
2020-09-02 22:34:49 +03:00
|
|
|
uptime_init();
|
|
|
|
|
|
2020-09-17 21:51:56 +03:00
|
|
|
SerialPrint("I","Update","Updater Init");
|
2020-09-02 22:34:49 +03:00
|
|
|
upgradeInit();
|
|
|
|
|
|
2020-09-17 21:51:56 +03:00
|
|
|
SerialPrint("I","HTTP","HttpServer Init");
|
2020-09-02 22:34:49 +03:00
|
|
|
HttpServer::init();
|
|
|
|
|
|
2020-09-17 21:51:56 +03:00
|
|
|
SerialPrint("I","Web","WebAdmin Init");
|
2020-09-02 22:34:49 +03:00
|
|
|
web_init();
|
|
|
|
|
|
2020-09-17 21:51:56 +03:00
|
|
|
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");
|
|
|
|
|
busInit();
|
2020-09-17 21:51:56 +03:00
|
|
|
|
2020-09-04 18:58:03 +03:00
|
|
|
#ifdef SSDP_EN
|
2020-09-17 18:04:06 +03:00
|
|
|
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
|
|
|
|
|
|
|
|
ts.add(
|
|
|
|
|
TEST, 1000 * 60, [&](void*) {
|
2020-09-17 18:32:39 +03:00
|
|
|
SerialPrint("I","System",printMemoryStatus());
|
2020-09-16 15:16:01 +03:00
|
|
|
|
2020-09-02 22:34:49 +03:00
|
|
|
},
|
|
|
|
|
nullptr, true);
|
|
|
|
|
|
|
|
|
|
just_load = false;
|
2020-09-15 23:50:08 +03:00
|
|
|
initialized = true; //this second POST makes the data to be processed (you don't need to connect as "keep-alive" for that to work)
|
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();
|
|
|
|
|
MqttClient::loop();
|
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
|
|
|
|
|
|
|
|
myNotAsincActions->loop();
|
|
|
|
|
ts.update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void clock_init() {
|
|
|
|
|
timeNow = new Clock();
|
|
|
|
|
timeNow->setNtpPool(jsonReadStr(configSetupJson, "ntp"));
|
|
|
|
|
timeNow->setTimezone(jsonReadStr(configSetupJson, "timezone").toInt());
|
|
|
|
|
|
|
|
|
|
ts.add(
|
|
|
|
|
TIME_SYNC, 30000, [&](void*) {
|
|
|
|
|
timeNow->hasSync();
|
|
|
|
|
},
|
|
|
|
|
nullptr, true);
|
|
|
|
|
}
|