Browse Source

[BasicWebUpdate] Refactor web page and add a ton of details

master
Steven Haigh 2 months ago
parent
commit
ae114170de
2 changed files with 22 additions and 14 deletions
  1. 1
    1
      BasicWebUpdate/flash_esp01
  2. 21
    13
      BasicWebUpdate/src/BasicWebUpdate.ino

+ 1
- 1
BasicWebUpdate/flash_esp01 View File

@@ -1,2 +1,2 @@
1 1
 #!/bin/bash
2
-pio run -e esp01_1m -t upload
2
+~/bin/esptool.py --baud 230400 --before default_reset write_flash 0 *esp01_1m*.bin

+ 21
- 13
BasicWebUpdate/src/BasicWebUpdate.ino View File

@@ -1,6 +1,7 @@
1 1
 #include <ESP8266WiFi.h>
2 2
 #include <ESP8266WebServer.h>
3 3
 #include <ESP8266HTTPUpdateServer.h>
4
+ADC_MODE(ADC_VCC);
4 5
  
5 6
 // USER CONFIGURED SECTION START //
6 7
 const char* ssid = "YOURSSID";
@@ -10,7 +11,10 @@ ESP8266WebServer httpServer(80);
10 11
 ESP8266HTTPUpdateServer httpUpdater;
11 12
  
12 13
 void setup() {
13
-	setup_wifi();
14
+	WiFi.mode(WIFI_STA);
15
+	WiFi.hostname(WiFi.macAddress());
16
+	WiFi.begin(ssid, password);
17
+
14 18
 	httpServer.on("/", handle_root);
15 19
 	httpServer.on("/reboot", reboot);
16 20
 	httpUpdater.setup(&httpServer);
@@ -22,19 +26,23 @@ void loop() {
22 26
 	delay(10);
23 27
 }
24 28
 
25
-void setup_wifi() {
26
-	WiFi.mode(WIFI_STA);
27
-	WiFi.hostname(WiFi.macAddress());
28
-	WiFi.begin(ssid, password);
29
-	while (WiFi.status() != WL_CONNECTED) {
30
-		delay(100);
31
-	}
32
-}
33
-
34 29
 void handle_root() {
35
-	String webpage = "<html><head>WebUpdate Status<head><body><h3>Web bootstrapper</h3>";
36
-	webpage += "<br>- <a href=\"/update\">Update Firmware</a>\n";
37
-	webpage += "<br>- <a href=\"/reboot\">Reboot</a>\n</body></html>";
30
+	String webpage = String("<!DOCTYPE HTML>") +
31
+		"<head><title>WebFlash Bootloader</title></head>\n" +
32
+		"<body><table><tr><th colspan='2'>ESP8266 Infomation</th></tr>\n" +
33
+		"<tr><td>MAC Address:</td><td>" + WiFi.macAddress().c_str() + "</td></tr>\n" +
34
+		"<tr><td>CPU Speed:</td><td>" + ESP.getCpuFreqMHz() + " MHz</td></tr>\n" +
35
+		"<tr><td>CPU ID:</td><td>" + ESP.getChipId() + "</td></tr>\n" +
36
+		"<tr><td>Vcc:</td><td>" + ESP.getVcc()  + " mV</td></tr>\n" +
37
+		"<tr><td>Flash Chip ID:</td><td>" + ESP.getFlashChipId() + "</td></tr>\n" +
38
+		"<tr><td>Flash Size:</td><td>" + ESP.getFlashChipSize() + " bytes</td></tr>\n" +
39
+		"<tr><td>Flash Real Size:</td><td>" + ESP.getFlashChipRealSize() + " bytes</td></tr>\n" +
40
+		"<tr><td>Flash Speed:</td><td>" + (ESP.getFlashChipSpeed() / 1000000) + " Mhz</td></tr>\n" +
41
+		"<tr><td>Flash Mode:</td><td>" +  ESP.getFlashChipMode() + "</td></tr>\n" +
42
+		"</table>\n" +
43
+		"<br>- <a href=\"/reboot\">Reboot</a><br>- <a href=\"/update\">Update Firmware</a>" +
44
+		"</pre><br><br><font size=\"-1\">" + ESP.getFullVersion() + "</font></body></html>";
45
+	httpServer.sendHeader("Refresh", "10");
38 46
 	httpServer.send(200, "text/html", webpage);
39 47
 }
40 48
 

Loading…
Cancel
Save