-
Notifications
You must be signed in to change notification settings - Fork 0
/
ESP32-WOW.ino
49 lines (40 loc) · 1.01 KB
/
ESP32-WOW.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <WiFi.h>
#include "config.h"
#include "lib\web.h"
#include "lib\oled.h"
#include "lib\ping.h"
#include "lib\ddns.h"
#include "lib\server.h"
#if CONFIG_FREERTOS_UNICORE
#define ARDUINO_RUNNING_CORE 0
#else
#define ARDUINO_RUNNING_CORE 1
#endif
unsigned long startTime;
WebServer webServer = WebServer();
void setup() {
Serial.begin(115200); // Enable serial port logging
OLED.u8g2::setI2CAddress(0x7A);
OLED.begin(); // Enable OLED display
Pinger::init(); // 初始化Ping
connectWifi(20); // Connect to wifi until success
ddns.begin(); // DDNS 更新
startTime = millis();
xTaskCreatePinnedToCore(webserver_handle, "WebServer", 6144, NULL, 1, NULL, ARDUINO_RUNNING_CORE);
}
void loop() {
ddns.update(10*1000);
OLED.update(300);
Pinger::update(2500);
if (millis() - startTime > 60*60*1000) {
ESP.restart();
};
delay(1);
}
void webserver_handle(void *params) {
webServer.begin(); // Start webserver
while(1) {
webServer.loop();
delay(1);
}
}