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