2023-11-06 19:16:07 +00:00
|
|
|
#include "Arduino.h"
|
2023-11-10 12:02:05 +00:00
|
|
|
#include <WiFiManager.h>
|
|
|
|
#define WEBSERVER_H
|
|
|
|
#include "ESPAsyncWebServer.h"
|
|
|
|
|
2023-11-07 00:11:12 +00:00
|
|
|
#include "lib/config.hpp"
|
2023-11-13 11:27:34 +00:00
|
|
|
|
2023-11-08 19:29:06 +00:00
|
|
|
//char ptrTaskList[400];
|
|
|
|
|
2023-11-25 23:51:54 +00:00
|
|
|
uint wifiLostConnection;
|
|
|
|
|
2023-11-06 19:16:07 +00:00
|
|
|
extern "C" void app_main()
|
|
|
|
{
|
|
|
|
initArduino();
|
|
|
|
|
|
|
|
Serial.begin(115200);
|
2023-11-07 20:26:15 +00:00
|
|
|
setup();
|
2023-11-06 19:16:07 +00:00
|
|
|
|
2023-11-07 00:11:12 +00:00
|
|
|
while (true)
|
|
|
|
{
|
2023-11-08 19:29:06 +00:00
|
|
|
// vTaskList(ptrTaskList);
|
|
|
|
// Serial.println(F("**********************************"));
|
|
|
|
// Serial.println(F("Task State Prio Stack Num"));
|
|
|
|
// Serial.println(F("**********************************"));
|
|
|
|
// Serial.print(ptrTaskList);
|
|
|
|
// Serial.println(F("**********************************"));
|
|
|
|
if (eventSourceTaskHandle != NULL)
|
|
|
|
xTaskNotifyGive(eventSourceTaskHandle);
|
|
|
|
|
2023-11-20 17:59:33 +00:00
|
|
|
if (!WiFi.isConnected()) {
|
2023-11-25 23:51:54 +00:00
|
|
|
if (!wifiLostConnection) {
|
|
|
|
wifiLostConnection = esp_timer_get_time() / 1000000;
|
|
|
|
Serial.println("Lost WiFi connection, trying to reconnect...");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (((esp_timer_get_time() / 1000000) - wifiLostConnection) > 600) {
|
|
|
|
Serial.println("Still no connection after 10 minutes, restarting...");
|
|
|
|
delay(2000);
|
|
|
|
ESP.restart();
|
|
|
|
}
|
|
|
|
|
2023-11-20 17:59:33 +00:00
|
|
|
WiFi.begin();
|
2023-11-25 23:51:54 +00:00
|
|
|
} else if (wifiLostConnection) {
|
|
|
|
wifiLostConnection = 0;
|
|
|
|
Serial.println("Connection restored, reset timer.");
|
2023-11-20 17:59:33 +00:00
|
|
|
}
|
|
|
|
|
2023-11-08 19:29:06 +00:00
|
|
|
vTaskDelay(pdMS_TO_TICKS(5000));
|
2023-11-07 00:11:12 +00:00
|
|
|
}
|
2023-11-06 19:16:07 +00:00
|
|
|
}
|