mirror of
https://github.com/H3ALY/Wireless-PC-Switch.git
synced 2026-12-04 14:01:58 +00:00
Rename main.ino to src/main.ino - clean up structure
This commit is contained in:
1 parent
e6d971816c
commit
0b78e59bad
1 file changed
@@ -0,0 +1,48 @@
|
||||
#include <SimpleTimer.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;
|
||||
MqttClient mqttClient(espClient);
|
||||
PowerController powerController(14, 16, mqttClient.client);
|
||||
#if enable_ota
|
||||
OtaManager otaManager;
|
||||
#endif
|
||||
SimpleTimer timer;
|
||||
|
||||
void mqttCallback(char* topic, byte* payload, unsigned int length) {
|
||||
payload[length] = '\0';
|
||||
String command = String((char*)payload);
|
||||
powerController.handleCommand(command);
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
WiFiManager wifiManager;
|
||||
wifiManager.setup_wifi();
|
||||
|
||||
mqttClient.setCallback(mqttCallback);
|
||||
mqttClient.setupMqtt();
|
||||
|
||||
powerController.setup();
|
||||
#if enable_ota
|
||||
otaManager.setupOTA();
|
||||
#endif
|
||||
|
||||
timer.setInterval(3000, []() { powerController.sensePower(); });
|
||||
timer.setInterval(120000, []() { mqttClient.publish(check_in_topic, "OK"); });
|
||||
}
|
||||
|
||||
void loop() {
|
||||
mqttClient.loop();
|
||||
#if enable_ota
|
||||
otaManager.handleOTA();
|
||||
#endif
|
||||
timer.run();
|
||||
}
|
||||
Reference in new issue
Block a user