-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathESP-LittleFS-Web-Server.ino
711 lines (654 loc) · 19.2 KB
/
ESP-LittleFS-Web-Server.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
/*
ESP-LittleFS-Web-Server - Example of a WebServer with LittleFS backend for esp
Copyright (c) 2015 Hristo Gochkov. All rights reserved.
This file is part of the ESP8266WebServer library for Arduino environment.
And is modyfied for the LittleFS
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <Arduino.h> // https://github.com/espressif/arduino-esp32/tree/master/cores/esp32
#if defined(ESP8266)
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#else
#include <WiFi.h> // https://github.com/espressif/arduino-esp32/tree/master/libraries/WiFi
#include <WebServer.h> // https://github.com/espressif/arduino-esp32/tree/master/libraries/WebServer
#include <ESPmDNS.h> // https://github.com/espressif/arduino-esp32/tree/master/libraries/ESPmDNS
#endif
#include <WiFiManager.h> // WifiManager by tzapu https://github.com/tzapu/WiFiManager
#include <ArduinoOTA.h> // ArduinoOTA by Arduino, Juraj https://github.com/JAndrassy/ArduinoOTA
#if defined(ESP8266)
#include <LittleFS.h>
#include <FS.h>
#else
#include <LittleFS.h>
#include <FS.h>
#endif
#define debug_print // manages most of the print and println debug, not all but most
#if defined debug_print
#define debug_begin(x) Serial.begin(x)
#define debug(x) Serial.print(x)
#define debugln(x) Serial.println(x)
#define setdebug(x) Serial.setDebugOutput(x)
#else
#define debug_begin(x)
#define debug(x)
#define debugln(x)
#define setdebug(x)
#endif
#if defined(ESP8266)
#warning "ESP8266 Pins You can not change them"
#endif
#define USEWIFIMANAGER
#ifndef USEWIFIMANAGER
const char *ssid = "SSID_ROUTER";
const char *password = "Password_Router";
#endif
#if defined(ESP8266)
const char *host = "ESP-LittleFS-12E";
#elif defined(CONFIG_IDF_TARGET_ESP32)
const char *host = "ESP-LittleFS-ESP";
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
const char *host = "ESP-LittleFS-C3";
#elif defined(CONFIG_IDF_TARGET_ESP32C6)
const char *host = "ESP-LittleFS-C6";
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
const char *host = "ESP-LittleFS-S2";
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
const char *host = "ESP-LittleFS-S3";
#endif
#if defined(ESP8266)
#define PIN_BOOT 0
#elif defined(CONFIG_IDF_TARGET_ESP32)
#define PIN_BOOT 0
#elif defined(CONFIG_IDF_TARGET_ESP32C3)
#define PIN_BOOT 9
#elif defined(CONFIG_IDF_TARGET_ESP32C6)
#define PIN_BOOT 9
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
#define PIN_BOOT 0
#elif defined(CONFIG_IDF_TARGET_ESP32S3)
#define PIN_BOOT 0
#if not defined(PIN_NEOPIXEL)
#define PIN_NEOPIXEL 48
#endif
#endif
#define PIN_LED LED_BUILTIN
#if defined(ESP8266)
ESP8266WebServer server(80);
#else
WebServer server(80);
#endif
unsigned long PreviousTimeSeconds;
unsigned long PreviousTimeMinutes;
unsigned long PreviousTimeHours;
unsigned long PreviousTimeDay;
unsigned long currentTimeSeconds = 0;
unsigned long NextTime = 0;
uint16_t Config_Reset_Counter = 0;
int OTAUploadBusy = 0;
File uploadFile;
String message;
void returnOK()
{
server.send(200, "text/plain", "");
}
void returnFail(String msg)
{
server.send(500, "text/plain", msg + "\r\n");
}
bool loadFromLittleFS(String path)
{
String dataType = "text/plain";
debugln(" GetFile " + path);
if (path.endsWith("/"))
path += "index.htm";
if (path.endsWith(".src"))
path = path.substring(0, path.lastIndexOf("."));
else if (path.endsWith(".htm"))
dataType = "text/html";
else if (path.endsWith(".html"))
dataType = "text/html";
else if (path.endsWith(".css"))
dataType = "text/css";
else if (path.endsWith(".js"))
dataType = "application/javascript";
else if (path.endsWith(".png"))
dataType = "image/png";
else if (path.endsWith(".gif"))
dataType = "image/gif";
else if (path.endsWith(".jpg"))
dataType = "image/jpeg";
else if (path.endsWith(".ico"))
dataType = "image/x-icon";
else if (path.endsWith(".xml"))
dataType = "text/xml";
else if (path.endsWith(".pdf"))
dataType = "application/pdf";
else if (path.endsWith(".zip"))
dataType = "application/zip";
debugln(" GetFile dataType " + String(dataType));
File dataFile = LittleFS.open(path, "r");
size_t filesize = dataFile.size();
;
if (!dataFile || filesize == 0)
{ // it will retuen a file handel
debugln("File not found " + path);
return false;
}
debugln("File found " + path + " Size " + String(filesize));
if (server.hasArg("download"))
dataType = "application/octet-stream";
if (path.endsWith("gz") &&
dataType != "application/x-gzip" &&
dataType != "application/octet-stream")
{
server.sendHeader(F("Content-Encoding"), F("gzip"));
}
// server.sendHeader("Connection","keep-alive",true);
// server.sendHeader("Keep-Alive", "timeout=2000");
// server.setContentLength(CONTENT_LENGTH_UNKNOWN);
server.sendHeader("Access-Control-Allow-Origin", "*");
server.setContentLength(filesize);
server.send(200, dataType, "");
debugln(" GetFile filesize " + String(filesize));
size_t blocksize = 0;
char databuffer[1024];
while (filesize > 0)
{
blocksize = dataFile.read((uint8_t *)databuffer, sizeof(databuffer));
if (blocksize > 0)
server.sendContent(databuffer, blocksize);
else
filesize = 0;
if (filesize > blocksize)
filesize -= blocksize;
else
filesize = 0;
debugln(" GetFile Size " + String(filesize));
}
//server.client().flush();
dataFile.close();
return true;
}
void handleFileUpload()
{
if (server.uri() != "/edit")
return;
HTTPUpload &upload = server.upload();
if (upload.status == UPLOAD_FILE_START)
{
if (LittleFS.exists(upload.filename))
LittleFS.remove(upload.filename);
uploadFile = LittleFS.open(upload.filename, "w");
debug("Upload: START, filename: ");
debugln(upload.filename);
}
else if (upload.status == UPLOAD_FILE_WRITE)
{
if (uploadFile)
uploadFile.write(upload.buf, upload.currentSize);
debug("Upload: WRITE, Bytes: ");
debugln(upload.currentSize);
}
else if (upload.status == UPLOAD_FILE_END)
{
if (uploadFile)
uploadFile.close();
debug("Upload: END, Size: ");
debugln(upload.totalSize);
}
}
void handleDelete()
{
debugln(" Delete ");
if (server.args() == 0)
return returnFail("BAD ARGS");
String path = server.arg(0);
debugln("Delete: " + path);
if (path == "/" || !LittleFS.exists(path))
{
returnFail("BAD File Path: " + path);
return;
}
LittleFS.remove(path);
returnOK();
}
void handleCreate()
{
if (server.args() == 0)
return returnFail("BAD ARGS");
String path = server.arg(0);
debugln("Create: " + path);
if (path == "/" || LittleFS.exists(path))
{
returnFail("BAD PATH");
return;
}
if(path.indexOf('.') > 0){
debugln("CreateFile: " + path);
File file = LittleFS.open(path, "w");
if (file)
{
file.write((const uint8_t *)" ", 1); // must write one char
file.close();
}
}
else
{
debugln("CreateDir: " + path);
LittleFS.mkdir(path);
}
returnOK();
}
#if defined(ESP8266)
void printDirectory()
{
String output;
int cnt = 0;
bool foundfile;
if (!server.hasArg("dir"))
return returnFail("BAD ARGS");
String path = server.arg("dir");
debugln(" DIR: ");
server.setContentLength(CONTENT_LENGTH_UNKNOWN);
server.send(200, "text/json", "");
Dir dir = LittleFS.openDir(path);
foundfile = dir.next();
while (foundfile)
{
output = String(cnt++>0?",{":"[{")
+ "\"name\":\"" + String(dir.fileName())+"\""
+ ",\"type\":\"" + String((dir.isDirectory()) ? "dir" : "file")+"\""
+ String((dir.isDirectory()) ?"":(",\"size\":\"" + String(dir.fileSize())+"\""))
+ "}";
foundfile = dir.next();
if (!foundfile)
output += ']';
debugln("Dir: " + output);
server.sendContent(output);
}
// server.client().flush();
}
#else
void printDirectory()
{
if (!server.hasArg("dir"))
return returnFail("BAD ARGS");
String path = server.arg("dir");
String output;
if(path != "/" && !LittleFS.exists(path)) return returnFail("BAD PATH");
File dir = LittleFS.open(path);
path = String();
if (!dir.isDirectory())
{
dir.close();
return returnFail("NOT DIR");
}
dir.rewindDirectory();
server.setContentLength(CONTENT_LENGTH_UNKNOWN);
server.send(200, "text/json", "");
WiFiClient client = server.client();
//server.sendContent("[");
for (int cnt = 0; true; ++cnt)
{
File entry = dir.openNextFile();
if (!entry)
break;
output = String(cnt>0?",{":"[{")
+ "\"type\":\"" + String((entry.isDirectory()) ? "dir" : "file")+"\""
+ ",\"name\":\"" + String(entry.name())+"\""
+ String((entry.isDirectory()) ?"":",\"size\":\"" + String(entry.size())+"\"")
+ "}";
server.sendContent(output);
entry.close();
}
server.sendContent("]");
//server.client().flush();
dir.close();
}
#endif
String urlDecode(const String &text)
{
String decoded = "";
char temp[] = "0x00";
unsigned int len = text.length();
unsigned int i = 0;
while (i < len)
{
char decodedChar;
char encodedChar = text.charAt(i++);
if ((encodedChar == '%') && (i + 1 < len))
{
temp[2] = text.charAt(i++);
temp[3] = text.charAt(i++);
decodedChar = strtol(temp, NULL, 16);
}
else
{
if (encodedChar == '+')
{
decodedChar = ' ';
}
else
{
decodedChar = encodedChar; // normal ascii char
}
}
decoded += decodedChar;
}
return decoded;
}
void handleNotFound()
{
if (loadFromLittleFS(urlDecode(server.uri())))
return;
String message = "";
message += "URI: ";
message += server.uri();
message += "\nMethod: ";
message += (server.method() == HTTP_GET) ? "GET" : "POST";
message += "\nArguments: ";
message += server.args();
message += "\n";
for (uint8_t i = 0; i < server.args(); i++)
{
message += " NAME:" + server.argName(i) + "\n VALUE:" + server.arg(i) + "\n";
}
server.send(404, "text/plain", message);
//server.client().flush();
debug(message);
}
const char Index_html[] PROGMEM = R"rawliteral(<!DOCTYPE html>
<html lang="en">
<head>
<title>LittleFS Editor</title>
<script src="https://emilespecialproducts.github.io/ESP-LittleFS-Web-Server/editor.js" type="text/javascript"></script>
</head>
<body onload="onBodyLoad();">
<div id="uploader"></div>
<div id="tree" class="css-tree"></div>
<div id="editor"></div>
<div id="preview" style="display:none;"></div>
<iframe id=download-frame style='display:none;'></iframe>
</body>
</html>
)rawliteral";
void Log(String Str)
{
debugln(Str);
#if defined(ESP8266)
File LogFile = LittleFS.open("/log.txt", "a"); // FILE_WRITE | O_APPEND);
#else
File LogFile = LittleFS.open("/log.txt", FILE_APPEND);
#endif
LogFile.println(Str);
LogFile.close();
}
void setup(void)
{
pinMode(PIN_BOOT, INPUT_PULLUP);
pinMode(PIN_LED, OUTPUT);
#if defined(ESP8266) || defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32) || Serial == USBSerial
debug_begin(115200);
#else
debug_begin(115200, SERIAL_8N1, RX, TX);
#endif
setdebug(true);
debug("\n");
#ifdef USEWIFIMANAGER
// WiFiManager, Local intialization. Once its business is done, there is no need to keep it around
WiFiManager wm;
// reset settings - wipe stored credentials for testing
// these are stored by the esp library
// wm.resetSettings();
// Automatically connect using saved credentials,
// if connection fails, it starts an access point with the specified name ( "AutoConnectAP"),
// if empty will auto generate SSID, if password is blank it will be anonymous AP (wm.autoConnect())
// then goes into a blocking loop awaiting configuration and will return success result
bool res;
res = wm.autoConnect(); // auto generated AP name from chipid
// res = wm.autoConnect(DeviceName); // anonymous ap
// res = wm.autoConnect("AutoConnectAP","password"); // password protected ap
if (!res)
{
debugln("Failed to connect Restarting");
delay(5000);
if (digitalRead(PIN_BOOT) == LOW)
{
wm.resetSettings();
}
ESP.restart();
}
else
{
// if you get here you have connected to the WiFi
}
#else
WiFi.begin(ssid, password);
debug("Connecting to ");
debugln(ssid);
// Wait for connection
uint8_t i = 0;
while (WiFi.status() != WL_CONNECTED && i++ < 20)
{ // wait 10 seconds
delay(500);
}
if (i == 21)
{
debug("Could not connect to");
debugln(ssid);
while (1)
delay(500);
}
#endif
WiFi.setSleep(false);
#if not defined(ESP8266)
esp_wifi_set_ps(WIFI_PS_NONE); // Esp32 enters the power saving mode by default,
#endif
debug("Connected! IP address: ");
debugln(WiFi.localIP());
debug("Connecting to ");
debugln(WiFi.SSID());
if (MDNS.begin(host))
{
MDNS.addService("http", "tcp", 80);
debugln("MDNS responder started");
debug("You can now connect to http://");
debug(host);
debug(".local or http://");
debugln(WiFi.localIP());
}
// Port defaults to 3232
// ArduinoOTA.setPort(3232);
// Hostname defaults to esp3232-[MAC]
ArduinoOTA.setHostname(host);
// No authentication by default
// ArduinoOTA.setPassword("admin");
// Password can be set with it's md5 value as well
// MD5(admin) = 21232f297a57a5a743894a0e4a801fc3
// ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3");
ArduinoOTA.onStart([]()
{
String type;
if (ArduinoOTA.getCommand() == U_FLASH) {
type = "sketch";
} else { // U_FS
type = "filesystem";
}
// NOTE: if updating FS this would be the place to unmount FS using FS.end()
OTAUploadBusy=60; // only do a update for 60 sec;
debugln("Start updating " + type); });
ArduinoOTA.onEnd([]()
{
OTAUploadBusy=0;
debugln("\nEnd"); });
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total)
{ debug("Progress: " + String((progress / (total / 100))) + "\r"); });
ArduinoOTA.onError([](ota_error_t error)
{
OTAUploadBusy=0;
debugln("Error: "+String( error));
if (error == OTA_AUTH_ERROR) {
debugln("Auth Failed");
} else if (error == OTA_BEGIN_ERROR) {
debugln("Begin Failed");
} else if (error == OTA_CONNECT_ERROR) {
debugln("Connect Failed");
} else if (error == OTA_RECEIVE_ERROR) {
debugln("Receive Failed");
} else if (error == OTA_END_ERROR) {
debugln("End Failed");
} });
ArduinoOTA.begin();
debug("LittleFS : "); // LittleFS.begin can take 10 seconds to start formating
#if defined(ESP8266)
if (!LittleFS.begin())
#else
if (!LittleFS.begin(true)) // FORMAT_LITTLEFS_IF_FAILED
#endif
{
debugln(" Mount Failed");
}
else
{
debugln(" Started ");
}
server.on("/", HTTP_GET, []()
{ server.sendHeader("Access-Control-Allow-Origin", "*");
server.send_P(200, "text/html", Index_html, sizeof(Index_html)-1); });
server.on("/list", HTTP_GET, printDirectory);
server.on("/edit", HTTP_DELETE, handleDelete);
server.on("/edit", HTTP_PUT, handleCreate);
server.on("/edit", HTTP_POST, []()
{ returnOK(); }, handleFileUpload);
server.onNotFound(handleNotFound);
server.begin();
debugln("HTTP server started");
message = "Reboot from: ";
#if defined(ESP8266)
message += ESP.getChipId();
#else
message += ESP.getChipModel();
#endif
message += "_";
message += WiFi.macAddress();
message += " LocalIpAddres: " + WiFi.localIP().toString();
message += " SSID: " + String(WiFi.SSID());
message += " Rssi: " + String(WiFi.RSSI());
#if not defined(ESP8266)
message += " Total heap: " + String(ESP.getHeapSize() / 1024);
message += " Free heap: " + String(ESP.getFreeHeap() / 1024);
message += " Total PSRAM: " + String(ESP.getPsramSize() / 1024);
message += " Free PSRAM: " + String(ESP.getFreePsram() / 1024);
message += " Temperature: " + String(temperatureRead()) + " °C "; // internal TemperatureSensor
#if defined(CONFIG_IDF_TARGET_ESP32)
message += " HallSensor: " + String(hallRead());
#endif
#else
message += " FlashChipId: " + String(ESP.getFlashChipId());
message += " FlashChipRealSize: " + String(ESP.getFlashChipRealSize());
#endif
message += " FlashChipSize: " + String(ESP.getFlashChipSize());
message += " FlashChipSpeed: " + String(ESP.getFlashChipSpeed());
#if not defined(ESP8266)
#if ESP_ARDUINO_VERSION != ESP_ARDUINO_VERSION_VAL(2, 0, 17)
// [ESP::getFlashChipMode crashes on ESP32S3 boards](https://github.com/espressif/arduino-esp32/issues/9816)
message += " FlashChipMode: ";
switch (ESP.getFlashChipMode())
{
case FM_QIO:
message += "FM_QIO";
break;
case FM_QOUT:
message += "FM_QOUT";
break;
case FM_DIO:
message += "FM_DIO";
break;
case FM_DOUT:
message += "FM_DOUT";
break;
case FM_FAST_READ:
message += "FM_FAST_READ";
break;
case FM_SLOW_READ:
message += "FM_SLOW_READ";
break;
default:
message += String(ESP.getFlashChipMode());
}
#endif
#endif
#if not defined(ESP8266)
message += " esp_idf_version: " + String(esp_get_idf_version());
message += " arduino_version: " + String(ESP_ARDUINO_VERSION_MAJOR) + "." + String(ESP_ARDUINO_VERSION_MINOR) + "." + String(ESP_ARDUINO_VERSION_PATCH);
#endif
message += " Build Date: " + String(__DATE__ " " __TIME__);
Log(message);
NextTime = millis() + 1000;
}
void loop(void)
{
unsigned long Time = millis();
yield();
ArduinoOTA.handle();
if (OTAUploadBusy == 0)
{ // Do not do things that take time when OTA is busy
server.handleClient();
}
if (PreviousTimeDay != (currentTimeSeconds / (60 * 60 * 24)))
{ // Day Loop
PreviousTimeDay = (currentTimeSeconds / (60 * 60 * 24));
}
if (PreviousTimeHours != (currentTimeSeconds / (60 * 60)))
{ // Hours Loop
PreviousTimeHours = (currentTimeSeconds / (60 * 60));
}
if (PreviousTimeMinutes != (currentTimeSeconds / 60))
{ // Minutes loop
PreviousTimeMinutes = (currentTimeSeconds / 60);
if ((WiFi.status() != WL_CONNECTED))
{ // if WiFi is down, try reconnecting
WiFi.disconnect();
WiFi.reconnect();
}
}
if (Time >= NextTime) // This will fail after 71 days
{
NextTime = millis() + 1000;
currentTimeSeconds++;
if (digitalRead(PIN_LED) == 0)
digitalWrite(PIN_LED, 1);
else
digitalWrite(PIN_LED, 0);
if (OTAUploadBusy > 0)
OTAUploadBusy--;
#ifdef USEWIFIMANAGER
if (digitalRead(PIN_BOOT) == LOW)
{
if (++Config_Reset_Counter > 5)
{ // press the BOOT 5 sec to reset the WifiManager Settings
WiFiManager wm; // WiFiManager, Local intialization. Once its business is done, there is no need to keep it around
delay(500);
wm.resetSettings();
ESP.restart();
}
}
else
{
Config_Reset_Counter = 0;
}
#endif
}
}