Skip to content

Commit 6e42ffd

Browse files
Merge pull request #20 from benbierens/feature/reset-wifi
Adds support for resetting wifi credentials
2 parents 859739d + a7d9e71 commit 6e42ffd

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

README.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,21 @@ To program the ESP8266 with the Arduino IDE, you need to install the board infor
109109
## Remark about the WiFi setup
110110

111111
Regarding the Wifi setting, I have actually implemented two variants:
112-
1. By default the WifiManager is activated. That is, the word clock makes the first time its own WiFi (should be called "WordclockAP"). There you simply connect to the cell phone and you can perform configuration of the WiFi settings conveniently as with a SmartHome devices (Very elegant 😊)
112+
1. By default the WifiManager is activated. That is, the word clock makes the first time its own WiFi (should be called "WordclockAP"). There you connect from a cell phone to `192.168.4.1`* and you can perform configuration of the WiFi settings conveniently as with a SmartHome devices (Very elegant 😊)
113113
2. Another (traditional) variant is to define the wifi credentials in the code (in secrets.h).
114114
- For this you have to comment out lines 230 to 251 in the code of the file *wordclock_esp8266.ino* (/\* before and \*/ after)
115115
- and comment out lines 257 to 305 (/\* and \*/ remove)
116+
(* default IP provided by the WifiMAnager library.)
116117

118+
## Resetting the wifi
119+
120+
You can clear the stored wifi credentials and restart the wifi setup described above with these steps:
121+
1. Open the settings panel in the web UI.
122+
2. Enable 'Reset Wifi' slider.
123+
3. Save settings.
124+
4. LED test should be performed.
125+
5. Disconnect and reconnect the power. Wifi credentials were removed. Setup should be restarted.
126+
Resetting the wifi credentials does not delete uploaded files.
117127

118128
## Remark about Logging
119129

data/index.html

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@
243243
}
244244

245245
.show{
246-
height: 150px;
246+
height: 200px;
247247
transition: height 1s;
248248
}
249249

@@ -284,6 +284,12 @@ <h1 id="headline">WORDCLOCK 2.0</h1>
284284
<label for="nm_end" style="align-self: flex-start">Nightmode end time: </label>
285285
<input type="time" id="nm_end" name="nm_end" min="00:00" max="23:59">
286286
</div>
287+
<div class="checkbox-container">
288+
<label for="ResetWifi" style="align-self: flex-start">Reset Wifi</label>
289+
<div>
290+
<input name= "ResetWifi" id="ResetWifi" type="checkbox" class="toggle">
291+
</div>
292+
</div>
287293
<div class="buttonClass save-button" onclick="saveSettings()">SAVE</div>
288294
</div>
289295

@@ -538,6 +544,7 @@ <h1 id="headline">WORDCLOCK 2.0</h1>
538544
var nmStart = document.getElementById("nm_start");
539545
var nmEnd = document.getElementById("nm_end");
540546
var brightnessElmt = document.getElementById("brightness");
547+
var ckb_resetWifi = document.querySelector('input[id="ResetWifi"]');
541548
var cmdstr = "./cmd?setting=";
542549
cmdstr += nmStart.value.replace(":", "-");
543550
cmdstr += "-";
@@ -546,6 +553,9 @@ <h1 id="headline">WORDCLOCK 2.0</h1>
546553
cmdstr += brightnessElmt.value;
547554
console.log(cmdstr);
548555
sendCommand(cmdstr);
556+
if(ckb_resetWifi.checked) {
557+
sendCommand("./cmd?resetwifi");
558+
}
549559
toggleSettings();
550560
}
551561

wordclock_esp8266.ino

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ ESP8266WebServer server(HTTPPort);
145145
//DNS Server
146146
DNSServer DnsServer;
147147

148+
// Wifi server. keep around to support resetting.
149+
WiFiManager wifiManager;
150+
148151
// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
149152
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
150153
// example for more information on possible values.
@@ -236,7 +239,7 @@ void setup() {
236239
/** Use WiFiMaanger for handling initial Wifi setup **/
237240

238241
// Local intialization. Once its business is done, there is no need to keep it around
239-
WiFiManager wifiManager;
242+
240243

241244
// Uncomment and run it once, if you want to erase all the stored information
242245
//wifiManager.resetSettings();
@@ -368,7 +371,6 @@ void setup() {
368371
ledmatrix.drawOnMatrixInstant();
369372
}
370373

371-
372374
// setup NTP
373375
ntp.setupNTPClient();
374376
logger.logString("NTP running");
@@ -856,6 +858,23 @@ void handleCommand() {
856858
logger.logString("Brightness: " + String(brightness));
857859
ledmatrix.setBrightness(brightness);
858860
}
861+
else if (server.argName(0) == "resetwifi"){
862+
wifiManager.resetSettings();
863+
// run LED test.
864+
for(int r = 0; r < HEIGHT; r++){
865+
for(int c = 0; c < WIDTH; c++){
866+
matrix.fillScreen(0);
867+
matrix.drawPixel(c, r, LEDMatrix::color24to16bit(colors24bit[2]));
868+
matrix.show();
869+
delay(10);
870+
}
871+
}
872+
873+
// clear Matrix
874+
matrix.fillScreen(0);
875+
matrix.show();
876+
delay(200);
877+
}
859878
else if(server.argName(0) == "stateautochange"){
860879
String modestr = server.arg(0);
861880
logger.logString("stateAutoChange change via Webserver to: " + modestr);

0 commit comments

Comments
 (0)