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"
|
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-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();
|
|
|
|
|
|
2020-10-10 01:44:11 +03:00
|
|
|
SerialPrint("I", "FS", "FS Init");
|
2020-09-02 22:34:49 +03:00
|
|
|
fileSystemInit();
|
|
|
|
|
|
2020-10-10 01:44:11 +03:00
|
|
|
SerialPrint("I", "Conf", "Config Init");
|
2020-09-02 22:34:49 +03:00
|
|
|
loadConfig();
|
|
|
|
|
|
2020-10-10 01:44:11 +03:00
|
|
|
SerialPrint("I", "Time", "Clock Init");
|
2020-09-02 22:34:49 +03:00
|
|
|
clock_init();
|
|
|
|
|
|
2020-10-10 01:44:11 +03:00
|
|
|
SerialPrint("I", "CMD", "Commands Init");
|
2020-09-02 22:34:49 +03:00
|
|
|
cmd_init();
|
|
|
|
|
|
2020-10-10 01:44:11 +03:00
|
|
|
SerialPrint("I", "Sensors", "Sensors Init");
|
2020-09-02 22:34:49 +03:00
|
|
|
sensorsInit();
|
|
|
|
|
|
2020-10-10 01:44:11 +03:00
|
|
|
SerialPrint("I", "Items", "Items Init");
|
|
|
|
|
itemsListInit();
|
|
|
|
|
|
|
|
|
|
SerialPrint("I", "Init", "Init Init");
|
2020-09-02 22:34:49 +03:00
|
|
|
all_init();
|
|
|
|
|
|
2020-10-10 01:44:11 +03:00
|
|
|
SerialPrint("I", "WIFI", "Network Init");
|
2020-10-02 01:14:45 +03:00
|
|
|
routerConnect();
|
2020-09-02 22:34:49 +03:00
|
|
|
|
2020-10-10 01:44:11 +03:00
|
|
|
SerialPrint("I", "Uptime", "Uptime Init");
|
2020-09-02 22:34:49 +03:00
|
|
|
uptime_init();
|
|
|
|
|
|
2020-10-10 01:44:11 +03:00
|
|
|
SerialPrint("I", "Update", "Updater Init");
|
2020-09-02 22:34:49 +03:00
|
|
|
upgradeInit();
|
|
|
|
|
|
2020-10-10 01:44:11 +03:00
|
|
|
SerialPrint("I", "HTTP", "HttpServer Init");
|
2020-09-02 22:34:49 +03:00
|
|
|
HttpServer::init();
|
|
|
|
|
|
2020-10-10 01:44:11 +03:00
|
|
|
SerialPrint("I", "Web", "WebAdmin Init");
|
2020-09-02 22:34:49 +03:00
|
|
|
web_init();
|
|
|
|
|
|
2020-10-10 01:44:11 +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
|
|
|
|
2020-10-10 01:44:11 +03:00
|
|
|
SerialPrint("I", "Bus", "Bus Init");
|
2020-09-18 00:24:07 +03:00
|
|
|
busInit();
|
2020-10-10 01:44:11 +03:00
|
|
|
|
2020-10-19 01:21:20 +03:00
|
|
|
#ifdef SSDP_ENABLED
|
2020-10-10 01:44:11 +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
|
|
|
|
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*) {
|
2020-10-10 01:44:11 +03:00
|
|
|
SerialPrint("I", "System", printMemoryStatus());
|
2020-09-02 22:34:49 +03:00
|
|
|
},
|
|
|
|
|
nullptr, true);
|
|
|
|
|
|
|
|
|
|
just_load = false;
|
2020-10-10 01:44:11 +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();
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|