mirror of
https://github.com/H3ALY/Wireless-PC-Switch.git
synced 2025-12-19 10:18:22 +00:00
Update paths and additional otaManager functionality
This commit is contained in:
committed by
GitHub
parent
341acb085d
commit
81b60ce0cb
17
main.ino
17
main.ino
@@ -1,14 +1,19 @@
|
|||||||
#include <SimpleTimer.h>
|
#include <SimpleTimer.h>
|
||||||
#include "wifi_setup.h"
|
|
||||||
#include "mqtt_handler.h"
|
|
||||||
#include "power_control.h"
|
|
||||||
#include "ota_setup.h"
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "core/wifi_setup.h"
|
||||||
|
#include "core/mqtt_handler.h"
|
||||||
|
#include "core/power_control.h"
|
||||||
|
|
||||||
|
#if enable_ota
|
||||||
|
#include "core/ota_setup.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
WiFiClient espClient;
|
WiFiClient espClient;
|
||||||
MqttClient mqttClient(espClient);
|
MqttClient mqttClient(espClient);
|
||||||
PowerController powerController(14, 16, mqttClient.client);
|
PowerController powerController(14, 16, mqttClient.client);
|
||||||
|
#if enable_ota
|
||||||
OtaManager otaManager;
|
OtaManager otaManager;
|
||||||
|
#endif
|
||||||
SimpleTimer timer;
|
SimpleTimer timer;
|
||||||
|
|
||||||
void mqttCallback(char* topic, byte* payload, unsigned int length) {
|
void mqttCallback(char* topic, byte* payload, unsigned int length) {
|
||||||
@@ -26,7 +31,9 @@ void setup() {
|
|||||||
mqttClient.setupMqtt();
|
mqttClient.setupMqtt();
|
||||||
|
|
||||||
powerController.setup();
|
powerController.setup();
|
||||||
|
#if enable_ota
|
||||||
otaManager.setupOTA();
|
otaManager.setupOTA();
|
||||||
|
#endif
|
||||||
|
|
||||||
timer.setInterval(3000, []() { powerController.sensePower(); });
|
timer.setInterval(3000, []() { powerController.sensePower(); });
|
||||||
timer.setInterval(120000, []() { mqttClient.publish(check_in_topic, "OK"); });
|
timer.setInterval(120000, []() { mqttClient.publish(check_in_topic, "OK"); });
|
||||||
@@ -34,6 +41,8 @@ void setup() {
|
|||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
mqttClient.loop();
|
mqttClient.loop();
|
||||||
|
#if enable_ota
|
||||||
otaManager.handleOTA();
|
otaManager.handleOTA();
|
||||||
|
#endif
|
||||||
timer.run();
|
timer.run();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user