proper reboot
This commit is contained in:
parent
6973677659
commit
bec4cc7358
@ -122,7 +122,12 @@ void httpLoop() {
|
|||||||
ws.cleanupClients();
|
ws.cleanupClients();
|
||||||
}
|
}
|
||||||
|
|
||||||
void websocketSend(const char *message) {
|
void httpStop() {
|
||||||
|
ws.closeAll();
|
||||||
|
ws.enable(false);
|
||||||
|
server.end();
|
||||||
|
}
|
||||||
|
|
||||||
void websocketSendAll(const char *message) {
|
void websocketSendAll(const char *message) {
|
||||||
if (websocketStarted) {
|
if (websocketStarted) {
|
||||||
ws.textAll(message);
|
ws.textAll(message);
|
||||||
|
|||||||
@ -5,7 +5,8 @@ void httpSetup();
|
|||||||
|
|
||||||
void httpLoop();
|
void httpLoop();
|
||||||
|
|
||||||
void websocketSend(const char *message);
|
void httpStop();
|
||||||
|
|
||||||
void websocketSendAll(const char *message);
|
void websocketSendAll(const char *message);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
#include "clock.h"
|
#include "clock.h"
|
||||||
#include "filesystem.h"
|
#include "filesystem.h"
|
||||||
|
#include "http.h"
|
||||||
|
#include "wifi.h"
|
||||||
|
|
||||||
void doLog(LogLevel level, const char *format, va_list args);
|
void doLog(LogLevel level, const char *format, va_list args);
|
||||||
|
|
||||||
@ -18,6 +20,8 @@ void logSetup() {
|
|||||||
info("Startup");
|
info("Startup");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto rebootRequested = false;
|
||||||
|
|
||||||
void execute(const char *cmd) {
|
void execute(const char *cmd) {
|
||||||
if (strcmp(cmd, "help") == 0) {
|
if (strcmp(cmd, "help") == 0) {
|
||||||
info("HELP");
|
info("HELP");
|
||||||
@ -38,9 +42,7 @@ void execute(const char *cmd) {
|
|||||||
info(" %-10s %s", "dns:", WiFi.dnsIP().toString().c_str());
|
info(" %-10s %s", "dns:", WiFi.dnsIP().toString().c_str());
|
||||||
} else if (strcmp(cmd, "reboot") == 0) {
|
} else if (strcmp(cmd, "reboot") == 0) {
|
||||||
info("REBOOT");
|
info("REBOOT");
|
||||||
delay(1000);
|
rebootRequested = true;
|
||||||
yield();
|
|
||||||
ESP.restart();
|
|
||||||
} else if (strcmp(cmd, "reconnect") == 0) {
|
} else if (strcmp(cmd, "reconnect") == 0) {
|
||||||
info("RECONNECT");
|
info("RECONNECT");
|
||||||
WiFi.disconnect();
|
WiFi.disconnect();
|
||||||
@ -57,7 +59,22 @@ void execute(const char *cmd) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void doReboot() {
|
||||||
|
httpStop();
|
||||||
|
wifiOff();
|
||||||
|
LittleFS.end();
|
||||||
|
yield();
|
||||||
|
|
||||||
|
delay(1000);
|
||||||
|
yield();
|
||||||
|
|
||||||
|
ESP.restart();
|
||||||
|
}
|
||||||
|
|
||||||
void logLoop() {
|
void logLoop() {
|
||||||
|
if (rebootRequested) {
|
||||||
|
doReboot();
|
||||||
|
}
|
||||||
static char buffer[64];
|
static char buffer[64];
|
||||||
static auto write = buffer;
|
static auto write = buffer;
|
||||||
if (Serial.available() > 0) {
|
if (Serial.available() > 0) {
|
||||||
|
|||||||
@ -57,6 +57,7 @@ void wifiSetupOTA() {
|
|||||||
void wifiOff() {
|
void wifiOff() {
|
||||||
info("wifi disabled");
|
info("wifi disabled");
|
||||||
wifiEnabled = false;
|
wifiEnabled = false;
|
||||||
|
WiFi.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wifiLoop() {
|
void wifiLoop() {
|
||||||
@ -64,7 +65,7 @@ void wifiLoop() {
|
|||||||
if (wifiConnected != currentState) {
|
if (wifiConnected != currentState) {
|
||||||
wifiConnected = currentState;
|
wifiConnected = currentState;
|
||||||
if (wifiConnected) {
|
if (wifiConnected) {
|
||||||
info("wifi connected: %s", WiFi.localIP().toString().c_str());
|
info("wifi connected as %s", WiFi.localIP().toString().c_str());
|
||||||
wifiSetupOTA();
|
wifiSetupOTA();
|
||||||
} else {
|
} else {
|
||||||
warn("wifi disconnected");
|
warn("wifi disconnected");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user