mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2025-12-13 02:52:11 +01:00
69 lines
1.8 KiB
C++
69 lines
1.8 KiB
C++
#include <WiFi.h>
|
|
#include <LittleFS.h>
|
|
#include "ConfigSettings.h"
|
|
#include "Network.h"
|
|
#include "Web.h"
|
|
#include "Sockets.h"
|
|
#include "Utils.h"
|
|
#include "Somfy.h"
|
|
#include "MQTT.h"
|
|
#include "GitOTA.h"
|
|
|
|
ConfigSettings settings;
|
|
Web webServer;
|
|
SocketEmitter sockEmit;
|
|
Network net;
|
|
rebootDelay_t rebootDelay;
|
|
SomfyShadeController somfy;
|
|
MQTTClass mqtt;
|
|
GitUpdater git;
|
|
|
|
void setup() {
|
|
Serial.begin(115200);
|
|
Serial.println();
|
|
Serial.println("Startup/Boot....");
|
|
Serial.println("Mounting File System...");
|
|
if(LittleFS.begin()) Serial.println("File system mounted successfully");
|
|
else Serial.println("Error mounting file system");
|
|
settings.begin();
|
|
if(WiFi.status() == WL_CONNECTED) WiFi.disconnect(true);
|
|
delay(10);
|
|
Serial.println();
|
|
webServer.startup();
|
|
webServer.begin();
|
|
delay(1000);
|
|
net.setup();
|
|
somfy.begin();
|
|
git.checkForUpdate();
|
|
}
|
|
|
|
void loop() {
|
|
if(!rebootDelay.reboot) git.loop();
|
|
|
|
// put your main code here, to run repeatedly:
|
|
if(rebootDelay.reboot && millis() > rebootDelay.rebootTime) {
|
|
Serial.print("Rebooting after ");
|
|
Serial.print(rebootDelay.rebootTime);
|
|
Serial.println("ms");
|
|
ESP.restart();
|
|
}
|
|
uint32_t timing = millis();
|
|
net.loop();
|
|
if(millis() - timing > 100) Serial.printf("Timing Net: %dms\n", millis() - timing);
|
|
timing = millis();
|
|
somfy.loop();
|
|
if(millis() - timing > 100) Serial.printf("Timing Somfy: %dms\n", millis() - timing);
|
|
timing = millis();
|
|
if(net.connected()) {
|
|
webServer.loop();
|
|
if(millis() - timing > 200) Serial.printf("Timing WebServer: %dms\n", millis() - timing);
|
|
timing = millis();
|
|
sockEmit.loop();
|
|
if(millis() - timing > 100) Serial.printf("Timing Socket: %dms\n", millis() - timing);
|
|
timing = millis();
|
|
}
|
|
if(rebootDelay.reboot && millis() > rebootDelay.rebootTime) {
|
|
net.end();
|
|
ESP.restart();
|
|
}
|
|
}
|